nectec.semantic.web.knowledge.application.framework.common
Class Common

java.lang.Object
  extended by nectec.semantic.web.knowledge.application.framework.common.Common

public abstract class Common
extends Object

Abstract class for storing common variables and useful methods used in many places internally to perform desired function. It is also available for general public use.


Field Summary
static String CLASS_ONT
          In each mapping configuration file, this will be the 'key' name for storing the name of ontology class, which will be aligned to the database table.
static String DISPLAY_PT
          In each configuration file (except mapping), this will be the 'key' name for storing sequence of the names of ontology properties which are used (when information of an instance is requested) to deliver these information of that particular instance specified.
static String ENCODING
          Character encoding used for I/O tasks.
static String INTERNAL_NAMESPACE
          Namespace used for storing immediate RDF data produced by D2RQ module (Not for public use).
static String ONTOLOGY_FILE
          In each configuration file (mapping, searching, etc), this will be the 'key' name for storing the name of ontology file.
static String PATHS
          In each configuration file (except mapping), this will be the 'key' name for storing the sequences of class names of interest.
static String PT_LABEL
          In each mapping configuration file, this will be the 'key' name for storing the label (different from rdfs:label) for the respective ontology property.
static boolean SHOW_INFO
          Boolean flag to indicate whether the system will show the series of detailed information (SPARQL query string used, for example) as the processing goes so that user can trace how any particular function works, or not.
static String TABLEDB
          In each mapping configuration file, this will be the 'key' name for storing the name of database table, which will be aligned to the class of the ontology.
static String TARGET_UNQ_PTY
          In each configuration file (except mapping), this will be the 'key' name for storing the name of ontology property, which can be treated as a unique ID to identify its instance.
static String UNIQUE_ID_ONT
          In each mapping configuration file, this will be the 'key' name for storing the name of ontology property, which can be treated as a unique ID to identify its instance.
 
Constructor Summary
Common()
           
 
Method Summary
static boolean containsElement(ArrayList<String> inputCollection, String elementToTest)
          Check whether the given collection contains certain element or not.
static ArrayList<String> convertArrayToArrayList(String[] inputArray)
          Transform from String Array data structure into String ArrayList.
static ArrayList<String> customTokenize(String inputString, String delimiter)
          Extend the function of standard Java class 'Tokenizer' in the way that it returns the tokens in a collection.
static void deleteDirectoryOrFile(File path)
          Delete the directory of given path including the files inside the directory.
static ArrayList<String> getAllHozoSpecificDatatypes(String NS)
          Get the list of terminologies (resource names) that are specific to HOZO ontology editor.
static boolean isDouble(String inputString)
          Check whether the input String is datatype double or not.
static boolean isInteger(String inputString)
          Check whether the input String is datatype integer(int) or not.
static boolean isNumberConvertibleString(String inputString)
          Check whether the given string is possible to convert number format.
static String printInfo(String inputString)
          Print the input string if 'Common.SHOW_INFO' is true.
static HashMap<String,String> readAllConfig(String app_dir, String root)
          Basically work in the same way as "readMaps()" function except that this aware the common configuration of the given application directory.
static ArrayList<String> readLines(String fileName, String filePath)
          Read the lines from a given file and return them as a collection.
static HashMap<String,String> readMaps(String fileName, String filePath)
          Read the given file in which each line represents key-value pairs separated by "|" character.
static ArrayList<String> removeDuplicate(ArrayList<String> inputCollection)
          Look for the duplicate elements in the given collection and remove them so that only unique elements are stored.
static ArrayList<String> removeHozoProprietaryResources(ArrayList<String> inputCollection)
          Remove all the proprietary (non-standard) resources provided by HOZO Ontology Editor.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHOW_INFO

public static boolean SHOW_INFO
Boolean flag to indicate whether the system will show the series of detailed information (SPARQL query string used, for example) as the processing goes so that user can trace how any particular function works, or not.


CLASS_ONT

public static final String CLASS_ONT
In each mapping configuration file, this will be the 'key' name for storing the name of ontology class, which will be aligned to the database table.

See Also:
Constant Field Values

TABLEDB

public static final String TABLEDB
In each mapping configuration file, this will be the 'key' name for storing the name of database table, which will be aligned to the class of the ontology.

See Also:
Constant Field Values

PT_LABEL

public static final String PT_LABEL
In each mapping configuration file, this will be the 'key' name for storing the label (different from rdfs:label) for the respective ontology property.

See Also:
Constant Field Values

INTERNAL_NAMESPACE

public static final String INTERNAL_NAMESPACE
Namespace used for storing immediate RDF data produced by D2RQ module (Not for public use).

See Also:
Constant Field Values

ONTOLOGY_FILE

public static final String ONTOLOGY_FILE
In each configuration file (mapping, searching, etc), this will be the 'key' name for storing the name of ontology file.

See Also:
Constant Field Values

PATHS

public static final String PATHS
In each configuration file (except mapping), this will be the 'key' name for storing the sequences of class names of interest. Class names are represented by directory (path) names.

See Also:
Constant Field Values

ENCODING

public static String ENCODING
Character encoding used for I/O tasks.


