/** * Returns a function which creates a specific UIMA array type. * * @param constructor method on the {@code CAS} object which returns the new array. * @return newly created array feature structure */ private UnaryOperator<FeatureStructure> arrayFactory( Function<Integer, FeatureStructure> constructor) { return (FeatureStructure featureStructure) -> constructor .apply(((CommonArrayFS) featureStructure).size()); }
/** * Creates a function which copies the contents of one array feature structure to another. * * @param aClass the array class * @return function which copies arrays for the type of class. */ private static BiConsumer<FeatureStructure, FeatureStructure> copyArray( Class<? extends CommonArrayFS> aClass) { Method toArrayMethod; Method fromArrayMethod; try { toArrayMethod = aClass.getMethod("toArray"); fromArrayMethod = aClass .getMethod("copyFromArray", toArrayMethod.getReturnType(), Integer.TYPE, Integer.TYPE, Integer.TYPE); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } return (from, to) -> { try { fromArrayMethod.invoke(to, toArrayMethod.invoke(from), 0, 0, ((CommonArrayFS) from).size()); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } }; }
private static Object[] toArray(Feature f, Annotation a) { Object[] ret; try { CommonArrayFS array = (CommonArrayFS) a.getFeatureValue(f); ret = new Object[array.size()]; int index = 0; for (String s : array.toStringArray()) { ret[index] = StringToObject.convertStringToObject(s); index++; } return ret; } catch (ClassCastException cce) { LoggerFactory.getLogger(FeatureUtils.class) .debug("Couldn't cast feature value to array", cce); return new Object[0]; } } }
private static Object[] toArray(Feature f, Annotation a) { Object[] ret; try { CommonArrayFS array = (CommonArrayFS) a.getFeatureValue(f); ret = new Object[array.size()]; int index = 0; for (String s : array.toStringArray()) { ret[index] = StringToObject.convertStringToObject(s); index++; } return ret; } catch (ClassCastException cce) { LoggerFactory.getLogger(FeatureUtils.class) .debug("Couldn't cast feature value to array", cce); return new Object[0]; } } }
/** * Array size. * * @param value the value * @return the int */ private int arraySize(FeatureStructure value) { if (!value.getType().isArray()) { throw new IllegalArgumentException(); } int size; if (value instanceof ArrayFS) { ArrayFS array = (ArrayFS) value; size = array.size(); } else if (value instanceof CommonArrayFS) { CommonArrayFS array = (CommonArrayFS) value; size = array.size(); } else if (value instanceof StringArrayFS) { StringArrayFS array = (StringArrayFS) value; size = array.size(); } else { throw new CasEditorError("Unkown array type!"); } return size; }
+ ((CommonArrayFS)fs).size() + "]";
final int array_size = ca.size();
length = source.size(); switch (aFeature.getRange().getComponentType().getName()) { case CAS.TYPE_NAME_BOOLEAN:
int arrayLength = ((CommonArrayFS)fs).size();