Class CPMUtils
- java.lang.Object
-
- org.apache.uima.collection.impl.cpm.utils.CPMUtils
-
public class CPMUtils extends java.lang.ObjectThe Class CPMUtils.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCPM_LOG_RESOURCE_BUNDLEThe Constant CPM_LOG_RESOURCE_BUNDLE.private static UimaTimertimerThe timer.
-
Constructor Summary
Constructors Constructor Description CPMUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringconvertToAbsolutePath(java.lang.String aSystemVar, java.lang.String aExpr, java.lang.String aPathToConvert)Convert to absolute path.static voiddumpEvents(ProcessTrace aPTr)Dumps all events in the process trace object.private static java.lang.StringextractText(org.w3c.dom.Node aNode)Finds a node with a given path and returns its textual value.static longextractTime(ProcessTrace aPT, java.lang.String eventName)Returns the total duration of a given event.static java.io.FilefindDeployDirectory(java.lang.String aServiceName)Find deploy directory.static ChunkMetadatagetChunkMetadata(CAS aCas)Extract metadata associated with chunk from a given CAS.private static ConfigurableFeaturegetConfigurableFeature(org.w3c.dom.Node entityNode)Gets the configurable feature.private static java.io.File[]getDirectories()Gets the directories.static intgetFeatureAsInt(CAS aCas, Feature aFeature, java.lang.String aName)Gets the feature as int.static java.lang.StringgetFeatureAsString(CAS aCas, Feature aFeature, java.lang.String aName)Returns a value associated with a given feature.private static java.util.ArrayListgetFeatures(org.w3c.dom.Node attributesNode)Gets the features.static java.lang.String[]getKeys2Drop(java.lang.String aKeyDropMapFile)Currently, this returns initialized array of Strings.private static java.lang.StringgetTextValue(org.w3c.dom.NodeList aList)Returns text associated with TEXT_NODE element.static UimaTimergetTimer()Gets the timer.static UimaTimergetTimer(java.lang.String aTimerClass)Return timer to measure performace of the cpm.static java.lang.StringscrubThePath(java.lang.String value)Finds an occurance of the ##CPM_HOME in a value parameter and returns it with an expanded form (ie.c:/cpm/...) based on the env variable CPM_HOME.static voidsetTimer(UimaTimer aTimer)Sets the timer.
-
-
-
Field Detail
-
CPM_LOG_RESOURCE_BUNDLE
public static final java.lang.String CPM_LOG_RESOURCE_BUNDLE
The Constant CPM_LOG_RESOURCE_BUNDLE.- See Also:
- Constant Field Values
-
timer
private static UimaTimer timer
The timer.
-
-
Method Detail
-
getKeys2Drop
public static java.lang.String[] getKeys2Drop(java.lang.String aKeyDropMapFile) throws ResourceConfigurationExceptionCurrently, this returns initialized array of Strings.- Parameters:
aKeyDropMapFile- - a file containing a list of features that should be removed from CAS being sent to Cas Processor. Currently not used.- Returns:
- - Array of empty Strings
- Throws:
ResourceConfigurationException- -
-
setTimer
public static void setTimer(UimaTimer aTimer)
Sets the timer.- Parameters:
aTimer- the new timer
-
getTimer
public static UimaTimer getTimer()
Gets the timer.- Returns:
- the timer
-
convertToAbsolutePath
public static java.lang.String convertToAbsolutePath(java.lang.String aSystemVar, java.lang.String aExpr, java.lang.String aPathToConvert)Convert to absolute path.- Parameters:
aSystemVar- the a system varaExpr- the a expraPathToConvert- the a path to convert- Returns:
- absolute path
-
getTimer
public static UimaTimer getTimer(java.lang.String aTimerClass) throws java.lang.Exception
Return timer to measure performace of the cpm. The timer can optionally be configured in the CPE descriptor. If none defined, the method returns default timer.- Parameters:
aTimerClass- the a timer class- Returns:
- - customer timer or JavaTimer (default)
- Throws:
java.lang.Exception- -
-
extractTime
public static long extractTime(ProcessTrace aPT, java.lang.String eventName)
Returns the total duration of a given event.- Parameters:
aPT- - Event containereventName- - name of the event for which the time is needed- Returns:
- - total duration of an event
-
dumpEvents
public static void dumpEvents(ProcessTrace aPTr)
Dumps all events in the process trace object.- Parameters:
aPTr- - event container
-
scrubThePath
public static java.lang.String scrubThePath(java.lang.String value)
Finds an occurance of the ##CPM_HOME in a value parameter and returns it with an expanded form (ie.c:/cpm/...) based on the env variable CPM_HOME.- Parameters:
value- the value- Returns:
- the string
-
extractText
private static java.lang.String extractText(org.w3c.dom.Node aNode) throws java.lang.ExceptionFinds a node with a given path and returns its textual value.- Parameters:
aNode- the a node- Returns:
- textual value of a node indicated in the XPath path
- Throws:
java.lang.Exception- the exception
-
getConfigurableFeature
private static ConfigurableFeature getConfigurableFeature(org.w3c.dom.Node entityNode) throws javax.naming.ConfigurationException
Gets the configurable feature.- Parameters:
entityNode- the entity node- Returns:
- a configurable feature
- Throws:
javax.naming.ConfigurationException- -
-
getTextValue
private static java.lang.String getTextValue(org.w3c.dom.NodeList aList)
Returns text associated with TEXT_NODE element.- Parameters:
aList- - list of elements- Returns:
- - Text
-
getFeatures
private static java.util.ArrayList getFeatures(org.w3c.dom.Node attributesNode) throws javax.naming.ConfigurationExceptionGets the features.- Parameters:
attributesNode- the attributes node- Returns:
- a list of features
- Throws:
javax.naming.ConfigurationException- -
-
findDeployDirectory
public static java.io.File findDeployDirectory(java.lang.String aServiceName) throws java.lang.ExceptionFind deploy directory.- Parameters:
aServiceName- the a service name- Returns:
- the deploy directory
- Throws:
java.lang.Exception- -
-
getDirectories
private static java.io.File[] getDirectories() throws java.lang.ExceptionGets the directories.- Returns:
- an array of directories
- Throws:
java.lang.Exception- -
-
getFeatureAsInt
public static int getFeatureAsInt(CAS aCas, Feature aFeature, java.lang.String aName) throws java.lang.Exception
Gets the feature as int.- Parameters:
aCas- the a casaFeature- the a featureaName- the a name- Returns:
- the feature as int
- Throws:
java.lang.Exception- the exception
-
getFeatureAsString
public static java.lang.String getFeatureAsString(CAS aCas, Feature aFeature, java.lang.String aName) throws java.lang.Exception
Returns a value associated with a given feature.- Parameters:
aCas- - Cas containing data to extractaFeature- - feature to locate in the CASaName- - name of the feature- Returns:
- - value as String
- Throws:
java.lang.Exception- the exception
-
getChunkMetadata
public static ChunkMetadata getChunkMetadata(CAS aCas)
Extract metadata associated with chunk from a given CAS.- Parameters:
aCas- - Cas to extract chunk metadata from- Returns:
- - chunk metadata
-
-