UNIQUE_ID_ONT

public static final String UNIQUE_ID_ONT
In each mapping configuration file, this will be the 'key' name for storing the name of ontology property, which can be treated as a unique ID to identify its instance.

See Also:
Constant Field Values

TARGET_UNQ_PTY

public static final String TARGET_UNQ_PTY
In each configuration file (except mapping), this will be the 'key' name for storing the name of ontology property, which can be treated as a unique ID to identify its instance.

See Also:
Constant Field Values

DISPLAY_PT

public static final String DISPLAY_PT
In each configuration file (except mapping), this will be the 'key' name for storing sequence of the names of ontology properties which are used (when information of an instance is requested) to deliver these information of that particular instance specified.

See Also:
Constant Field Values
Constructor Detail

Common

public Common()
Method Detail

convertArrayToArrayList

public static ArrayList<String> convertArrayToArrayList(String[] inputArray)
Transform from String Array data structure into String ArrayList.

Parameters:
inputArray - String Array to be converted.
Returns:
Transformed String ArrayList.

isDouble

public static boolean isDouble(String inputString)
Check whether the input String is datatype double or not.

Parameters:
inputString - String to be checked.
Returns:
true (It is double) or false (It is not double).

isInteger

public static boolean isInteger(String inputString)
Check whether the input String is datatype integer(int) or not.

Parameters:
inputString - String to be checked.
Returns:
true (It is integer) or false (It is not integer).

readLines

public static ArrayList<String> readLines(String fileName,
                                          String filePath)
Read the lines from a given file and return them as a collection. One element in the collection represents one line of the file.

Parameters:
fileName - Name of the file to be read.
filePath - Location of the file on system.
Returns:
Collection of lines from the file specified.

readMaps

public static HashMap<String,String> readMaps(String fileName,
                                              String filePath)
Read the given file in which each line represents key-value pairs separated by "|" character. Store them in a Map-where the "key|value" becomes the key and value of the Map element respectively.

Parameters:
fileName - Name of the file to be read.
filePath - Location of the file on system.
Returns:
Map containing all pairs of "Key|Value" from the file.

readAllConfig

public static HashMap<String,String> readAllConfig(String app_dir,
                                                   String root)
Basically work in the same way as "readMaps()" function except that this aware the common configuration of the given application directory. For example, readAllConfig('Person', 'C:/SKAF/Searching'), assuming that the SKAF data folder is under C:/, will first read the common configuration file called 'C:/SKAF/Searching/common.cfg' and then read the local settings of 'Person', stored in 'C:/SKAF/Searching/Setting/settings.cfg'. Note: Directory name is same as the class name in ontology (Intended for internal use).

Parameters:
app_dir - Application directory name which represents a class name in ontology.
root - Path that 'common.cfg' is located.
Returns:
Map containing all pairs of "Key|Value" from the appropriate files.

containsElement

public static boolean containsElement(ArrayList<String> inputCollection,
                                      String elementToTest)
Check whether the given collection contains certain element or not.

Parameters:
inputCollection - Collection from which function will find the element.
elementToTest - Element to be searched.
Returns:
true (the collection contains given element) or false (the collection does not contain given element).

customTokenize

public static ArrayList<String> customTokenize(String inputString,
                                               String delimiter)
Extend the function of standard Java class 'Tokenizer' in the way that it returns the tokens in a collection.

Parameters:
inputString - String to be tokenized.
delimiter - Character(s) to be used as a separator.
Returns:
Collection which contains the tokens as its elements.

removeDuplicate

public static ArrayList<String> removeDuplicate(ArrayList<String> inputCollection)
Look for the duplicate elements in the given collection and remove them so that only unique elements are stored.

Parameters:
inputCollection - Collection of elements, that may or may not contains duplicate elements.
Returns:
Collection of elements without duplication.

removeHozoProprietaryResources

public static ArrayList<String> removeHozoProprietaryResources(ArrayList<String> inputCollection)
Remove all the proprietary (non-standard) resources provided by HOZO Ontology Editor. For example, 'RelationalConcept', 'hasAttribute', 'hasPart', etc.

Parameters:
inputCollection - Collection of resources containing HOZO-generated resources.
Returns:
Collection of elements without HOZO-generated resources.

deleteDirectoryOrFile

public static void deleteDirectoryOrFile(File path)
Delete the directory of given path including the files inside the directory.

Parameters:
path - Directory path on the system.

getAllHozoSpecificDatatypes

public static ArrayList<String> getAllHozoSpecificDatatypes(String NS)
Get the list of terminologies (resource names) that are specific to HOZO ontology editor.

Parameters:
NS - Namespace for the ontology of interest.
Returns:
Collection of HOZO-specific datatypes.

isNumberConvertibleString

public static boolean isNumberConvertibleString(String inputString)
Check whether the given string is possible to convert number format.

Parameters:
inputString - Input String.
Returns:
true (It is convertible) or false (It is not convertible).

printInfo

public static String printInfo(String inputString)
Print the input string if 'Common.SHOW_INFO' is true.

Parameters:
inputString - Input string.
Returns:
Formatted string.