Beispiel #1
0
 /**
  * A variable can be put whereever a term of whatever type is required --> A VariableSchema is
  * compatible with s if s descends from TermSchema.getBaseSchema()
  */
 public boolean isCompatibleWith(ObjectSchema s) {
   if (s != null) {
     return s.descendsFrom(TermSchema.getBaseSchema());
   } else {
     return false;
   }
 }
Beispiel #2
0
 /**
  * Return true if - s is the base schema for the XXXSchema class this schema is an instance of
  * (e.g. s is ConceptSchema.getBaseSchema() and this schema is an instance of ConceptSchema) - s
  * is the base schema for a super-class of the XXXSchema class this schema is an instance of (e.g.
  * s is TermSchema.getBaseSchema() and this schema is an instance of ConceptSchema)
  */
 protected boolean descendsFrom(ObjectSchema s) {
   if (s != null) {
     if (s.equals(getBaseSchema())) {
       return true;
     }
     return super.descendsFrom(s);
   } else {
     return false;
   }
 }
  public AbsObject externalizeSpecialType(
      Object obj, ObjectSchema schema, Class javaClass, Ontology referenceOnto)
      throws OntologyException {
    try {
      AbsObject abs = schema.newInstance();

      Introspectable intro = (Introspectable) obj;
      intro.externalise(abs, referenceOnto);
      return abs;
    } catch (OntologyException oe) {
      // Just forward the exception
      throw oe;
    } catch (ClassCastException cce) {
      throw new OntologyException("Object " + obj + " is not Introspectable");
    } catch (Throwable t) {
      throw new OntologyException("Schema and Java class do not match", t);
    }
  }