You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by "Richard Eckart de Castilho (JIRA)" <de...@uima.apache.org> on 2011/05/29 13:46:47 UTC

[jira] [Created] (UIMA-2147) Generate static fields for type names and feature names in JCas wrappers

Generate static fields for type names and feature names in JCas wrappers
------------------------------------------------------------------------

                 Key: UIMA-2147
                 URL: https://issues.apache.org/jira/browse/UIMA-2147
             Project: UIMA
          Issue Type: Improvement
          Components: Core Java Framework
    Affects Versions: 2.3.1
            Reporter: Richard Eckart de Castilho


It would be convient if the JCas wrapper generator would create static final String fields for feature names and for the type name, e.g.

public static final String TYPE_NAME = "my.jcastypes.Type";

public static final String FEAT_BEGIN = "begin";

This would allow cleaner programming with JCas wrappers in cases where the names are required. In particular it would allow to detect certain errors at compile-time and facilitate refactoring.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (UIMA-2147) Generate static fields for type names and feature names in JCas wrappers

Posted by "Marshall Schor (Commented) (JIRA)" <de...@uima.apache.org>.
    [ https://issues.apache.org/jira/browse/UIMA-2147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13120390#comment-13120390 ] 

Marshall Schor commented on UIMA-2147:
--------------------------------------

Thanks, Richard.  I had forgotten about that...  

Can you give an example of how you imagine using the FEAT_xxxxx ?  
                
> Generate static fields for type names and feature names in JCas wrappers
> ------------------------------------------------------------------------
>
>                 Key: UIMA-2147
>                 URL: https://issues.apache.org/jira/browse/UIMA-2147
>             Project: UIMA
>          Issue Type: Improvement
>          Components: Core Java Framework
>    Affects Versions: 2.3.1
>            Reporter: Richard Eckart de Castilho
>
> It would be convient if the JCas wrapper generator would create static final String fields for feature names and for the type name, e.g.
> public static final String TYPE_NAME = "my.jcastypes.Type";
> public static final String FEAT_BEGIN = "begin";
> This would allow cleaner programming with JCas wrappers in cases where the names are required. In particular it would allow to detect certain errors at compile-time and facilitate refactoring.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (UIMA-2147) Generate static fields for type names and feature names in JCas wrappers

Posted by "Marshall Schor (Commented) (JIRA)" <de...@uima.apache.org>.
    [ https://issues.apache.org/jira/browse/UIMA-2147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13120309#comment-13120309 ] 

Marshall Schor commented on UIMA-2147:
--------------------------------------

Which UIMA built-in types have names not equivalent to the CAS type name?
                
> Generate static fields for type names and feature names in JCas wrappers
> ------------------------------------------------------------------------
>
>                 Key: UIMA-2147
>                 URL: https://issues.apache.org/jira/browse/UIMA-2147
>             Project: UIMA
>          Issue Type: Improvement
>          Components: Core Java Framework
>    Affects Versions: 2.3.1
>            Reporter: Richard Eckart de Castilho
>
> It would be convient if the JCas wrapper generator would create static final String fields for feature names and for the type name, e.g.
> public static final String TYPE_NAME = "my.jcastypes.Type";
> public static final String FEAT_BEGIN = "begin";
> This would allow cleaner programming with JCas wrappers in cases where the names are required. In particular it would allow to detect certain errors at compile-time and facilitate refactoring.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (UIMA-2147) Generate static fields for type names and feature names in JCas wrappers

Posted by "Richard Eckart de Castilho (Commented) (JIRA)" <de...@uima.apache.org>.
    [ https://issues.apache.org/jira/browse/UIMA-2147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13120199#comment-13120199 ] 

Richard Eckart de Castilho commented on UIMA-2147:
--------------------------------------------------

One scenario that I remember immediately is writing test cases for code that - in general - should be type-system agnostic, but I have JCas wrappers available for the types that I use for testing. In that case it would be convenient to use constants at least for features instead of having to define constants in the test case or even use string literals.

The TYPE_NAME field would be useful for type that have JCas wrappers but are built into UIMA. In that case the classname is sometimes not equivalent to the CAS type name.

Reconsidering the request, however, a TYPE_NAME constant may be problematic because it would have to change for sub-types. I still think constants for the feature names would be nice though.
                
> Generate static fields for type names and feature names in JCas wrappers
> ------------------------------------------------------------------------
>
>                 Key: UIMA-2147
>                 URL: https://issues.apache.org/jira/browse/UIMA-2147
>             Project: UIMA
>          Issue Type: Improvement
>          Components: Core Java Framework
>    Affects Versions: 2.3.1
>            Reporter: Richard Eckart de Castilho
>
> It would be convient if the JCas wrapper generator would create static final String fields for feature names and for the type name, e.g.
> public static final String TYPE_NAME = "my.jcastypes.Type";
> public static final String FEAT_BEGIN = "begin";
> This would allow cleaner programming with JCas wrappers in cases where the names are required. In particular it would allow to detect certain errors at compile-time and facilitate refactoring.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (UIMA-2147) Generate static fields for type names and feature names in JCas wrappers

Posted by "Marshall Schor (Commented) (JIRA)" <de...@uima.apache.org>.
    [ https://issues.apache.org/jira/browse/UIMA-2147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13120155#comment-13120155 ] 

Marshall Schor commented on UIMA-2147:
--------------------------------------

I'm wondering if we need TYPE_NAME, because in order to use it you need the class name, and it's the same as the class name.  It would help me understand better if you could post some pseudo code showing some use cases.
                
> Generate static fields for type names and feature names in JCas wrappers
> ------------------------------------------------------------------------
>
>                 Key: UIMA-2147
>                 URL: https://issues.apache.org/jira/browse/UIMA-2147
>             Project: UIMA
>          Issue Type: Improvement
>          Components: Core Java Framework
>    Affects Versions: 2.3.1
>            Reporter: Richard Eckart de Castilho
>
> It would be convient if the JCas wrapper generator would create static final String fields for feature names and for the type name, e.g.
> public static final String TYPE_NAME = "my.jcastypes.Type";
> public static final String FEAT_BEGIN = "begin";
> This would allow cleaner programming with JCas wrappers in cases where the names are required. In particular it would allow to detect certain errors at compile-time and facilitate refactoring.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (UIMA-2147) Generate static fields for type names and feature names in JCas wrappers

Posted by "Richard Eckart de Castilho (Commented) (JIRA)" <de...@uima.apache.org>.
    [ https://issues.apache.org/jira/browse/UIMA-2147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13120360#comment-13120360 ] 

Richard Eckart de Castilho commented on UIMA-2147:
--------------------------------------------------

At least Annotation which has the type "uima.tcas.Annotation". I don't know if there are others. In uimaFIT, we have a few lines of code to get the Type object for a particular type name and here we had to add special handling for this:

{noformat}
String UIMA_BUILTIN_JCAS_PREFIX = "org.apache.uima.jcas.";
if (typeName.startsWith(UIMA_BUILTIN_JCAS_PREFIX)) {
  typeName = "uima." + typeName.substring(UIMA_BUILTIN_JCAS_PREFIX.length());
}
Type t = cas.getTypeSystem().getType(typeName);
{noformat}
                
> Generate static fields for type names and feature names in JCas wrappers
> ------------------------------------------------------------------------
>
>                 Key: UIMA-2147
>                 URL: https://issues.apache.org/jira/browse/UIMA-2147
>             Project: UIMA
>          Issue Type: Improvement
>          Components: Core Java Framework
>    Affects Versions: 2.3.1
>            Reporter: Richard Eckart de Castilho
>
> It would be convient if the JCas wrapper generator would create static final String fields for feature names and for the type name, e.g.
> public static final String TYPE_NAME = "my.jcastypes.Type";
> public static final String FEAT_BEGIN = "begin";
> This would allow cleaner programming with JCas wrappers in cases where the names are required. In particular it would allow to detect certain errors at compile-time and facilitate refactoring.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (UIMA-2147) Generate static fields for type names and feature names in JCas wrappers

Posted by "Richard Eckart de Castilho (Commented) (JIRA)" <de...@uima.apache.org>.
    [ https://issues.apache.org/jira/browse/UIMA-2147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13120477#comment-13120477 ] 

Richard Eckart de Castilho commented on UIMA-2147:
--------------------------------------------------

Lets see what I can make up and/or pick up from our source codes

1) I imagine to write test cases for components that do internally not use the JCas API, but that are configurable with respect to the type system. In the test case, however, I use some types that I commonly use and for these I have JCas wrappers.

2) I imagine to have the "comfort" of JCas wrappers, but do not want to actually use JCas (avoiding to initialize the JCas subsystem). For some UIMA-buildin types, there are constants like these, which would be nice to have for custom JCas wrappers as well.

{noformat}
annotationType = aJCas.getTypeSystem().getType(CAS.TYPE_NAME_ANNOTATION);
beginFeature = annotationType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_BEGIN);
endFeature = annotationType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_END);
{noformat}

3) We have some cases were we use CAS.createAnnotation to create an annotation of a particular type (e.g. Verb, Noun, etc.) in a CAS-based component. We know, that the type will be a sub-type of a certain type (PartOfSpeechTag) and will have a certain feature (posValue). So we have this code:

{noformat}
AnnotationFS posAnno = aCAS.createAnnotation(posType, offset, offset + len);
posAnno.setStringValue(posType.getFeatureByBaseName("PosValue"), pos);
{noformat}

If somebody changed the type system, we could not get a compiler warning that "PosValue" is no longer available. If we used a constant from a JCas wrapper which is generated from the type system, we would notice that however. Ok, we have test-cases, but I still like static compiler checks more.

4) Consider StatusCallbackListenerImpl:165 - here String literals are used which do not allow for static compile-time checks.

{noformat}
      Type t = aCas.getTypeSystem().getType("uima.cpm.FileLocation");
      Feature f = t.getFeatureByBaseName("DocumentSize");
{noformat}

5) The constants could allow to conveniently search for usages of a feature/type in situations where a the CAS API is used.

So it boils down to compile-time checks and maintainability.
                
> Generate static fields for type names and feature names in JCas wrappers
> ------------------------------------------------------------------------
>
>                 Key: UIMA-2147
>                 URL: https://issues.apache.org/jira/browse/UIMA-2147
>             Project: UIMA
>          Issue Type: Improvement
>          Components: Core Java Framework
>    Affects Versions: 2.3.1
>            Reporter: Richard Eckart de Castilho
>
> It would be convient if the JCas wrapper generator would create static final String fields for feature names and for the type name, e.g.
> public static final String TYPE_NAME = "my.jcastypes.Type";
> public static final String FEAT_BEGIN = "begin";
> This would allow cleaner programming with JCas wrappers in cases where the names are required. In particular it would allow to detect certain errors at compile-time and facilitate refactoring.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira