本文整理汇总了Java中org.apache.uima.cas.FeatureStructure.setIntValue方法的典型用法代码示例。如果您正苦于以下问题:Java FeatureStructure.setIntValue方法的具体用法?Java FeatureStructure.setIntValue怎么用?Java FeatureStructure.setIntValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.cas.FeatureStructure
的用法示例。
在下文中一共展示了FeatureStructure.setIntValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyPrimiteFeature
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
private void copyPrimiteFeature(FeatureStructure sourceFs,
FeatureStructure targetFs, Feature feat) {
String rangeName = feat.getRange().getName();
if (CAS.TYPE_NAME_STRING.equals(rangeName)) {
targetFs.setStringValue(feat, sourceFs.getStringValue(feat));
} else if (CAS.TYPE_NAME_INTEGER.equals(rangeName)) {
targetFs.setIntValue(feat, sourceFs.getIntValue(feat));
} else if (CAS.TYPE_NAME_FLOAT.equals(rangeName)) {
targetFs.setFloatValue(feat, sourceFs.getFloatValue(feat));
} else if (CAS.TYPE_NAME_BYTE.equals(rangeName)) {
targetFs.setByteValue(feat, sourceFs.getByteValue(feat));
} else if (CAS.TYPE_NAME_SHORT.equals(rangeName)) {
targetFs.setShortValue(feat, sourceFs.getShortValue(feat));
} else if (CAS.TYPE_NAME_LONG.equals(rangeName)) {
targetFs.setLongValue(feat, sourceFs.getLongValue(feat));
} else if (CAS.TYPE_NAME_DOUBLE.equals(rangeName)) {
targetFs.setDoubleValue(feat, sourceFs.getDoubleValue(feat));
} else if (CAS.TYPE_NAME_BOOLEAN.equals(rangeName)) {
targetFs.setBooleanValue(feat, sourceFs.getBooleanValue(feat));
}
}
示例2: setFeatureValue
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
public static void setFeatureValue(FeatureStructure aFS, Feature aFeature, Object aValue)
{
switch (aFeature.getRange().getName()) {
case CAS.TYPE_NAME_STRING:
aFS.setStringValue(aFeature, aValue == null ? null : aValue.toString());
break;
case CAS.TYPE_NAME_BOOLEAN:
aFS.setBooleanValue(aFeature, Boolean.valueOf(aValue.toString()));
break;
case CAS.TYPE_NAME_FLOAT:
aFS.setFloatValue(aFeature, Float.valueOf(aValue.toString()));
break;
case CAS.TYPE_NAME_INTEGER:
aFS.setIntValue(aFeature, Integer.valueOf(aValue.toString()));
break;
case CAS.TYPE_NAME_BYTE:
aFS.setByteValue(aFeature, Byte.valueOf(aValue.toString()));
break;
case CAS.TYPE_NAME_DOUBLE:
aFS.setDoubleValue(aFeature, Double.valueOf(aValue.toString()));
break;
case CAS.TYPE_NAME_LONG:
aFS.setLongValue(aFeature, Long.valueOf(aValue.toString()));
break;
case CAS.TYPE_NAME_SHORT:
aFS.setShortValue(aFeature, Short.valueOf(aValue.toString()));
break;
default:
return;
// return aFS.getFeatureValue(aFeature);
}
}
示例3: setFeature
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
/**
* Set a feature value.
*
* @param aFS
* the feature structure.
* @param aFeature
* the feature within the annotation whose value to set. If this parameter is
* {@code null} then nothing happens.
* @param aValue
* the feature value.
*/
public static void setFeature(FeatureStructure aFS, AnnotationFeature aFeature, Object aValue)
{
if (aFeature == null) {
return;
}
Feature feature = aFS.getType().getFeatureByBaseName(aFeature.getName());
switch (aFeature.getMultiValueMode()) {
case NONE: {
String effectiveType = aFeature.getType();
if (effectiveType.contains(":")) {
effectiveType = CAS.TYPE_NAME_STRING;
}
// Sanity check
if (!Objects.equals(effectiveType, feature.getRange().getName())) {
throw new IllegalArgumentException("On [" + aFS.getType().getName() + "] feature ["
+ aFeature.getName() + "] actual type [" + feature.getRange().getName()
+ "] does not match expected feature type [" + effectiveType + "].");
}
switch (effectiveType) {
case CAS.TYPE_NAME_STRING:
aFS.setStringValue(feature, (String) aValue);
break;
case CAS.TYPE_NAME_BOOLEAN:
aFS.setBooleanValue(feature, aValue != null ? (boolean) aValue : false);
break;
case CAS.TYPE_NAME_FLOAT:
aFS.setFloatValue(feature, aValue != null ? (float) aValue : 0.0f);
break;
case CAS.TYPE_NAME_INTEGER:
aFS.setIntValue(feature, aValue != null ? (int) aValue : 0);
break;
default:
throw new IllegalArgumentException("Cannot set value of feature ["
+ aFeature.getName() + "] with type [" + feature.getRange().getName()
+ "] to [" + aValue + "]");
}
break;
}
case ARRAY: {
switch (aFeature.getLinkMode()) {
case WITH_ROLE: {
// Get type and features - we need them later in the loop
setLinkFeature(aFS, aFeature, (List<LinkWithRoleModel>) aValue, feature);
break;
}
default:
throw new IllegalArgumentException("Unsupported link mode ["
+ aFeature.getLinkMode() + "] on feature [" + aFeature.getName() + "]");
}
break;
}
default:
throw new IllegalArgumentException("Unsupported multi-value mode ["
+ aFeature.getMultiValueMode() + "] on feature [" + aFeature.getName() + "]");
}
}