/** * Create a sofa mapping using the component class rather than the component name. Actually, the * name of the class is used as the component name. * * @param componentClass * the component clas * @param componentSofaName * the sofa name used by the the component * @param aggregateSofaName * the view name that the component name is mapped to and used by the aggregate analysis * engine * @return a sofa mapping with the componentSofaName mapped to the aggregateSofaName */ public static SofaMapping createSofaMapping(Class<? extends AnalysisComponent> componentClass, String componentSofaName, String aggregateSofaName) { return createSofaMapping(componentClass.getName(), componentSofaName, aggregateSofaName); } }
/** * Provide a sofa mapping for a component from the component's view to the aggregate view. * * @param componentName * the name of the component * @param componentViewName * the name of the component view * @param aggregateViewName * the name of the aggregate view to map the component view to. */ public void addSofaMapping(String componentName, String componentViewName, String aggregateViewName) { if (componentNames.contains(componentName)) { sofaMappings.add(SofaMappingFactory.createSofaMapping(componentName, componentViewName, aggregateViewName)); } else { throw new IllegalArgumentException("No component with the name '" + componentName + "' has been added to this builder. Sofa mappings may only be added for " + "components that have been added to this builder. "); } }
/** * @param componentName * the name of the component to add * @param aed * an analysis engine description to add to the aggregate analysis engine * @param viewNames * pairs of view names corresponding to a componentSofaName followed by the * aggregateSofaName that it is mapped to. An even number of names must be passed in or * else an IllegalArgumentException will be thrown. See * {@link SofaMappingFactory#createSofaMapping(String, String, String)} */ public void add(String componentName, AnalysisEngineDescription aed, String... viewNames) { if (componentNames.contains(componentName)) { throw new IllegalArgumentException("the component name '" + componentName + "' has already been used for another added analysis engine description."); } if (viewNames != null && viewNames.length % 2 != 0) { throw new IllegalArgumentException("an even number of view names is required (as " + "component view name, aggregate view name pairs) for the AggregateBuilder.add " + "method. " + viewNames.length + " view names passed: " + Arrays.asList(viewNames)); } analysisEngineDescriptions.add(aed); componentNames.add(componentName); if (viewNames != null) { for (int i = 0; i < viewNames.length; i += 2) { sofaMappings.add(SofaMappingFactory.createSofaMapping(componentName, viewNames[i], viewNames[i + 1])); } } }