public void unregisterListener(ThingListener listener) { if (!(listener instanceof CuisineCodeListener)) throw new IllegalArgumentException("ThingListener must be instance of CuisineCodeListener"); if (listeners == null) return; if (this.listeners.contains(listener)) { listeners.remove(listener); } }
public void addedStatement(com.hp.hpl.jena.rdf.model.Statement stmt) { if (stmt.getPredicate().equals(hasContextProperty)) { if (!stmt.getObject().canAs(com.hp.hpl.jena.rdf.model.Resource.class)) return; com.hp.hpl.jena.rdf.model.Resource resource = (com.hp.hpl.jena.rdf.model.Resource) stmt.getObject().as(com.hp.hpl.jena.rdf.model.Resource.class); hasContext = null; if (true) { // don't check resource type if the property range is Resource try { hasContext = ibspan.tss.um.ontology.UserModellingFactory.getUserBehaviourContext(resource, _model); } catch (JastorException e) { // e.printStackTrace(); } } if (listeners != null) { java.util.ArrayList consumers; synchronized (listeners) { consumers = (java.util.ArrayList) listeners.clone(); } for (java.util.Iterator iter = consumers.iterator(); iter.hasNext(); ) { ExtendedUserBehaviourListener listener = (ExtendedUserBehaviourListener) iter.next(); listener.hasContextChanged(ibspan.tss.um.ontology.ExtendedUserBehaviourImpl.this); } } return; } if (stmt.getPredicate().equals(hasUserBehaviourProperty)) { if (!stmt.getObject().canAs(com.hp.hpl.jena.rdf.model.Resource.class)) return; com.hp.hpl.jena.rdf.model.Resource resource = (com.hp.hpl.jena.rdf.model.Resource) stmt.getObject().as(com.hp.hpl.jena.rdf.model.Resource.class); hasUserBehaviour = null; if (true) { // don't check resource type if the property range is Resource try { hasUserBehaviour = ibspan.tss.um.ontology.UserModellingFactory.getUserBehaviour(resource, _model); } catch (JastorException e) { // e.printStackTrace(); } } if (listeners != null) { java.util.ArrayList consumers; synchronized (listeners) { consumers = (java.util.ArrayList) listeners.clone(); } for (java.util.Iterator iter = consumers.iterator(); iter.hasNext(); ) { ExtendedUserBehaviourListener listener = (ExtendedUserBehaviourListener) iter.next(); listener.hasUserBehaviourChanged(ibspan.tss.um.ontology.ExtendedUserBehaviourImpl.this); } } return; } }
public void removedStatement(com.hp.hpl.jena.rdf.model.Statement stmt) { // if (!stmt.getSubject().equals(_resource)) // return; if (stmt.getPredicate().equals(hasContextProperty)) { if (!stmt.getObject().canAs(com.hp.hpl.jena.rdf.model.Resource.class)) return; com.hp.hpl.jena.rdf.model.Resource resource = (com.hp.hpl.jena.rdf.model.Resource) stmt.getObject().as(com.hp.hpl.jena.rdf.model.Resource.class); if (hasContext != null && hasContext.resource().equals(resource)) hasContext = null; if (listeners != null) { java.util.ArrayList consumers; synchronized (listeners) { consumers = (java.util.ArrayList) listeners.clone(); } for (java.util.Iterator iter = consumers.iterator(); iter.hasNext(); ) { ExtendedUserBehaviourListener listener = (ExtendedUserBehaviourListener) iter.next(); listener.hasContextChanged(ibspan.tss.um.ontology.ExtendedUserBehaviourImpl.this); } } return; } if (stmt.getPredicate().equals(hasUserBehaviourProperty)) { if (!stmt.getObject().canAs(com.hp.hpl.jena.rdf.model.Resource.class)) return; com.hp.hpl.jena.rdf.model.Resource resource = (com.hp.hpl.jena.rdf.model.Resource) stmt.getObject().as(com.hp.hpl.jena.rdf.model.Resource.class); if (hasUserBehaviour != null && hasUserBehaviour.resource().equals(resource)) hasUserBehaviour = null; if (listeners != null) { java.util.ArrayList consumers; synchronized (listeners) { consumers = (java.util.ArrayList) listeners.clone(); } for (java.util.Iterator iter = consumers.iterator(); iter.hasNext(); ) { ExtendedUserBehaviourListener listener = (ExtendedUserBehaviourListener) iter.next(); listener.hasUserBehaviourChanged(ibspan.tss.um.ontology.ExtendedUserBehaviourImpl.this); } } return; } }