Class Jg

java.lang.Object
org.apache.uima.tools.jcasgen.Jg

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

    • IS_TRACE_LIMITED

      private static final boolean IS_TRACE_LIMITED
      See Also:
    • jControlModel

      static final String jControlModel
      The Constant jControlModel.
      See Also:
    • featureDescriptionArray0

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

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

      static final Set<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 Properties casCreateProperties
      The Constant casCreateProperties.
    • extendableBuiltInTypes

      static final Map<String,FeatureDescription[]> extendableBuiltInTypes
      The Constant extendableBuiltInTypes.
    • emptyFds

      static final FeatureDescription[] emptyFds
      The Constant emptyFds.
    • builtInTypeSystem

      static TypeSystem builtInTypeSystem
      The built in type system.
    • builtInTypes

      static Map<String,TypeInfo> builtInTypes
      The built in types.
    • genericFeatureDescriptorTypes

      private static List<String> genericFeatureDescriptorTypes
    • resourceBundle

      private static ResourceBundle resourceBundle
      The resource bundle.
    • imports

      final Map<String,String> imports
      The imports.
    • _imports

      final Map<String,String> _imports
      The imports.
    • classPath

      String classPath
      The class path.
    • xmlSourceFileName

      String xmlSourceFileName
      The xml source file name.
    • cas

      CAS cas
      The cas.
    • gui

      GUI gui
      The gui.
    • merger

      IMerge merger
      The merger.
    • progressMonitor

      IProgressMonitor progressMonitor
      The progress monitor.
    • error

      public IError error
      The error.
    • waiter

      Waiter waiter
      The waiter.
    • packageName

      String packageName
      The package name.
    • simpleClassName

      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 Map<String,Set<String>> mergedTypesAddingFeatures
      The merged types adding features.
    • projectPathDir

      private String projectPathDir
      The project path dir.
    • limitJCasGenToProjectScope

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

      private static ArrayList<String> nonImportableJavaNames
      The non importable java names.
  • Constructor Details

    • Jg

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

    • addBuiltInTypeInfo

      private static void addBuiltInTypeInfo(String casName, String javaName, 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(String casName, String javaName)
      Adds the built in type info.
      Parameters:
      casName - the cas name
      javaName - the java name
    • getResourceString

      public String getResourceString(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 String getString(String key, Object[] substitutions)
      Gets the string.
      Parameters:
      key - the key
      substitutions - the substitutions
      Returns:
      the string
    • getResourceBundle

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

      public void driveGui()
      Drive gui.
    • main

      public static void main(String[] args)
      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 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:
      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 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:
      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 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:
      IOException - Signals that an I/O exception has occurred.
      InstantiationException - the instantiation exception
      IllegalAccessException - 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, 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:
      IOException - Signals that an I/O exception has occurred.
      InstantiationException - the instantiation exception
      IllegalAccessException - the illegal access exception
    • main0

      public int main0(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(String[] arguments)
      Arguments are: -jcasgeninput xxxx -jcasgenoutput xxxx -jcasgenclasspath xxxx
      Parameters:
      arguments - the arguments
      Returns:
      the int
    • makeMergeMessage

      private String makeMergeMessage(Map<String,Set<String>> m)
      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 directory
      tds - the tds
      aCas - the a cas
      jcasTypeClass - the jcas type class
      Throws:
      IOException - Signals that an I/O exception has occurred.
      InstantiationException - the instantiation exception
      IllegalAccessException - the illegal access exception
    • isOutOfScope

      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.
      Parameters:
      td - the td
      projectDirPath - 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 object
      outputDirectory - output directory
      jcasTypeInstance - Template instance used to generate class
      Throws:
      IOException - -
    • getPkg

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

      String getPkg(String nameWithPkg)
      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 class
      outputDirectory - the output directory
      td - the td
      sourceContents - the source contents
      className - the class name
      mergerGenerateClass - the merger generate class
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • removePkg

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

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

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

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

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

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

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

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

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

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

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

      String getJavaRangeType2(FeatureDescription fd)
      Gets the java range type, with generic types in invalid input: '<'> 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

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

      String getJavaRangeArrayElementType2(FeatureDescription fd)
      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

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

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

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

      String wrapToGetFS(String core, 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

      String simpleCore(String get_set, String range, 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

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

      String arrayCore(String get_set, String range, String arrayRange, 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

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

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

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

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

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

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

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

      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

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

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

      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 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 String getCheckSuffix(String get_set, String range)
      Gets the check suffix.
      Parameters:
      get_set - the get set
      range - the range
      Returns:
      the check suffix
    • isRangeTypeGeneric

      boolean isRangeTypeGeneric(FeatureDescription fd)
    • isElementTypeGeneric

      boolean isElementTypeGeneric(FeatureDescription fd)