public List getFeatureValues()

in ConfigurableFeatureExtractor/src/main/java/org/apache/uima/tools/cfe/TargetObjectMatcher.java [305:350]


    public List<MatchedValue> getFeatureValues (MatchedValue mv)
    throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
    {
        // allows derived classes to be processed
        List<MatchedValue> result = new ArrayList<MatchedValue>();
        if (m_delimit_array_values) {
            // set max array level
            result.add(new MatchedValue(new ArrayDelimiterObject(0), new ArrayList<Object>()));
        }
        
        if (! m_root_class.isAssignableFrom(mv.m_matchedObject.getClass())) {
            return result;
        }
        else if (0 == m_target_path_tokens.length) {
            if (isTargetClassMatches(mv.m_matchedObject.getClass(), false)) {
                result.add(mv);
            }
            return result;
        }
        
        if ((1 == m_target_path_tokens.length) && m_target_path_tokens[0].contains("/")) {
            // if the path is an xpath (separator is '/') then it will 
            // be a single "token" as parsing only splits on ':'
            // WARNING: JXPath is not supported!!! just experimenting
            // the biggest issue so far is that elements of arrays are not separated
            // by the objects containing them,
            // so for the path:
            //      array_feature1/regular_feature/array_feature2/regular_feature2
            // all values for regular_feature2 are iterated by a single iterator
            // and it is not clear to which element of array_feature1 a particular 
            // regular_feature2 belongs
            JXPathContext ctx = JXPathContext.newContext(mv.m_matchedObject);
            ctx.setLenient(true);
            for (Iterator<?> it = ctx.iterate(m_target_path_tokens[0]); it.hasNext();) {
                // System.out.printf("%s=%s\n", m_target_path_tokens[0], it.next());
                if (result.size() > 1 && m_delimit_array_values) {
                    result.add(new MatchedValue(new ArrayDelimiterObject(0), new ArrayList<Object>()));                    
                }
                result.add(new MatchedValue(it.next(), new ArrayList<Object>()));
            }
        }
        else {
            getMatchedValues(new Object[] {mv.m_matchedObject}, mv.m_orderedPath, m_target_path_tokens, 0, result, new ArrayList<Object>(), -1);
        }
        return result;
    }