Java Code Examples for org.apache.uima.jcas.cas.Sofa#getSofaID()

The following examples show how to use org.apache.uima.jcas.cas.Sofa#getSofaID() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CASImpl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public boolean isBackwardCompatibleCas() {
  // check that there is exactly one sofa
  if (this.svd.viewCount != 1) {
    return false;
  }

  if (!this.svd.initialSofaCreated) {
    return false;
  }
  
  Sofa sofa = this.getInitialView().getSofa();

  // check for mime type exactly equal to "text"
  String sofaMime = sofa.getMimeType();
  if (!"text".equals(sofaMime)) {
    return false;
  }
  // check that sofaURI and sofaArray are not set
  String sofaUri = sofa.getSofaURI();
  if (sofaUri != null) {
    return false;
  }
  TOP sofaArray = sofa.getSofaArray();
  if (sofaArray != null) {
    return false;
  }
  // check that name is NAME_DEFAULT_SOFA
  String sofaname = sofa.getSofaID();
  return NAME_DEFAULT_SOFA.equals(sofaname);
}
 
Example 2
Source File: JsonCasSerializer.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
@Override
protected void writeFeatureStructures(int elementCount /* not used */ ) throws Exception{
  jch.withoutNl();  // set up prettyprint mode so this class controls it
 
  jg.writeStartObject();  // container for (maybe) context, fss (2 parts), and (maybe) delta view info
 
  if (isWithContext) {
    serializeJsonLdContext();
  }
  
  jch.writeNlJustBeforeNext();
  
  // write the reachable from indexes FS
  indexId = false;

  
  jg.writeFieldName(VIEWS_NAME);
  jg.writeStartObject();
  
  final List<TOP>[] byViewByTypeFSs = sortByViewType(); 
  
  for (int viewNbr = 1; viewNbr <= byViewByTypeFSs.length; viewNbr++) {
    // viewNbr starts at 1
    lastEncodedTypeCode = -1;
    final List<TOP> fssInView = byViewByTypeFSs[viewNbr - 1];
    final Sofa sofa = cds.getSofa(viewNbr);
    if (sofa == null && fssInView.size() == 0) {
      continue;  // skip non-existent initial view with no sofa and no elements                    
    }
    jch.writeNlJustBeforeNext();
    String viewName = (null == sofa) ? CAS.NAME_DEFAULT_SOFA : sofa.getSofaID();
    jg.writeFieldName(viewName);  // view namne
    jg.writeStartObject();
    for (TOP fs : fssInView) {
      cds.encodeFS(fs);
    }
    if (lastEncodedTypeCode != -1) {
      jg.writeEndArray(); // of array of types under a fs
    }
    jg.writeEndObject();
  }
  
  jg.writeEndObject();  // end of value for _views
  
  // write the non-embeddable referenced FSs
  
  indexId = true;
  startedReferencedFSs = false;
  cds.encodeQueued();
  if (startedReferencedFSs) {
    jg.writeEndObject(); // of all referenced FSs
  }
        
}