void traceFSfs(FeatureStructureImpl fs) { StringBuilder b = svd.traceFScreationSb; svd.traceFSid = fs.getAddress(); b.append("c:").append(String.format("%-3d", getCasId())); String viewName = fs.getCAS().getViewName(); if (null == viewName) { viewName = "base"; } b.append(" v:").append(MiscImpl.elide(viewName, 8)); b.append(" i:").append(String.format("%-5s", fs.getAddress())); b.append(" t:").append(MiscImpl.elide(fs.getType().getShortName(), 10)); }
/****************************************** * DEBUGGING and TRACING * ******************************************/ void traceFSCreate(FeatureStructureImpl fs) { StringBuilder b = svd.traceFScreationSb; if (b.length() > 0) { traceFSflush(); } traceFSfs(fs); svd.traceFSisCreate = true; if (fs.getType().isArray()) { int arraySize = ll_getArraySize(fs.getAddress()); b.append(" l:").append(arraySize); } if (fs.getAddress() > 190000 && fs.getAddress() < 200000 && fs.getType().getShortName().equals("Passage")) { traceOut.println("Passage callback: " + MiscImpl.getCallers(3, 10)); } }
public Object clone() throws CASRuntimeException { if (getType().getName().equals(CAS.TYPE_NAME_SOFA)) { throw new CASRuntimeException(CASRuntimeException.CANNOT_CLONE_SOFA); } CASImpl casImpl = this.getCASImpl(); FeatureStructure newFS = getCAS().createFS(getType()); casImpl.copyFeatures(((FeatureStructureImpl) newFS).getAddress(), this.getAddress()); return newFS; }
public float getFloatValue(Feature feat) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(feat.getDomain(), getType())) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(feat.getRange(), ts.getType(CAS.TYPE_NAME_FLOAT))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_FLOAT)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getFloatValue(this.getAddress(), featCode); }
public long getLongValue(Feature feat) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(feat.getDomain(), getType())) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(feat.getRange(), ts.getType(CAS.TYPE_NAME_LONG))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_LONG)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getLongValue(this.getAddress(), featCode); }
public byte getByteValue(Feature feat) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(feat.getDomain(), getType())) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(feat.getRange(), ts.getType(CAS.TYPE_NAME_BYTE))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_BYTE)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getByteValue(this.getAddress(), featCode); }
public short getShortValue(Feature feat) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(feat.getDomain(), getType())) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(feat.getRange(), ts.getType(CAS.TYPE_NAME_SHORT))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_SHORT)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getShortValue(this.getAddress(), featCode); }
public double getDoubleValue(Feature feat) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(feat.getDomain(), getType())) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(feat.getRange(), ts.getType(CAS.TYPE_NAME_DOUBLE))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_DOUBLE)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getDoubleValue(this.getAddress(), featCode); }
public boolean getBooleanValue(Feature feat) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(feat.getDomain(), getType())) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(feat.getRange(), ts.getType(CAS.TYPE_NAME_BOOLEAN))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_BOOLEAN)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getBooleanValue(this.getAddress(), featCode); }
public int getIntValue(Feature feat) { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(feat.getDomain(), getType())) { // System.out.println( // "Domain: " // + feat.getDomain().getName() // + ", type: " // + getType().getName()); throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(feat.getRange(), ts.getType(CAS.TYPE_NAME_INTEGER))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_INTEGER)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getFeatureValue(this.getAddress(), featCode); }
public String getStringValue(Feature f) throws CASRuntimeException { final int thisType = ((TypeImpl) this.getType()).getCode(); final int domType = ((TypeImpl) f.getDomain()).getCode(); final int stringType = ((TypeImpl) this.getCASImpl().getTypeSystem().getType( CAS.TYPE_NAME_STRING)).getCode(); final int rangeType = ((TypeImpl) f.getRange()).getCode(); final TypeSystemImpl ts = (TypeSystemImpl) this.getCASImpl().getTypeSystem(); if (!ts.subsumes(domType, thisType)) { throwUndefinedFeatureExc(f, getType()); } if (!ts.subsumes(stringType, rangeType)) { throwIllegalRangeExc(f, this.getCASImpl().getTypeSystem().getType(CAS.TYPE_NAME_STRING)); } // final int stringAddr = casImpl.getFeatureValue(this.getAddress(), // ((FeatureImpl)f).getCode()); // return casImpl.getStringValue(stringAddr); return this.getCASImpl().getStringValue(this.getAddress(), ((FeatureImpl) f).getCode()); }
public void setShortValue(Feature feat, short val) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_SHORT)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_SHORT)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, val); }
public void setIntValue(Feature feat, int val) { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_INTEGER)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_INTEGER)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, val); }
public void setFloatValue(Feature feat, float val) { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_FLOAT)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_FLOAT)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFloatValue(this.getAddress(), featCode, val); }
public void setByteValue(Feature feat, byte val) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_BYTE)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_BYTE)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, val); }
public void setBooleanValue(Feature feat, boolean b) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_BOOLEAN)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_BOOLEAN)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, b); }
public void setLongValue(Feature feat, long val) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_LONG)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_LONG)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, val); }
public void setDoubleValue(Feature feat, double val) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_DOUBLE)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_DOUBLE)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, val); }
public FeatureStructure getFeatureValue(Feature feat) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); // final int featCode = ts.getFeatureCode(feat.getName()); final int featCode = ((FeatureImpl) feat).getCode(); // assert(featCode > 0); if (!ts.isApprop(this.getCASImpl().getHeapValue(this.getAddress()), featCode)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_FEAT, new String[] { feat.getName(), this.getType().getName() }); throw e; } // Check that feature value is not primitive. final int rangeTypeCode = ts.ll_getRangeType(featCode); if (!this.getCASImpl().ll_isRefType(rangeTypeCode)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.PRIMITIVE_VAL_FEAT, new String[] { feat.getName() }); throw e; } final int valAddr = this.getCASImpl().getFeatureValue(this.getAddress(), featCode); // assert(valAddr > 0); return this.getCASImpl().createFS(valAddr); }
public void setStringValue(Feature feat, String val) { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); final int featCode = ((FeatureImpl) feat).getCode(); final int rangeType = ts.range(featCode); final int thisType = this.getCASImpl().getHeapValue(this.getAddress()); final int stringType = ((TypeImpl) this.getCASImpl().getTypeSystem().getType( CAS.TYPE_NAME_STRING)).getCode(); if (!ts.isApprop(thisType, featCode)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_FEAT, new String[] { feat.getName(), this.getType().getName() }); throw e; } if (!ts.subsumes(stringType, rangeType)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_TYPE, new String[] { feat.getRange().getName(), this.getCAS().getTypeSystem().getType(CAS.TYPE_NAME_STRING).getName() }); throw e; } this.getCAS().getLowLevelCAS().ll_setStringValue(this.getAddress(), featCode, val); }