01: package org.ontoware.rdf2go.model.impl;
02:
03: import org.ontoware.rdf2go.exception.ModelRuntimeException;
04: import org.ontoware.rdf2go.model.Model;
05: import org.ontoware.rdf2go.model.Statement;
06: import org.slf4j.Logger;
07: import org.slf4j.LoggerFactory;
08:
09: /**
10: * This is an abstract class which provides quick & dirty implementations to get
11: * an adapter started quickly. Do not use this code in production environments.
12: *
13: * @author voelkel
14: *
15: */
16: public abstract class DirtyAbstractModel extends AbstractModel {
17:
18: private static Logger log = LoggerFactory
19: .getLogger(DirtyAbstractModel.class);
20:
21: /**
22: * Adapter implementations are strongly encouraged to overwrite this method.
23: * It is slow and semantically not correct.
24: */
25: public boolean isomorphicWith(Model other) {
26: assertModel();
27: try {
28: if (other instanceof AbstractModel) {
29: AbstractModel abstractModel = (AbstractModel) other;
30: if (size() == abstractModel.size()) {
31:
32: for (Statement s : this ) {
33: if (!abstractModel.contains(s)) {
34: log.debug("Other model does not contain "
35: + s);
36: return false;
37: }
38: }
39: return true;
40: }
41: //else
42: log.debug("Models do not have the same size");
43: return false;
44:
45: }
46: //else
47: log
48: .debug("object is not an instance of ModelAdapter, it's "
49: + other.getClass());
50: return false;
51: } catch (ModelRuntimeException e) {
52: throw new RuntimeException(e);
53: }
54: }
55:
56: /**
57: * You should overrride this method!
58: */
59: public boolean isValidURI(@SuppressWarnings("unused")
60: String uriString) {
61: log
62: .warn("You used method isValidURI() from DirtyAbstractModel, which always returns TRUE");
63: return true;
64: }
65:
66: }
|