String tmpnamesin = tmptype.getName()+"_has_"+attrname; String tmpnameplu = tmptype.getName()+"_has_"+attrnameplu; attrtype = tmptype.getDeclaredAttributeType0(tmpnamesin); if(attrtype==null) attrtype = tmptype.getDeclaredAttributeType0(tmpnameplu); tmptype = tmptype.getSupertype();
/** * Create a new attribute type. * @param name The name. * @param type The type. * @param mult The multiplicity. * @param def The default value. */ public OAVAttributeType createAttributeType(String name, OAVObjectType type) { return createAttributeType(name, type, OAVAttributeType.NONE, null); }
/** * Test if two object are equal. * @param object The object to compare to. */ public boolean equals(Object object) { return object instanceof OAVInternalObjectId && this.id==((OAVInternalObjectId)object).id && this.type.equals(((OAVInternalObjectId)object).type); }
/** * Test if this type is same type or subtype of another type. * @param type The type to test. * @return True, if this object is same type or subtype. */ public boolean isSubtype(OAVObjectType type) { boolean ret = false; OAVObjectType tmp = this; while(tmp!=null && !ret) { if(type.equals(tmp)) ret = true; else tmp = tmp.getSupertype(); } return ret; }
/** * Get an attribute type description. * @param attribute The name of the attribute. * @return The OAV attribute type. */ public OAVAttributeType getAttributeType0(String attribute) { OAVAttributeType ret = (OAVAttributeType)(attributes!=null? attributes.get(attribute): null); if(ret==null) { OAVObjectType type = this.getSupertype(); while(ret==null && type!=null) { ret = type.getAttributeType0(attribute); type = type.getSupertype(); } } return ret; }
/** * Get the properties of an object. */ protected Collection getProperties(Object object, IContext context, boolean includemethods, boolean includefields) { Collection ret = new LinkedHashSet(); IOAVState state = (IOAVState)context; OAVObjectType type = state.getType(object); while(type!=null && !(type instanceof OAVJavaType)) { Collection props = type.getDeclaredAttributeTypes(); ret.addAll(props); type = type.getSupertype(); } return ret; }
/** * Create a string representation of this OAV object id. */ public String toString() { return type.getName()+"_"+id; }
/** * Get the set of matching type nodes for a (sub)type. * @param type The object type. * @return The set of type nodes for that object type. */ protected Set getTypeNodes(OAVObjectType type) { Set ret = (Set)typenodesets.get(type); if(ret==null) { synchronized(this) { ret = (Set)typenodesets.get(type); if(ret==null) { ret = new HashSet(); for(Iterator it=typenodes.values().iterator(); it.hasNext(); ) { TypeNode tnode = (TypeNode)it.next(); if(type.isSubtype(tnode.getObjectType())) ret.add(tnode); } typenodesets.put(type, ret); } } } return ret; }
OAVAttributeType attr = otype.getAttributeType(attrname); aret.add(new Object[]{attr, key}); otype = attr.getType(); OAVAttributeType attr = otype.getAttributeType(attrname); aret.add(attr); otype = attr.getType(); ret = otype.getAttributeType(slotname);
public String getObjectName(Object obj) { String name = null; if(state.getType(obj).isSubtype(OAVBDIMetaModel.modelelement_type)) { name = (String)state.getAttributeValue(obj, OAVBDIMetaModel.modelelement_has_name); } if(name==null && state.getType(obj).isSubtype(OAVBDIMetaModel.elementreference_type)) { name = (String)state.getAttributeValue(obj, OAVBDIMetaModel.elementreference_has_concrete); } if(name==null && state.getType(obj).isSubtype(OAVBDIMetaModel.expression_type)) { IParsedExpression exp =(IParsedExpression)state.getAttributeValue(obj, OAVBDIMetaModel.expression_has_parsed); String text = (String)state.getAttributeValue(obj, OAVBDIMetaModel.expression_has_text); name = exp!=null ? exp.getExpressionText() : text!=null ? text.trim() : null; } if(name==null) { name = ""+obj; } return obj instanceof String ? (String)obj : state.getType(obj).getName().substring(1) + " " + name; } }
public void objectAdded(Object id, OAVObjectType type, boolean root) { // Add the type and its supertypes (if not already contained). while(type!=null && types.add(type)) type = type.getSupertype(); }
/** * Create a new attribute type. * @param name The name. * @param type The type. * @param mult The multiplicity. * @param def The default value. */ public OAVAttributeType createAttributeType(String name, OAVObjectType type, String mult, Object def, OAVAttributeType idxattr) { if(!tmodel.contains(type)) throw new RuntimeException("Unknown object type: "+type); OAVAttributeType attr = new OAVAttributeType(this, name, type, mult, def, idxattr); addAttributeType(attr); return attr; }
/** * Get an attribute type description. * @param attribute The name of the attribute. * @return The OAV attribute type. */ public OAVAttributeType getAttributeType(String attribute) { OAVAttributeType ret = getAttributeType0(attribute); if(ret==null) throw new RuntimeException("Attribute not found: "+this+", "+attribute); return ret; }
/** * Create a type. * Creates a type that can be used to create objects. * @param name The type name. * @param supertype The supertype. * @return The type. */ public OAVObjectType createType(String name, OAVObjectType supertype) { OAVObjectType type = new OAVObjectType(name, supertype, this); if(contains(type)) throw new RuntimeException("Type already exists: "+name); types.put(name, type); return type; }
/** * Create a string representation of this OAV object id. */ public String toString() { return type.getName()+"_"+id; }
/** * Get the properties of an object. */ protected Collection getProperties(Object object, IContext context, boolean includemethods, boolean includefields) { Collection ret = new LinkedHashSet(); IOAVState state = (IOAVState)context; OAVObjectType type = state.getType(object); while(type!=null && !(type instanceof OAVJavaType)) { Collection props = type.getDeclaredAttributeTypes(); ret.addAll(props); type = type.getSupertype(); } return ret; }
/** * Get the set of matching type nodes for a (sub)type. * @param type The object type. * @return The set of type nodes for that object type. */ protected Set getTypeNodes(OAVObjectType type) { Set ret = (Set)typenodesets.get(type); if(ret==null) { synchronized(this) { ret = (Set)typenodesets.get(type); if(ret==null) { ret = new HashSet(); for(Iterator it=typenodes.values().iterator(); it.hasNext(); ) { TypeNode tnode = (TypeNode)it.next(); if(type.isSubtype(tnode.getObjectType())) ret.add(tnode); } typenodesets.put(type, ret); } } } return ret; }
/** * Test if this type is same type or subtype of another type. * @param type The type to test. * @return True, if this object is same type or subtype. */ public boolean isSubtype(OAVObjectType type) { boolean ret = false; OAVObjectType tmp = this; while(tmp!=null && !ret) { if(type.equals(tmp)) ret = true; else tmp = tmp.getSupertype(); } return ret; }