You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by "Christopher Buckley (JIRA)" <de...@uima.apache.org> on 2011/06/08 22:57:58 UTC

[jira] [Commented] (UIMA-1471) CasDataUtils should be refactored and reviewed

    [ https://issues.apache.org/jira/browse/UIMA-1471?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13046214#comment-13046214 ] 

Christopher Buckley commented on UIMA-1471:
-------------------------------------------

Hi Marshall, I'm assuming you wanted to take the following out

if (object instanceof FeatureStructure) {} 

I'm also assuming that you want to keep this in but, get rid of the instanceof...
      if (((FeatureStructure) object).getType().equals(aFeatureStructure)) {

I've also made some changes to get rid of the casting the object so it now looks like this for example.

  public static boolean hasFeature(CasData aCAS, String featureName) {
    Iterator<FeatureStructure> it = aCAS.getFeatureStructures();
    while (it.hasNext()) {
        FeatureStructure fs = it.next();
        FeatureValue fValue = fs.getFeatureValue(featureName);
        if (fValue != null) {
          return true;
        }
    }
    return false;
  }
 
The code built successfully and all the tests passed. I wanted to take on something smaller to get started.  I've attached the file with the changes.
 

> CasDataUtils should be refactored and reviewed
> ----------------------------------------------
>
>                 Key: UIMA-1471
>                 URL: https://issues.apache.org/jira/browse/UIMA-1471
>             Project: UIMA
>          Issue Type: Improvement
>          Components: Core Java Framework
>    Affects Versions: 2.3
>            Reporter: Jörn Kottmann
>            Priority: Trivial
>
> The CasDataUtils class should be reviewed and re-factored to eliminate the (unnecessary) explicit type checks in the various utility methods.

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