protected MappingNode morphNode(MappingNode mappingNode) { MWMapping mapping; if (mappingNode.isMapped()) { mapping = morphMapping(mappingNode.getMapping()); } else { mapping = addMapping(mappingNode.descriptor(), mappingNode.instanceVariable()); } return (MappingNode) mappingNode.getDescriptorNode().descendantNodeForValue(mapping); }
@Override protected Object createEmptyJavaBean(MappingNode node) { if (YamlTape.class.equals(node.getType())) { return new YamlTape(fileResolver); } else { return super.createEmptyJavaBean(node); } }
/** * Reads one lists (one file) of phrases * * @param node the node * @param add if <b>true</b> will add the phrases found in the list to the ones recognised by this * gazetteer, if <b>false</b> the phrases found in the list will be removed from the list of * phrases recognised by this gazetteer. */ protected void readList(LinearNode node, boolean add) throws ResourceInstantiationException { String listName, majorType, minorType, languages, annotationType; if (null == node) { throw new ResourceInstantiationException(" LinearNode node is null "); } listName = node.getList(); majorType = node.getMajorType(); minorType = node.getMinorType(); languages = node.getLanguage(); annotationType = node.getAnnotationType(); GazetteerList gazList = (GazetteerList) listsByNode.get(node); if (null == gazList) { throw new ResourceInstantiationException("gazetteer list not found by node"); } Iterator iline = gazList.iterator(); // create default lookup for entries with no arbitrary features Lookup defaultLookup = new Lookup(listName, majorType, minorType, languages, annotationType); defaultLookup.list = node.getList(); if (null != mappingDefinition) { MappingNode mnode = mappingDefinition.getNodeByList(defaultLookup.list); if (null != mnode) { defaultLookup.oClass = mnode.getClassID(); defaultLookup.ontology = mnode.getOntologyID(); } } // if mapping def Lookup lookup; String entry; // the actual gazetteer entry text while (iline.hasNext()) { GazetteerNode gazNode = (GazetteerNode) iline.next(); entry = gazNode.getEntry(); Map features = gazNode.getFeatureMap(); if (features == null) { lookup = defaultLookup; } else { // create a new Lookup object with features lookup = new Lookup(listName, majorType, minorType, languages, annotationType); lookup.list = node.getList(); if (null != mappingDefinition) { MappingNode mnode = mappingDefinition.getNodeByList(lookup.list); if (null != mnode) { lookup.oClass = mnode.getClassID(); lookup.ontology = mnode.getOntologyID(); } } // if mapping def lookup.features = features; } if (add) addLookup(entry, lookup); else removeLookup(entry, lookup); } } // void readList(String listDesc)
/** return whether the specified node is already morphed */ protected boolean nodeIsMorphed(MappingNode mappingNode) { return mappingNode.isMapped() && (this.mappingClass().isAssignableFrom(mappingNode.getMapping().getClass())); }
protected void disengageValueEnabled(AbstractApplicationNode node) { super.disengageValueEnabled(node); ((MappingNode) node) .descriptor() .removePropertyChangeListener(MWDescriptor.ACTIVE_PROPERTY, getEnabledStateListener()); }