/** * Checks if the given feature has the expected type otherwise * an exception is thrown. * * @param feature * @param expectedType * @throws AnalysisEngineProcessException - if type does not match */ private static void checkFeatureType(Feature feature, String expectedType) throws AnalysisEngineProcessException { if (!feature.getRange().getName().equals(expectedType)) { throw new OpenNlpAnnotatorProcessException( ExceptionMessages.WRONG_FEATURE_TYPE, new Object[] {feature.getName(), expectedType }); } }
@Override public String getName() { return delegate.getName(); }
private static void requireSingleValue(Feature aFeature, Object aArray) { if (aArray == null) { throw new IllegalArgumentException("Cannot set [" + aFeature.getName() + "] to a null value."); } if (Array.getLength(aArray) != 1) { throw new IllegalArgumentException("Feature [" + aFeature.getName() + "] requires a single value but got " + asList(aArray)); } }
/** * Do not check on agreement on Position and SOfa feature - already checked */ private static boolean isBasicFeature(Feature aFeature) { // FIXME The two parts of this OR statement seem to be redundant. Also the order // of the check should be changes such that equals is called on the constant. return aFeature.getName().equals(CAS.FEATURE_FULL_NAME_SOFA) || aFeature.toString().equals("uima.cas.AnnotationBase:sofa"); }
/** * Do not check on agreement on Position and SOfa feature - already checked */ private static boolean isBasicFeature(Feature aFeature) { // FIXME The two parts of this OR statement seem to be redundant. Also the order // of the check should be changes such that equals is called on the constant. return aFeature.getName().equals(CAS.FEATURE_FULL_NAME_SOFA) || aFeature.toString().equals("uima.cas.AnnotationBase:sofa"); }
@Override public String getName() { checkDelegate(); return delegate.getName(); }
private final String getFeatureString(Feature f) { return f.getName() + " (" + ll_getCodeForFeature(f) + ")"; }
private static final void throwUndefinedFeatureExc(Feature f, Type t) throws CASRuntimeException { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_FEAT, new String[] { f.getName(), t.getName() }); throw e; }
private void reportMultiRefWarning(int featCode) throws SAXException { String message = String.format("Feature %s is marked multipleReferencesAllowed=false, but it has" + " multiple references. These will be serialized in duplicate.", tsi.ll_getFeatureForCode(featCode).getName()); MessageReport.decreasingWithTrace(errorCount, message, logger); if (this.errorHandler != null) { this.errorHandler.warning(new SAXParseException(message, null)); } }
private void processFeature(Map<String, Object> map, Base base, Feature f) { if (stopFeatures.contains(f.getName()) || stopFeatures.contains(f.getShortName())) { return; } try { convertFeature(map, base, f); } catch (Exception e) { getMonitor() .warn( "Couldn't output {} to map. Type '{}' isn't supported.", f.getName(), f.getRange().getShortName(), e); } }
/** * Checks if the given feature has the expected type otherwise * an exception is thrown. * * @param feature * @param expectedType * @throws AnalysisEngineProcessException - if type does not match */ private static void checkFeatureType(Feature feature, String expectedType) throws AnalysisEngineProcessException { if (!feature.getRange().getName().equals(expectedType)) { throw new OpenNlpAnnotatorProcessException( ExceptionMessages.WRONG_FEATURE_TYPE, new Object[] {feature.getName(), expectedType }); } }
/** * Checks if the given feature has the expected type otherwise * an exception is thrown. * * @param feature * @param expectedType * * @throws AnalysisEngineProcessException - if type does not match */ private static void checkFeatureType(Feature feature, String expectedType) throws AnalysisEngineProcessException { if (!feature.getRange().getName().equals(expectedType)) { throw new OpenNlpAnnotatorProcessException( ExceptionMessages.WRONG_FEATURE_TYPE, new Object[] {feature.getName(), expectedType }); } }
private static final void throwIllegalRangeExc(Feature f, Type t) throws CASRuntimeException { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_RANGE, new String[] { f.getName(), t.getName(), f.getRange().getName() }); throw e; }
private final void checkDomTypeConditions(int domTypeCode, int featCode) { final TypeSystemImpl ts = this.svd.casMetadata.ts; if (!ts.isApprop(domTypeCode, featCode)) { LowLevelException e = new LowLevelException(LowLevelException.FEAT_DOM_ERROR); e.addArgument(Integer.toString(domTypeCode)); e.addArgument(ts.ll_getTypeForCode(domTypeCode).getName()); e.addArgument(Integer.toString(featCode)); e.addArgument(ts.ll_getFeatureForCode(featCode).getName()); throw e; } }
private final void checkTypingConditions(int domTypeCode, int ranTypeCode, int featCode) { checkDomTypeConditions(domTypeCode, featCode); final TypeSystemImpl ts = this.svd.casMetadata.ts; if (!ts.subsumes(ts.range(featCode), ranTypeCode)) { LowLevelException e = new LowLevelException(LowLevelException.FEAT_RAN_ERROR); e.addArgument(Integer.toString(featCode)); e.addArgument(ts.ll_getFeatureForCode(featCode).getName()); e.addArgument(Integer.toString(ranTypeCode)); e.addArgument(ts.ll_getTypeForCode(ranTypeCode).getName()); throw e; } }
private final void checkFsRan(int featCode) throws LowLevelException { final TypeSystemImpl ts = this.svd.casMetadata.ts; final int rangeTypeCode = ts.range(featCode); if (!ll_isRefType(rangeTypeCode)) { LowLevelException e = new LowLevelException(LowLevelException.FS_RAN_TYPE_ERROR); e.addArgument(Integer.toString(featCode)); e.addArgument(ts.ll_getFeatureForCode(featCode).getName()); e.addArgument(ts.ll_getTypeForCode(rangeTypeCode).getName()); throw e; } }
private void populateFeaturesForAnnotation( final JCas jCas, final BaleenAnnotation annotation, final Map<String, Object> map, final List<ReferencedFeatures> featuresToDereference) { for (final Feature f : annotation.getType().getFeatures()) { try { populateFeature(jCas, map, annotation, f, featuresToDereference); } catch (final Exception e) { getMonitor() .warn( "Couldn't populate {} to map. Type '{}' isn't supported.", f.getName(), f.getRange().getShortName(), e); } } }
private final void setNullValue(int featCode, int rangeType) { if (this.getCASImpl().isIntType(rangeType) || this.getCASImpl().isFloatType(rangeType) || this.getCASImpl().isStringType(rangeType)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.PRIMITIVE_VAL_FEAT, new String[] { this.getCASImpl().getTypeSystemImpl().ll_getFeatureForCode(featCode).getName() }); throw e; } // a null fsref is never an index key this.getCASImpl().setFeatureValueNoIndexCorruptionCheck(this.getAddress(), featCode, CASImpl.NULL); }