Package org.apache.uima.tools.jcasgen
Class Jg
java.lang.Object
org.apache.uima.tools.jcasgen.Jg
Class holds type plugin-wide collections and static methods. Also implements the runnable that is
called to do the processing
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The Class ErrorExit.static interface
Interface implemented by JCAS code generation's templates. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe imports.The built in types.(package private) static TypeSystem
The built in type system.(package private) CAS
The cas.static final Properties
The Constant casCreateProperties.private Type
The cas string type.(package private) String
The class path.(package private) static final FeatureDescription[]
The Constant emptyFds.The error.(package private) static final Map
<String, FeatureDescription[]> The Constant extendableBuiltInTypes.(package private) static final FeatureDescription[]
The Constant featureDescriptionArray0.(package private) GUI
The gui.The imports.private static final boolean
(package private) static final String
The Constant jControlModel.private boolean
The limit J cas gen to project scope.The merged types adding features.(package private) IMerge
The merger.Set of types not generated from the CAS type set because they're already in existence as builtins in the JCas impl.The non importable java names.(package private) String
The package name.(package private) IProgressMonitor
The progress monitor.private String
The project path dir.(package private) static final Collection
<String> The Constant reservedFeatureNames.private static ResourceBundle
The resource bundle.(package private) String
The simple class name.private Type
The tcas annotation type.private TypeSystem
The type system.(package private) Waiter
The waiter.(package private) String
The xml source file name. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
addBuiltInTypeInfo
(String casName, String javaName) Adds the built in type info.private static void
addBuiltInTypeInfo
(String casName, String javaName, String casElementName) Adds the built in type info.(package private) String
Array core.(package private) String
arrayLLCore
(String get_set, String range, String fname) Array LL core.(package private) String
arrayLLCoreChk
(String get_set, String range, String fname) Array LL core chk.(package private) String
castResult
(String resultType, String core) Cast result.(package private) void
collectImport
(String casName, boolean _Type) Collect import.(package private) Collection
<String> collectImports
(TypeDescription td, boolean _Type) Collect imports.Creates the resource manager.void
driveGui()
Drive gui.private void
generateAllTypesFromTemplates
(String outputDirectory, TypeDescription[] tds, CASImpl aCas, Class<JCasTypeTemplate> jcasTypeClass) Generate all types from templates.private void
generateClass
(IProgressMonitor progressMonitorGenerateClass, String outputDirectory, TypeDescription td, String sourceContents, String className, IMerge mergerGenerateClass) Generate class.private void
generateClassesFromTemplate
(TypeDescription td, String outputDirectory, Jg.IJCasTypeTemplate jcasTypeInstance) Generate type classes from the specified templates.(package private) String
Gets the array feature value.private String
getCheckSuffix
(String get_set, String range) Gets the check suffix.(package private) String
getDate()
Gets the date.(package private) String
Gets the feature value.(package private) String
Gets the gets the set array name part.(package private) String
Gets the gets the set name part.(package private) String
getJavaName
(String name) Gets the java name.(package private) String
Gets the java name.(package private) String
Gets the java name type.(package private) String
getJavaNameWithPkg
(String casTypeName) Gets the java name with pkg.(package private) String
Gets the java pkg.(package private) String
Gets the java range array element type.(package private) String
Gets the java range array element type, with generic type or ? in invalid input: '<'> as needed(package private) String
Gets the java range type.(package private) String
Gets the java range type, with generic types in invalid input: '<'> as required.(package private) String
Gets the pkg.(package private) String
Gets the pkg.Returns the plugin's resource bundle,.getResourceString
(String key) Returns the string from the plugin's resource bundle, or 'key' if not found.Gets the string.(package private) boolean
Checks for array range.(package private) boolean
hasPkgPrefix
(String name) Checks for pkg prefix.(package private) boolean
private boolean
isOutOfScope
(TypeDescription td, String projectDirPath) return true if td is not defined in this project, or it is defined, but is also in merged and any of the other merged urls are not defined in this project.(package private) boolean
Checks if is possible index key.(package private) boolean
private boolean
Checks if is same feature description.(package private) boolean
Checks if is string subtype.(package private) boolean
Checks if is sub type of annotation.static void
The main method.int
main0
(String[] args, IMerge aMerger, IProgressMonitor aProgressMonitor, IError aError) Main 0.int
Arguments are: -jcasgeninput xxxx -jcasgenoutput xxxx -jcasgenclasspath xxxxvoid
mainForCde
(IMerge aMerger, IProgressMonitor aProgressMonitor, IError aError, String inputFile, String outputDirectory, TypeDescription[] tds, CASImpl aCas) Main for cde.void
mainForCde
(IMerge aMerger, IProgressMonitor aProgressMonitor, IError aError, String inputFile, String outputDirectory, TypeDescription[] tds, CASImpl aCas, String pProjectPathDir, boolean limitToProjectScope, Map<String, Set<String>> pMergedTypesAddingFeatures) Main for cde.void
mainGenerateAllTypesFromTemplates
(IMerge aMerger, IProgressMonitor aProgressMonitor, IError aError, String inputFile, String outputDirectory, TypeDescription[] tds, CASImpl aCas, Class<JCasTypeTemplate> jcasTypeClass, Class<JCasTypeTemplate> jcas_TypeClass) Main generate all types from templates.void
mainGenerateAllTypesFromTemplates
(IMerge aMerger, IProgressMonitor aProgressMonitor, IError aError, String inputFile, String outputDirectory, TypeDescription[] tds, CASImpl aCas, Class<JCasTypeTemplate> jcasTypeClass, String pProjectPathDir, boolean limitToProjectScope, Map<String, Set<String>> pMergedTypesAddingFeatures) Main generate all types from templates.private String
makeMergeMessage
(Map<String, Set<String>> m) Make merge message.private TypeSystemDescription
Merge type system imports.(package private) String
Null blank.static String
Removes the pkg.(package private) String
Sc.(package private) String
Sets the array feature value.(package private) List
<FeatureDescription> setDifference
(FeatureDescription[] newFeatures, FeatureDescription[] alreadyDefinedFeatures) Sets the difference.(package private) String
Sets the feature value.(package private) String
simpleCore
(String get_set, String range, String fname) Simple core.(package private) String
simpleLLCore
(String get_set, String range, String fname) Simple LL core.(package private) String
Uc 1.(package private) String
wrapToGetFS
(String core, String range) Wrap to get FS.
-
Field Details
-
IS_TRACE_LIMITED
private static final boolean IS_TRACE_LIMITED- See Also:
-
jControlModel
The Constant jControlModel.- See Also:
-
featureDescriptionArray0
The Constant featureDescriptionArray0. -
reservedFeatureNames
The Constant reservedFeatureNames. -
noGenTypes
Set of types not generated from the CAS type set because they're already in existence as builtins in the JCas impl. and if they're generated, the generated forms are wrong. -
casCreateProperties
The Constant casCreateProperties. -
extendableBuiltInTypes
The Constant extendableBuiltInTypes. -
emptyFds
The Constant emptyFds. -
builtInTypeSystem
The built in type system. -
builtInTypes
The built in types. -
genericFeatureDescriptorTypes
-
resourceBundle
The resource bundle. -
imports
The imports. -
_imports
The imports. -
classPath
String classPathThe class path. -
xmlSourceFileName
String xmlSourceFileNameThe xml source file name. -
cas
CAS casThe cas. -
gui
GUI guiThe gui. -
merger
IMerge mergerThe merger. -
progressMonitor
IProgressMonitor progressMonitorThe progress monitor. -
error
The error. -
waiter
Waiter waiterThe waiter. -
packageName
String packageNameThe package name. -
simpleClassName
String simpleClassNameThe simple class name. -
typeSystem
The type system. -
casStringType
The cas string type. -
tcasAnnotationType
The tcas annotation type. -
mergedTypesAddingFeatures
The merged types adding features. -
projectPathDir
The project path dir. -
limitJCasGenToProjectScope
private boolean limitJCasGenToProjectScopeThe limit J cas gen to project scope. -
nonImportableJavaNames
The non importable java names.
-
-
Constructor Details
-
Jg
public Jg()Instantiates a new jg.
-
-
Method Details
-
addBuiltInTypeInfo
Adds the built in type info.- Parameters:
casName
- the cas namejavaName
- the java namecasElementName
- the cas element name
-
addBuiltInTypeInfo
Adds the built in type info.- Parameters:
casName
- the cas namejavaName
- the java name
-
getResourceString
Returns the string from the plugin's resource bundle, or 'key' if not found.- Parameters:
key
- the key- Returns:
- the resource string
-
getString
Gets the string.- Parameters:
key
- the keysubstitutions
- the substitutions- Returns:
- the string
-
getResourceBundle
Returns the plugin's resource bundle,.- Returns:
- the resource bundle
-
driveGui
public void driveGui()Drive gui. -
main
The main method.- Parameters:
args
- the arguments
-
mainForCde
public void mainForCde(IMerge aMerger, IProgressMonitor aProgressMonitor, IError aError, String inputFile, String outputDirectory, TypeDescription[] tds, CASImpl aCas) throws IOException Main for cde.- Parameters:
aMerger
- the a mergeraProgressMonitor
- the a progress monitoraError
- the a errorinputFile
- the input fileoutputDirectory
- the output directorytds
- the tdsaCas
- the a cas- Throws:
IOException
- Signals that an I/O exception has occurred.
-
mainForCde
public void mainForCde(IMerge aMerger, IProgressMonitor aProgressMonitor, IError aError, String inputFile, String outputDirectory, TypeDescription[] tds, CASImpl aCas, String pProjectPathDir, boolean limitToProjectScope, Map<String, Set<String>> pMergedTypesAddingFeatures) throws IOExceptionMain for cde.- Parameters:
aMerger
- the a mergeraProgressMonitor
- the a progress monitoraError
- the a errorinputFile
- the input fileoutputDirectory
- the output directorytds
- the tdsaCas
- the a caspProjectPathDir
- the project path dirlimitToProjectScope
- the limit J cas gen to project scopepMergedTypesAddingFeatures
- the merged types adding features- Throws:
IOException
- Signals that an I/O exception has occurred.
-
mainGenerateAllTypesFromTemplates
public void mainGenerateAllTypesFromTemplates(IMerge aMerger, IProgressMonitor aProgressMonitor, IError aError, String inputFile, String outputDirectory, TypeDescription[] tds, CASImpl aCas, Class<JCasTypeTemplate> jcasTypeClass, Class<JCasTypeTemplate> jcas_TypeClass) throws IOException, InstantiationException, IllegalAccessException Main generate all types from templates.- Parameters:
aMerger
- the a mergeraProgressMonitor
- the a progress monitoraError
- the a errorinputFile
- the input fileoutputDirectory
- the output directorytds
- the tdsaCas
- the a casjcasTypeClass
- the jcas type classjcas_TypeClass
- the jcas type class- Throws:
IOException
- Signals that an I/O exception has occurred.InstantiationException
- the instantiation exceptionIllegalAccessException
- the illegal access exception
-
mainGenerateAllTypesFromTemplates
public void mainGenerateAllTypesFromTemplates(IMerge aMerger, IProgressMonitor aProgressMonitor, IError aError, String inputFile, String outputDirectory, TypeDescription[] tds, CASImpl aCas, Class<JCasTypeTemplate> jcasTypeClass, String pProjectPathDir, boolean limitToProjectScope, Map<String, Set<String>> pMergedTypesAddingFeatures) throws IOException, InstantiationException, IllegalAccessExceptionMain generate all types from templates.- Parameters:
aMerger
- the a mergeraProgressMonitor
- the a progress monitoraError
- the a errorinputFile
- the input fileoutputDirectory
- the output directorytds
- the tdsaCas
- the a casjcasTypeClass
- the jcas type classpProjectPathDir
- the project path dirlimitToProjectScope
- the limit J cas gen to project scopepMergedTypesAddingFeatures
- the merged types adding features- Throws:
IOException
- Signals that an I/O exception has occurred.InstantiationException
- the instantiation exceptionIllegalAccessException
- the illegal access exception
-
main0
Main 0.- Parameters:
args
- the argsaMerger
- the a mergeraProgressMonitor
- the a progress monitoraError
- the a error- Returns:
- the int
-
main1
Arguments are: -jcasgeninput xxxx -jcasgenoutput xxxx -jcasgenclasspath xxxx- Parameters:
arguments
- the arguments- Returns:
- the int
-
makeMergeMessage
Make merge message.- Parameters:
m
- the m- Returns:
- the string
-
generateAllTypesFromTemplates
private void generateAllTypesFromTemplates(String outputDirectory, TypeDescription[] tds, CASImpl aCas, Class<JCasTypeTemplate> jcasTypeClass) throws IOException, InstantiationException, IllegalAccessException Generate all types from templates.- Parameters:
outputDirectory
- the output directorytds
- the tdsaCas
- the a casjcasTypeClass
- the jcas type class- Throws:
IOException
- Signals that an I/O exception has occurred.InstantiationException
- the instantiation exceptionIllegalAccessException
- the illegal access exception
-
isOutOfScope
return true if td is not defined in this project, or it is defined, but is also in merged and any of the other merged urls are not defined in this project.- Parameters:
td
- the tdprojectDirPath
- the project dir path- Returns:
- true, if is out of scope
-
generateClassesFromTemplate
private void generateClassesFromTemplate(TypeDescription td, String outputDirectory, Jg.IJCasTypeTemplate jcasTypeInstance) throws IOException Generate type classes from the specified templates.- Parameters:
td
- TypeDescription objectoutputDirectory
- output directoryjcasTypeInstance
- Template instance used to generate class- Throws:
IOException
- -
-
getPkg
Gets the pkg.- Parameters:
td
- the td- Returns:
- the pkg
-
getPkg
Gets the pkg.- Parameters:
nameWithPkg
- the name with pkg- Returns:
- the pkg
-
generateClass
private void generateClass(IProgressMonitor progressMonitorGenerateClass, String outputDirectory, TypeDescription td, String sourceContents, String className, IMerge mergerGenerateClass) throws IOException Generate class.- Parameters:
progressMonitorGenerateClass
- the progress monitor generate classoutputDirectory
- the output directorytd
- the tdsourceContents
- the source contentsclassName
- the class namemergerGenerateClass
- the merger generate class- Throws:
IOException
- Signals that an I/O exception has occurred.
-
removePkg
Removes the pkg.- Parameters:
name
- the name- Returns:
- the string
-
sc
Sc.- Parameters:
v
- the v- Returns:
- the string
-
getJavaPkg
Gets the java pkg.- Parameters:
td
- the td- Returns:
- the java pkg
-
getJavaNameWithPkg
Gets the java name with pkg.- Parameters:
casTypeName
- the cas type name- Returns:
- the java name with pkg
-
hasPkgPrefix
Checks for pkg prefix.- Parameters:
name
- the name- Returns:
- true, if successful
-
getJavaName
Gets the java name.- Parameters:
td
- the td- Returns:
- the java name
-
getJavaName_Type
Gets the java name type.- Parameters:
td
- the td- Returns:
- the java name type
-
getJavaName
Gets the java name.- Parameters:
name
- the name- Returns:
- the java name
-
collectImport
Collect import.- Parameters:
casName
- the cas name_Type
- the type
-
collectImports
Collect imports.- Parameters:
td
- the td_Type
- the type- Returns:
- the collection
-
getJavaRangeType
Gets the java range type.- Parameters:
fd
- the fd- Returns:
- the java range type
-
getJavaRangeType2
Gets the java range type, with generic types in invalid input: '<'> as required.- Parameters:
fd
- the fd- Returns:
- the java range type
-
isSubTypeOfAnnotation
Checks if is sub type of annotation.- Parameters:
td
- the td- Returns:
- true, if is sub type of annotation
-
hasArrayRange
Checks for array range.- Parameters:
fd
- the fd- Returns:
- true, if successful
-
isPossibleIndexKey
Checks if is possible index key.- Parameters:
fd
- the fd- Returns:
- true, if is possible index key
-
isStringSubtype
Checks if is string subtype.- Parameters:
fd
- the fd- Returns:
- true, if is string subtype
-
getJavaRangeArrayElementType
Gets the java range array element type.- Parameters:
fd
- the fd- Returns:
- the java range array element type
-
getJavaRangeArrayElementType2
Gets the java range array element type, with generic type or ? in invalid input: '<'> as needed- Parameters:
fd
- the fd- Returns:
- the java range array element type
-
uc1
Uc 1.- Parameters:
name
- the name- Returns:
- the string
-
getDate
String getDate()Gets the date.- Returns:
- the date
-
castResult
Cast result.- Parameters:
resultType
- the result typecore
- the core- Returns:
- the string
-
wrapToGetFS
Wrap to get FS.- Parameters:
core
- string representing the get or set coderange
- Boolean, Byte, Short, Int, Long, Float, Double, String, or Feature- Returns:
- -
-
simpleCore
Simple core.- Parameters:
get_set
- get or setrange
- Boolean, Byte, Short, Int, Long, Float, Double, String, or Featurefname
- feature name (e.g. "begin"- Returns:
- the string
-
simpleLLCore
Simple LL core.- Parameters:
get_set
- the get setrange
- the rangefname
- the fname- Returns:
- the string
-
arrayCore
Array core.- Parameters:
get_set
- get or setrange
- the component range: Boolean, Byte, Short, Int, Long, Float, Double, String, FeaturearrayRange
- the array rangefname
- the fname- Returns:
- the string
-
arrayLLCore
Array LL core.- Parameters:
get_set
- the get setrange
- the rangefname
- the fname- Returns:
- the string
-
arrayLLCoreChk
Array LL core chk.- Parameters:
get_set
- the get setrange
- the rangefname
- the fname- Returns:
- the string
-
getFeatureValue
Gets the feature value.- Parameters:
fd
- the fdtd
- the td- Returns:
- the feature value
-
setFeatureValue
Sets the feature value.- Parameters:
fd
- the fdtd
- the td- Returns:
- the string
-
getArrayFeatureValue
Gets the array feature value.- Parameters:
fd
- the fdtd
- the td- Returns:
- the array feature value
-
setArrayFeatureValue
Sets the array feature value.- Parameters:
fd
- the fdtd
- the td- Returns:
- the string
-
getGetSetNamePart
Gets the gets the set name part.- Parameters:
fd
- the fd- Returns:
- the gets the set name part
-
getGetSetArrayNamePart
Gets the gets the set array name part.- Parameters:
fd
- the fd- Returns:
- the gets the set array name part
-
nullBlank
Null blank.- Parameters:
s
- the s- Returns:
- the string
-
createResourceManager
Creates the resource manager.- Returns:
- the resource manager
-
mergeTypeSystemImports
private TypeSystemDescription mergeTypeSystemImports(TypeSystemDescription tsd) throws ResourceInitializationException Merge type system imports.- Parameters:
tsd
- the tsd- Returns:
- the type system description
- Throws:
ResourceInitializationException
- the resource initialization exception
-
setDifference
List<FeatureDescription> setDifference(FeatureDescription[] newFeatures, FeatureDescription[] alreadyDefinedFeatures) Sets the difference.- Parameters:
newFeatures
- the new featuresalreadyDefinedFeatures
- the already defined features- Returns:
- the list
-
isSameFeatureDescription
Checks if is same feature description.- Parameters:
f1
- the f 1f2
- the f 2- Returns:
- true, if is same feature description
-
getCheckSuffix
Gets the check suffix.- Parameters:
get_set
- the get setrange
- the range- Returns:
- the check suffix
-
isRangeTypeGeneric
-
isElementTypeGeneric
-