negativediff.java

来自「Semantic Web Ontology Editor」· Java 代码 · 共 548 行 · 第 1/2 页

JAVA
548
字号
	public void visit(OWLDifferentIndividualsAxiom axiom) throws OWLException {		if (!destination.getIndividualAxioms().contains(axiom)) {			Set different = new HashSet();					for (Iterator iter = axiom.getIndividuals().iterator(); iter.hasNext(); ) {				different.add(copier.copy((OWLIndividual)iter.next()));			}			OWLIndividualAxiom tgtAxiom = factory.getOWLDifferentIndividualsAxiom(different);			changes.add(new RemoveIndividualAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLDisjointClassesAxiom axiom) throws OWLException {		if (!destination.getClassAxioms().contains(axiom)) {			Set disjoints = new HashSet();			for (Iterator iter = axiom.getDisjointClasses().iterator(); iter.hasNext(); ) {				disjoints.add(copier.copy((OWLDescription) iter.next()));			}			OWLClassAxiom tgtAxiom = factory.getOWLDisjointClassesAxiom(disjoints);			changes.add(new RemoveClassAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLEquivalentClassesAxiom axiom) throws OWLException {		if (!destination.getClassAxioms().contains(axiom)) {			Set equivalents = new HashSet();			for (Iterator iter = axiom.getEquivalentClasses().iterator(); iter.hasNext(); ) {				equivalents.add(copier.copy((OWLDescription) iter.next()));			}			OWLClassAxiom tgtAxiom = factory.getOWLEquivalentClassesAxiom(equivalents);			changes.add(new RemoveClassAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLEquivalentPropertiesAxiom axiom) throws OWLException {		if (!destination.getPropertyAxioms().contains(axiom)) {			Set equivalents = new HashSet();			for (Iterator iter = axiom.getProperties().iterator(); iter.hasNext();) {				equivalents.add(copier.copy((OWLProperty) iter.next()));			}			OWLPropertyAxiom tgtAxiom = factory.getOWLEquivalentPropertiesAxiom(equivalents);			changes.add(new RemovePropertyAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLFunctionalPropertyAxiom axiom) throws OWLException {		if (!destination.getPropertyAxioms().contains(axiom)) {			OWLProperty tgtProp = (OWLProperty) copier.copy(axiom.getProperty());			OWLPropertyAxiom tgtAxiom = factory.getOWLFunctionalPropertyAxiom(tgtProp);			changes.add(new RemovePropertyAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLIndividual entity) throws OWLException {		OWLIndividual tgtEntity;		OWLIndividual dstEntity;				if (entity.isAnonymous()) {			tgtEntity = factory.getAnonOWLIndividual(entity.getAnonId());			dstEntity = destination.getIndividual(entity.getAnonId());		} else {			tgtEntity = factory.getOWLIndividual(entity.getURI());			dstEntity = destination.getIndividual(entity.getURI());		}				if (dstEntity == null) {			changes.add(new RemoveEntity(target, tgtEntity, null));			if (entity.isAnonymous()) {				dstEntity = destination.getOWLDataFactory().getAnonOWLIndividual(entity.getAnonId());			} else {				dstEntity = destination.getOWLDataFactory().getOWLIndividual(entity.getURI());			}		}		annotationRemover(entity, dstEntity, tgtEntity);		Set srcTypes = entity.getTypes(source);		Set dstTypes = dstEntity.getTypes(destination);		for (Iterator typeIter = srcTypes.iterator(); typeIter.hasNext();) {			OWLDescription srcType = (OWLDescription) typeIter.next();			if (!dstTypes.contains(srcType)) {				OWLDescription tgtType = copier.copy(srcType);				changes.add(new RemoveIndividualClass(target, tgtEntity,						tgtType, null));			}		}		Map srcProps = entity.getDataPropertyValues(source);		Map dstProps = dstEntity.getDataPropertyValues(destination);		for (Iterator propIter = srcProps.keySet().iterator(); propIter				.hasNext();) {			OWLDataProperty prop = (OWLDataProperty) propIter.next();			OWLDataProperty dstProp = destination.getOWLDataFactory().getOWLDataProperty(prop.getURI());			OWLDataProperty tgtProp = factory.getOWLDataProperty(prop.getURI());			Set srcValues = (Set) srcProps.get(prop);			Set dstValues = (Set) dstProps.get(dstProp);			if (dstValues == null) {				dstValues = Collections.EMPTY_SET;			}			for (Iterator valueIter = srcValues.iterator(); valueIter.hasNext();) {				OWLDataValue dv = (OWLDataValue) valueIter.next();				if (!dstValues.contains(dv)) {					OWLDataValue tgtDV = factory.getOWLConcreteData(							dv.getURI(), dv.getLang(), dv.getValue());					changes.add(new RemoveDataPropertyInstance(target,							tgtEntity, tgtProp, tgtDV, null));				}			}		}		srcProps = entity.getObjectPropertyValues(source);		dstProps = dstEntity.getObjectPropertyValues(destination);		for (Iterator propIter = srcProps.keySet().iterator(); propIter				.hasNext();) {			OWLObjectProperty prop = (OWLObjectProperty) propIter.next();			OWLObjectProperty dstProp = destination.getOWLDataFactory().getOWLObjectProperty(prop.getURI());			OWLObjectProperty tgtProp = factory.getOWLObjectProperty(prop.getURI());			Set srcValues = (Set) srcProps.get(prop);			Set dstValues = (Set) dstProps.get(dstProp);			if (dstValues == null) {				dstValues = Collections.EMPTY_SET;			}			for (Iterator valueIter = srcValues.iterator(); valueIter.hasNext();) {				OWLIndividual object = (OWLIndividual) valueIter.next();				OWLIndividual dstObject;				OWLIndividual tgtInd;				if (object.isAnonymous()) {					dstObject = destination.getOWLDataFactory().getAnonOWLIndividual(object.getAnonId());					tgtInd = factory.getAnonOWLIndividual(object.getAnonId());				} else {					dstObject = destination.getOWLDataFactory().getOWLIndividual(object.getURI());					tgtInd = factory.getOWLIndividual(object.getURI());				}				if (!dstValues.contains(dstObject)) {					changes.add(new RemoveObjectPropertyInstance(target,							tgtEntity, tgtProp, tgtInd, null));				}			}		}									}	public void visit(OWLInverseFunctionalPropertyAxiom axiom) throws OWLException {		if (!destination.getPropertyAxioms().contains(axiom)) {			OWLObjectProperty tgtProp = (OWLObjectProperty) copier.copy(axiom.getProperty());			OWLPropertyAxiom tgtAxiom = factory.getOWLInverseFunctionalPropertyAxiom(tgtProp);			changes.add(new RemovePropertyAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLInversePropertyAxiom axiom) throws OWLException {		if (!destination.getPropertyAxioms().contains(axiom)) {			OWLObjectProperty tgtProp = (OWLObjectProperty) copier.copy(axiom.getProperty());			OWLObjectProperty tgtInverse = (OWLObjectProperty) copier.copy(axiom.getInverseProperty());			OWLPropertyAxiom tgtAxiom = factory.getOWLInversePropertyAxiom(tgtProp, tgtInverse);			changes.add(new RemovePropertyAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLObjectProperty entity) throws OWLException {		OWLObjectProperty tgtEntity = factory.getOWLObjectProperty(entity.getURI());		OWLObjectProperty dstEntity = destination.getObjectProperty(entity.getURI());				if (dstEntity == null) {			changes.add(new RemoveEntity(target, tgtEntity, null));			dstEntity = destination.getOWLDataFactory().getOWLObjectProperty(entity.getURI());		}		genericPropertyChanges(entity, dstEntity, tgtEntity);				if (entity.isInverseFunctional(source) && !dstEntity.isInverseFunctional(destination)) {			changes.add(new SetInverseFunctional(target, tgtEntity, false, null));		}		if (entity.isSymmetric(source) && !dstEntity.isSymmetric(destination)) {			changes.add(new SetSymmetric(target, tgtEntity, false, null));		}		if (entity.isTransitive(source) && !dstEntity.isTransitive(destination)) {			changes.add(new SetTransitive(target, tgtEntity, false, null));		}		if (entity.isOneToOne(source) && !dstEntity.isOneToOne(destination)) {			changes.add(new SetOneToOne(target, tgtEntity, false, null));		}				for (Iterator iter = entity.getRanges(source).iterator(); iter.hasNext(); ) {			OWLDescription desc = (OWLDescription) iter.next();			if (!dstEntity.getRanges(destination).contains(desc)) {				OWLDescription tgtDesc = copier.copy(desc);				changes.add(new RemoveObjectPropertyRange(target, tgtEntity, tgtDesc, null));			}		}			}	public void visit(OWLObjectPropertyRangeAxiom axiom) throws OWLException {		if (!destination.getPropertyAxioms().contains(axiom)) {			OWLObjectProperty tgtProperty = (OWLObjectProperty) copier.copy(axiom.getProperty());			OWLDescription tgtRange = copier.copy(axiom.getRange());			OWLPropertyAxiom tgtAxiom = factory.getOWLObjectPropertyRangeAxiom(tgtProperty, tgtRange);			changes.add(new RemovePropertyAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLPropertyDomainAxiom axiom) throws OWLException {		if (!destination.getPropertyAxioms().contains(axiom)) {			OWLProperty tgtProperty = (OWLProperty) copier.copy(axiom.getProperty());			OWLDescription tgtDomain = copier.copy(axiom.getDomain());			OWLPropertyAxiom tgtAxiom = factory.getOWLPropertyDomainAxiom(tgtProperty, tgtDomain);			changes.add(new RemovePropertyAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLSameIndividualsAxiom axiom) throws OWLException {		if (!destination.getIndividualAxioms().contains(axiom)) {			Set equivalents = new HashSet();			for (Iterator iter = axiom.getIndividuals().iterator(); iter.hasNext(); ) {				equivalents.add(copier.copy((OWLIndividual)iter.next()));			}			OWLIndividualAxiom tgtAxiom = factory.getOWLSameIndividualsAxiom(equivalents);			changes.add(new RemoveIndividualAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLSubClassAxiom axiom) throws OWLException {		if (!destination.getClassAxioms().contains(axiom)) {			OWLDescription subClass = copier.copy(axiom.getSubClass());			OWLDescription superClass = copier.copy(axiom.getSuperClass());			OWLClassAxiom tgtAxiom = factory.getOWLSubClassAxiom(subClass, superClass);			changes.add(new RemoveClassAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLSubPropertyAxiom axiom) throws OWLException {		if (!destination.getPropertyAxioms().contains(axiom)) {			OWLProperty subProp = (OWLProperty) copier.copy(axiom.getSubProperty());			OWLProperty superProp = (OWLProperty) copier.copy(axiom.getSuperProperty());			OWLPropertyAxiom tgtAxiom = factory.getOWLSubPropertyAxiom(subProp, superProp);					changes.add(new RemovePropertyAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLSymmetricPropertyAxiom axiom) throws OWLException {		if (!destination.getPropertyAxioms().contains(axiom)) {			OWLObjectProperty tgtProp = (OWLObjectProperty) copier.copy(axiom.getProperty());			OWLPropertyAxiom tgtAxiom = factory.getOWLSymmetricPropertyAxiom(tgtProp);			changes.add(new RemovePropertyAxiom(target, tgtAxiom, null));		}	}	public void visit(OWLTransitivePropertyAxiom axiom) throws OWLException {		if (!destination.getPropertyAxioms().contains(axiom)) {			OWLObjectProperty tgtProp = (OWLObjectProperty) copier.copy(axiom.getProperty());			OWLPropertyAxiom tgtAxiom = factory.getOWLTransitivePropertyAxiom(tgtProp);			changes.add(new RemovePropertyAxiom(target, tgtAxiom, null));		}	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?