uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Eckart de Castilho (Commented) (JIRA)" <...@uima.apache.org>
Subject [jira] [Commented] (UIMA-2147) Generate static fields for type names and feature names in JCas wrappers
Date Tue, 04 Oct 2011 21:11:34 GMT

    [ 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.

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

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:

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

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.

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

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

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


View raw message