/*
* (Internal) create a new instance of TOP (or subclass of TOP) in Java and Cas, and make them
* correspond.
*/
public TOP(JCas jcas) {
CASImpl casImpl = (CASImpl)jcas.getCas();
this.jcasType = jcas.getType(getTypeIndexID());
if (null == jcasType) {
CASRuntimeException e = new CASRuntimeException(CASRuntimeException.JCAS_TYPE_NOT_IN_CAS,
new String[] { this.getClass().getName() });
throw e;
}
boolean isSubtypeOfAnnotationBase = casImpl.isSubtypeOfAnnotationBaseType(jcasType.casTypeCode);
if (isSubtypeOfAnnotationBase &&
(casImpl.getBaseCAS() == casImpl)) {
throw new CASRuntimeException(CASRuntimeException.DISALLOW_CREATE_ANNOTATION_IN_BASE_CAS,
new String[] { this.getClass().getName() });
}
this.addr = jcasType.ll_cas.ll_createFS(jcasType.casTypeCode);
jcas.putJfsFromCaddr(addr, this);
if (casImpl.isSubtypeOfAnnotationBaseType(jcasType.casTypeCode)) {
casImpl.setSofaFeat(addr, casImpl.getSofaRef());
}
}