uk.ac.bbk.dcs.automed.hdmstore
Class HdmStoreCmd

java.lang.Object
  extended by uk.ac.bbk.dcs.automed.hdmstore.HdmStoreCmd

public class HdmStoreCmd
extends java.lang.Object

A command line processor for the HDM store which can be used as an alternative to the API..

Author:
Dean Williams (dean@dcs.bbk.ac.uk)

Field Summary
private static char comma
           
private  Debug debug
           
private  HdmStore hdmStore
           
private static char hideComma
           
private static java.lang.String hideSpace
           
private  java.util.HashMap macros
           
private static java.lang.String space
           
 
Constructor Summary
HdmStoreCmd(java.lang.String[] args)
          Construct a HdmStoreCmd and process the command line arguments
 
Method Summary
private  java.util.ArrayList breakIntoCommands(java.lang.String inputFileName)
          Take the command file and break into an array list of individual commands
private static java.lang.String changeInternalSpaces(java.lang.String orig, java.lang.String from, java.lang.String to)
          Change internal seperators from one string to another
private  java.lang.String chomp(java.lang.String in)
          Given a string, return the string less any preceeding or trailing spaces.
private  java.lang.String expandEdgeNames(java.lang.String command)
          If edge names have been given without types expand out e.g.
static java.lang.String hideInternalSpaces(java.lang.String orig)
          Change any spaces within an edge thats a span to another character
static void main(java.lang.String[] args)
          main creates an HdmStoreCmd and passes the arguments
private  void processAdd(java.lang.String pType, java.lang.String pValue)
          Process an 'add' command - for either an edge or a node.
private  void processCommand(java.lang.String command)
          Takes a command in the full notation and processes it by making appropriate HDM Store API calls.
private  java.lang.String processMacros(java.lang.String command)
          Macros are short cuts.
private  java.util.ArrayList processMultipleInstances(java.lang.String command)
          For this command, if its a compound command break it out into a number of simple commands e.g add [dean,mat] becomes: add [dean] add [mat]
private  java.lang.String replaceAny(java.lang.String in, java.lang.String key, java.lang.String value)
          If there is an occurance of string key in string in, then replace it with the string value and repeat until there are no more occurances.
static java.lang.String returnInternalSpaces(java.lang.String orig)
          Changeback any seperators within an edge thats a span to spaces
private  java.lang.String swapInternalCommas(java.lang.String in)
          An edge may have an edge as one of its spans.
static void usage()
          Show the useage message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

space

private static final java.lang.String space
See Also:
Constant Field Values

hideSpace

private static final java.lang.String hideSpace
See Also:
Constant Field Values

comma

private static final char comma
See Also:
Constant Field Values

hideComma

private static final char hideComma
See Also:
Constant Field Values

macros

private java.util.HashMap macros

hdmStore

private HdmStore hdmStore

debug

private Debug debug
Constructor Detail

HdmStoreCmd

public HdmStoreCmd(java.lang.String[] args)
Construct a HdmStoreCmd and process the command line arguments

Method Detail

processMultipleInstances

private java.util.ArrayList processMultipleInstances(java.lang.String command)
For this command, if its a compound command break it out into a number of simple commands e.g add [dean,mat] becomes: add [dean] add [mat]


expandEdgeNames

private java.lang.String expandEdgeNames(java.lang.String command)
If edge names have been given without types expand out e.g. add <
> ...... goes to add <>


processMacros

private java.lang.String processMacros(java.lang.String command)
Macros are short cuts. If you type a long edge name you vsn then identify and number it e.g. &1 for later reference. This rountine expands out any macros it finds.


replaceAny

private java.lang.String replaceAny(java.lang.String in,
                                    java.lang.String key,
                                    java.lang.String value)
If there is an occurance of string key in string in, then replace it with the string value and repeat until there are no more occurances. NVB the built in replace method on Strings only works on single characters.


processCommand

private void processCommand(java.lang.String command)
Takes a command in the full notation and processes it by making appropriate HDM Store API calls.


processAdd

private void processAdd(java.lang.String pType,
                        java.lang.String pValue)
Process an 'add' command - for either an edge or a node.


swapInternalCommas

private java.lang.String swapInternalCommas(java.lang.String in)
An edge may have an edge as one of its spans. Changing the commas on these 'internal edges' makes it possible to split the string into spans byt looking for commas.


chomp

private java.lang.String chomp(java.lang.String in)
Given a string, return the string less any preceeding or trailing spaces.


hideInternalSpaces

public static java.lang.String hideInternalSpaces(java.lang.String orig)
Change any spaces within an edge thats a span to another character


returnInternalSpaces

public static java.lang.String returnInternalSpaces(java.lang.String orig)
Changeback any seperators within an edge thats a span to spaces


changeInternalSpaces

private static java.lang.String changeInternalSpaces(java.lang.String orig,
                                                     java.lang.String from,
                                                     java.lang.String to)
Change internal seperators from one string to another


breakIntoCommands

private java.util.ArrayList breakIntoCommands(java.lang.String inputFileName)
Take the command file and break into an array list of individual commands


usage

public static void usage()
Show the useage message


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception,
                        java.sql.SQLException,
                        java.io.IOException
main creates an HdmStoreCmd and passes the arguments

Throws:
java.lang.Exception
java.sql.SQLException
java.io.IOException