Class Jg


  • public class Jg
    extends java.lang.Object
    Class holds type plugin-wide collections and static methods. Also implements the runnable that is called to do the processing
    • Field Detail

      • jControlModel

        static final java.lang.String jControlModel
        The Constant jControlModel.
        See Also:
        Constant Field Values
      • featureDescriptionArray0

        static final FeatureDescription[] featureDescriptionArray0
        The Constant featureDescriptionArray0.
      • reservedFeatureNames

        static final java.util.Collection<java.lang.String> reservedFeatureNames
        The Constant reservedFeatureNames.
      • noGenTypes

        static final java.util.Set<java.lang.String> 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

        public static final java.util.Properties casCreateProperties
        The Constant casCreateProperties.
      • extendableBuiltInTypes

        static final java.util.Map<java.lang.String,​FeatureDescription[]> extendableBuiltInTypes
        The Constant extendableBuiltInTypes.
      • builtInTypeSystem

        static TypeSystem builtInTypeSystem
        The built in type system.
      • builtInTypes

        static java.util.Map<java.lang.String,​TypeInfo> builtInTypes
        The built in types.
      • genericFeatureDescriptorTypes

        private static java.util.List<java.lang.String> genericFeatureDescriptorTypes
      • resourceBundle

        private static java.util.ResourceBundle resourceBundle
        The resource bundle.
      • imports

        final java.util.Map<java.lang.String,​java.lang.String> imports
        The imports.
      • _imports

        final java.util.Map<java.lang.String,​java.lang.String> _imports
        The imports.
      • classPath

        java.lang.String classPath
        The class path.
      • xmlSourceFileName

        java.lang.String xmlSourceFileName
        The xml source file name.
      • cas

        CAS cas
        The cas.
      • gui

        GUI gui
        The gui.
      • merger

        IMerge merger
        The merger.
      • error

        public IError error
        The error.
      • waiter

        Waiter waiter
        The waiter.
      • packageName

        java.lang.String packageName
        The package name.
      • simpleClassName

        java.lang.String simpleClassName
        The simple class name.
      • typeSystem

        private TypeSystem typeSystem
        The type system.
      • casStringType

        private Type casStringType
        The cas string type.
      • tcasAnnotationType

        private Type tcasAnnotationType
        The tcas annotation type.
      • mergedTypesAddingFeatures

        private java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> mergedTypesAddingFeatures
        The merged types adding features.
      • projectPathDir

        private java.lang.String projectPathDir
        The project path dir.
      • limitJCasGenToProjectScope

        private boolean limitJCasGenToProjectScope
        The limit J cas gen to project scope.
      • nonImportableJavaNames

        private static java.util.ArrayList<java.lang.String> nonImportableJavaNames
        The non importable java names.
    • Constructor Detail

      • Jg

        public Jg()
        Instantiates a new jg.
    • Method Detail

      • addBuiltInTypeInfo

        private static void addBuiltInTypeInfo​(java.lang.String casName,
                                               java.lang.String javaName,
                                               java.lang.String casElementName)
        Adds the built in type info.
        Parameters:
        casName - the cas name
        javaName - the java name
        casElementName - the cas element name
      • addBuiltInTypeInfo

        private static void addBuiltInTypeInfo​(java.lang.String casName,
                                               java.lang.String javaName)
        Adds the built in type info.
        Parameters:
        casName - the cas name
        javaName - the java name
      • getResourceString

        public java.lang.String getResourceString​(java.lang.String key)
        Returns the string from the plugin's resource bundle, or 'key' if not found.
        Parameters:
        key - the key
        Returns:
        the resource string
      • getString

        public java.lang.String getString​(java.lang.String key,
                                          java.lang.Object[] substitutions)
        Gets the string.
        Parameters:
        key - the key
        substitutions - the substitutions
        Returns:
        the string
      • getResourceBundle

        public java.util.ResourceBundle getResourceBundle()
        Returns the plugin's resource bundle,.
        Returns:
        the resource bundle
      • driveGui

        public void driveGui()
        Drive gui.
      • main

        public static void main​(java.lang.String[] args)
        The main method.
        Parameters:
        args - the arguments
      • mainForCde

        public void mainForCde​(IMerge aMerger,
                               IProgressMonitor aProgressMonitor,
                               IError aError,
                               java.lang.String inputFile,
                               java.lang.String outputDirectory,
                               TypeDescription[] tds,
                               CASImpl aCas)
                        throws java.io.IOException
        Main for cde.
        Parameters:
        aMerger - the a merger
        aProgressMonitor - the a progress monitor
        aError - the a error
        inputFile - the input file
        outputDirectory - the output directory
        tds - the tds
        aCas - the a cas
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • mainForCde

        public void mainForCde​(IMerge aMerger,
                               IProgressMonitor aProgressMonitor,
                               IError aError,
                               java.lang.String inputFile,
                               java.lang.String outputDirectory,
                               TypeDescription[] tds,
                               CASImpl aCas,
                               java.lang.String pProjectPathDir,
                               boolean limitToProjectScope,
                               java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> pMergedTypesAddingFeatures)
                        throws java.io.IOException
        Main for cde.
        Parameters:
        aMerger - the a merger
        aProgressMonitor - the a progress monitor
        aError - the a error
        inputFile - the input file
        outputDirectory - the output directory
        tds - the tds
        aCas - the a cas
        pProjectPathDir - the project path dir
        limitToProjectScope - the limit J cas gen to project scope
        pMergedTypesAddingFeatures - the merged types adding features
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • mainGenerateAllTypesFromTemplates

        public void mainGenerateAllTypesFromTemplates​(IMerge aMerger,
                                                      IProgressMonitor aProgressMonitor,
                                                      IError aError,
                                                      java.lang.String inputFile,
                                                      java.lang.String outputDirectory,
                                                      TypeDescription[] tds,
                                                      CASImpl aCas,
                                                      java.lang.Class<JCasTypeTemplate> jcasTypeClass,
                                                      java.lang.Class<JCasTypeTemplate> jcas_TypeClass)
                                               throws java.io.IOException,
                                                      java.lang.InstantiationException,
                                                      java.lang.IllegalAccessException
        Main generate all types from templates.
        Parameters:
        aMerger - the a merger
        aProgressMonitor - the a progress monitor
        aError - the a error
        inputFile - the input file
        outputDirectory - the output directory
        tds - the tds
        aCas - the a cas
        jcasTypeClass - the jcas type class
        jcas_TypeClass - the jcas type class
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
        java.lang.InstantiationException - the instantiation exception
        java.lang.IllegalAccessException - the illegal access exception
      • mainGenerateAllTypesFromTemplates

        public void mainGenerateAllTypesFromTemplates​(IMerge aMerger,
                                                      IProgressMonitor aProgressMonitor,
                                                      IError aError,
                                                      java.lang.String inputFile,
                                                      java.lang.String outputDirectory,
                                                      TypeDescription[] tds,
                                                      CASImpl aCas,
                                                      java.lang.Class<JCasTypeTemplate> jcasTypeClass,
                                                      java.lang.String pProjectPathDir,
                                                      boolean limitToProjectScope,
                                                      java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> pMergedTypesAddingFeatures)
                                               throws java.io.IOException,
                                                      java.lang.InstantiationException,
                                                      java.lang.IllegalAccessException
        Main generate all types from templates.
        Parameters:
        aMerger - the a merger
        aProgressMonitor - the a progress monitor
        aError - the a error
        inputFile - the input file
        outputDirectory - the output directory
        tds - the tds
        aCas - the a cas
        jcasTypeClass - the jcas type class
        pProjectPathDir - the project path dir
        limitToProjectScope - the limit J cas gen to project scope
        pMergedTypesAddingFeatures - the merged types adding features
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
        java.lang.InstantiationException - the instantiation exception
        java.lang.IllegalAccessException - the illegal access exception
      • main0

        public int main0​(java.lang.String[] args,
                         IMerge aMerger,
                         IProgressMonitor aProgressMonitor,
                         IError aError)
        Main 0.
        Parameters:
        args - the args
        aMerger - the a merger
        aProgressMonitor - the a progress monitor
        aError - the a error
        Returns:
        the int
      • main1

        public int main1​(java.lang.String[] arguments)
        Arguments are: -jcasgeninput xxxx -jcasgenoutput xxxx -jcasgenclasspath xxxx
        Parameters:
        arguments - the arguments
        Returns:
        the int
      • makeMergeMessage

        private java.lang.String makeMergeMessage​(java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> m)
        Make merge message.
        Parameters:
        m - the m
        Returns:
        the string
      • generateAllTypesFromTemplates

        private void generateAllTypesFromTemplates​(java.lang.String outputDirectory,
                                                   TypeDescription[] tds,
                                                   CASImpl aCas,
                                                   java.lang.Class<JCasTypeTemplate> jcasTypeClass)
                                            throws java.io.IOException,
                                                   java.lang.InstantiationException,
                                                   java.lang.IllegalAccessException
        Generate all types from templates.
        Parameters:
        outputDirectory - the output directory
        tds - the tds
        aCas - the a cas
        jcasTypeClass - the jcas type class
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
        java.lang.InstantiationException - the instantiation exception
        java.lang.IllegalAccessException - the illegal access exception
      • isOutOfScope

        private boolean isOutOfScope​(TypeDescription td,
                                     java.lang.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.
        Parameters:
        td - the td
        projectDirPath - the project dir path
        Returns:
        true, if is out of scope
      • generateClassesFromTemplate

        private void generateClassesFromTemplate​(TypeDescription td,
                                                 java.lang.String outputDirectory,
                                                 Jg.IJCasTypeTemplate jcasTypeInstance)
                                          throws java.io.IOException
        Generate type classes from the specified templates.
        Parameters:
        td - TypeDescription object
        outputDirectory - output directory
        jcasTypeInstance - Template instance used to generate class
        Throws:
        java.io.IOException - -
      • getPkg

        java.lang.String getPkg​(TypeDescription td)
        Gets the pkg.
        Parameters:
        td - the td
        Returns:
        the pkg
      • getPkg

        java.lang.String getPkg​(java.lang.String nameWithPkg)
        Gets the pkg.
        Parameters:
        nameWithPkg - the name with pkg
        Returns:
        the pkg
      • generateClass

        private void generateClass​(IProgressMonitor progressMonitorGenerateClass,
                                   java.lang.String outputDirectory,
                                   TypeDescription td,
                                   java.lang.String sourceContents,
                                   java.lang.String className,
                                   IMerge mergerGenerateClass)
                            throws java.io.IOException
        Generate class.
        Parameters:
        progressMonitorGenerateClass - the progress monitor generate class
        outputDirectory - the output directory
        td - the td
        sourceContents - the source contents
        className - the class name
        mergerGenerateClass - the merger generate class
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • removePkg

        public static java.lang.String removePkg​(java.lang.String name)
        Removes the pkg.
        Parameters:
        name - the name
        Returns:
        the string
      • sc

        java.lang.String sc​(java.lang.String v)
        Sc.
        Parameters:
        v - the v
        Returns:
        the string
      • getJavaPkg

        java.lang.String getJavaPkg​(TypeDescription td)
        Gets the java pkg.
        Parameters:
        td - the td
        Returns:
        the java pkg
      • getJavaNameWithPkg

        java.lang.String getJavaNameWithPkg​(java.lang.String casTypeName)
        Gets the java name with pkg.
        Parameters:
        casTypeName - the cas type name
        Returns:
        the java name with pkg
      • hasPkgPrefix

        boolean hasPkgPrefix​(java.lang.String name)
        Checks for pkg prefix.
        Parameters:
        name - the name
        Returns:
        true, if successful
      • getJavaName

        java.lang.String getJavaName​(TypeDescription td)
        Gets the java name.
        Parameters:
        td - the td
        Returns:
        the java name
      • getJavaName_Type

        java.lang.String getJavaName_Type​(TypeDescription td)
        Gets the java name type.
        Parameters:
        td - the td
        Returns:
        the java name type
      • getJavaName

        java.lang.String getJavaName​(java.lang.String name)
        Gets the java name.
        Parameters:
        name - the name
        Returns:
        the java name
      • collectImport

        void collectImport​(java.lang.String casName,
                           boolean _Type)
        Collect import.
        Parameters:
        casName - the cas name
        _Type - the type
      • collectImports

        java.util.Collection<java.lang.String> collectImports​(TypeDescription td,
                                                              boolean _Type)
        Collect imports.
        Parameters:
        td - the td
        _Type - the type
        Returns:
        the collection
      • getJavaRangeType

        java.lang.String getJavaRangeType​(FeatureDescription fd)
        Gets the java range type.
        Parameters:
        fd - the fd
        Returns:
        the java range type
      • getJavaRangeType2

        java.lang.String getJavaRangeType2​(FeatureDescription fd)
        Gets the java range type, with generic types in <> as required.
        Parameters:
        fd - the fd
        Returns:
        the java range type
      • isSubTypeOfAnnotation

        boolean isSubTypeOfAnnotation​(TypeDescription td)
        Checks if is sub type of annotation.
        Parameters:
        td - the td
        Returns:
        true, if is sub type of annotation
      • hasArrayRange

        boolean hasArrayRange​(FeatureDescription fd)
        Checks for array range.
        Parameters:
        fd - the fd
        Returns:
        true, if successful
      • isPossibleIndexKey

        boolean isPossibleIndexKey​(FeatureDescription fd)
        Checks if is possible index key.
        Parameters:
        fd - the fd
        Returns:
        true, if is possible index key
      • isStringSubtype

        boolean isStringSubtype​(FeatureDescription fd)
        Checks if is string subtype.
        Parameters:
        fd - the fd
        Returns:
        true, if is string subtype
      • getJavaRangeArrayElementType

        java.lang.String getJavaRangeArrayElementType​(FeatureDescription fd)
        Gets the java range array element type.
        Parameters:
        fd - the fd
        Returns:
        the java range array element type
      • getJavaRangeArrayElementType2

        java.lang.String getJavaRangeArrayElementType2​(FeatureDescription fd)
        Gets the java range array element type, with generic type or ? in <> as needed
        Parameters:
        fd - the fd
        Returns:
        the java range array element type
      • uc1

        java.lang.String uc1​(java.lang.String name)
        Uc 1.
        Parameters:
        name - the name
        Returns:
        the string
      • getDate

        java.lang.String getDate()
        Gets the date.
        Returns:
        the date
      • castResult

        java.lang.String castResult​(java.lang.String resultType,
                                    java.lang.String core)
        Cast result.
        Parameters:
        resultType - the result type
        core - the core
        Returns:
        the string
      • wrapToGetFS

        java.lang.String wrapToGetFS​(java.lang.String core,
                                     java.lang.String range)
        Wrap to get FS.
        Parameters:
        core - string representing the get or set code
        range - Boolean, Byte, Short, Int, Long, Float, Double, String, or Feature
        Returns:
        -
      • simpleCore

        java.lang.String simpleCore​(java.lang.String get_set,
                                    java.lang.String range,
                                    java.lang.String fname)
        Simple core.
        Parameters:
        get_set - get or set
        range - Boolean, Byte, Short, Int, Long, Float, Double, String, or Feature
        fname - feature name (e.g. "begin"
        Returns:
        the string
      • simpleLLCore

        java.lang.String simpleLLCore​(java.lang.String get_set,
                                      java.lang.String range,
                                      java.lang.String fname)
        Simple LL core.
        Parameters:
        get_set - the get set
        range - the range
        fname - the fname
        Returns:
        the string
      • arrayCore

        java.lang.String arrayCore​(java.lang.String get_set,
                                   java.lang.String range,
                                   java.lang.String arrayRange,
                                   java.lang.String fname)
        Array core.
        Parameters:
        get_set - get or set
        range - the component range: Boolean, Byte, Short, Int, Long, Float, Double, String, Feature
        arrayRange - the array range
        fname - the fname
        Returns:
        the string
      • arrayLLCore

        java.lang.String arrayLLCore​(java.lang.String get_set,
                                     java.lang.String range,
                                     java.lang.String fname)
        Array LL core.
        Parameters:
        get_set - the get set
        range - the range
        fname - the fname
        Returns:
        the string
      • arrayLLCoreChk

        java.lang.String arrayLLCoreChk​(java.lang.String get_set,
                                        java.lang.String range,
                                        java.lang.String fname)
        Array LL core chk.
        Parameters:
        get_set - the get set
        range - the range
        fname - the fname
        Returns:
        the string
      • getFeatureValue

        java.lang.String getFeatureValue​(FeatureDescription fd,
                                         TypeDescription td)
        Gets the feature value.
        Parameters:
        fd - the fd
        td - the td
        Returns:
        the feature value
      • setFeatureValue

        java.lang.String setFeatureValue​(FeatureDescription fd,
                                         TypeDescription td)
        Sets the feature value.
        Parameters:
        fd - the fd
        td - the td
        Returns:
        the string
      • getArrayFeatureValue

        java.lang.String getArrayFeatureValue​(FeatureDescription fd,
                                              TypeDescription td)
        Gets the array feature value.
        Parameters:
        fd - the fd
        td - the td
        Returns:
        the array feature value
      • setArrayFeatureValue

        java.lang.String setArrayFeatureValue​(FeatureDescription fd,
                                              TypeDescription td)
        Sets the array feature value.
        Parameters:
        fd - the fd
        td - the td
        Returns:
        the string
      • getGetSetNamePart

        java.lang.String getGetSetNamePart​(FeatureDescription fd)
        Gets the gets the set name part.
        Parameters:
        fd - the fd
        Returns:
        the gets the set name part
      • getGetSetArrayNamePart

        java.lang.String getGetSetArrayNamePart​(FeatureDescription fd)
        Gets the gets the set array name part.
        Parameters:
        fd - the fd
        Returns:
        the gets the set array name part
      • nullBlank

        java.lang.String nullBlank​(java.lang.String s)
        Null blank.
        Parameters:
        s - the s
        Returns:
        the string
      • createResourceManager

        public ResourceManager createResourceManager()
        Creates the resource manager.
        Returns:
        the resource manager
      • setDifference

        java.util.List<FeatureDescription> setDifference​(FeatureDescription[] newFeatures,
                                                         FeatureDescription[] alreadyDefinedFeatures)
        Sets the difference.
        Parameters:
        newFeatures - the new features
        alreadyDefinedFeatures - the already defined features
        Returns:
        the list
      • isSameFeatureDescription

        private boolean isSameFeatureDescription​(FeatureDescription f1,
                                                 FeatureDescription f2)
        Checks if is same feature description.
        Parameters:
        f1 - the f 1
        f2 - the f 2
        Returns:
        true, if is same feature description
      • getCheckSuffix

        private java.lang.String getCheckSuffix​(java.lang.String get_set,
                                                java.lang.String range)
        Gets the check suffix.
        Parameters:
        get_set - the get set
        range - the range
        Returns:
        the check suffix