/** * Test if an attribute is contained in the attribute set. * @param attr The attribute. * @return True, if contained. */ public boolean contains(OAVAttributeType attr) { boolean ret = attributes==null? false: attributes.contains(attr); if(!ret && alltypes!=null && attr.getObjectType() instanceof OAVJavaType) { ret = alltypes.contains(attr.getObjectType()); if(!ret) { OAVJavaType attrtype = (OAVJavaType)attr.getObjectType(); for(Iterator it=alltypes.iterator(); it.hasNext() && !ret; ) { OAVJavaType type = (OAVJavaType)it.next(); ret = attrtype.isSubtype(type); } } } // todo: build up negative list for already tested java types to improve performance. return ret; }
/** * Test if an attribute is contained in the attribute set. * @param attr The attribute. * @return True, if contained. */ public boolean contains(OAVAttributeType attr) { boolean ret = attributes==null? false: attributes.contains(attr); if(!ret && alltypes!=null && attr.getObjectType() instanceof OAVJavaType) { ret = alltypes.contains(attr.getObjectType()); if(!ret) { OAVJavaType attrtype = (OAVJavaType)attr.getObjectType(); for(Iterator it=alltypes.iterator(); it.hasNext() && !ret; ) { OAVJavaType type = (OAVJavaType)it.next(); ret = attrtype.isSubtype(type); } } } // todo: build up negative list for already tested java types to improve performance. return ret; }
/** * Check if it is allowed to set or add an attribute value. * For this purpose it is checked if the value is either * a) a ObjectId -> type check via OAVObjectType * b) a normal Java object -> type check via OAVJavaType * Additionally multiplicity is checked. * @throws RuntimeException if value is not allowed. */ protected boolean checkValueCompatibility(Object object, OAVAttributeType attribute, Object value) { if(value!=null) { OAVObjectType atype = attribute.getType(); if(atype instanceof OAVJavaType) { if(!tmodel.getJavaType(value.getClass()).isSubtype(atype)) throw new RuntimeException("Value not of suitable type: "+object+" "+attribute+" "+value); } else if(!getType(value).isSubtype(atype)) { throw new RuntimeException("Value not of suitable type: "+object+" "+attribute+" "+value); } } return true; }
/** * Check if it is allowed to set or add an attribute value. * For this purpose it is checked if the value is either * a) a ObjectId -> type check via OAVObjectType * b) a normal Java object -> type check via OAVJavaType * Additionally multiplicity is checked. * @throws RuntimeException if value is not allowed. */ protected boolean checkValueCompatibility(Object object, OAVAttributeType attribute, Object value) { if(value!=null) { OAVObjectType atype = attribute.getType(); if(atype instanceof OAVJavaType) { if(!tmodel.getJavaType(value.getClass()).isSubtype(atype)) throw new RuntimeException("Value not of suitable type: "+object+" "+attribute+" "+value); } else if(!getType(value).isSubtype(atype)) { throw new RuntimeException("Value not of suitable type: "+object+" "+attribute+" "+value); } } return true; }
/** * Check if it is allowed to set or add an attribute value. * For this purpose it is checked if the value is either * a) a ObjectId -> type check via OAVObjectType * b) a normal Java object -> type check via OAVJavaType * Additionally multiplicity is checked. * @throws RuntimeException if value is not allowed. */ protected boolean checkValueCompatibility(Object id, OAVAttributeType attribute, Object value) { // #ifndef MIDP assert nocheck || generator.isId(id); // #endif if(value!=null) { OAVObjectType atype = attribute.getType(); if(atype instanceof OAVJavaType) { if(!tmodel.getJavaType(value.getClass()).isSubtype(atype)) throw new RuntimeException("Value not of suitable type: "+id+" "+attribute+" "+value); } else if(!getType(value).isSubtype(atype)) { throw new RuntimeException("Value not of suitable type: "+id+" "+attribute+" "+value); } } return true; }
/** * Check if it is allowed to set or add an attribute value. * For this purpose it is checked if the value is either * a) a ObjectId -> type check via OAVObjectType * b) a normal Java object -> type check via OAVJavaType * Additionally multiplicity is checked. * @throws RuntimeException if value is not allowed. */ protected boolean checkValueCompatibility(Object id, OAVAttributeType attribute, Object value) { // #ifndef MIDP assert nocheck || generator.isId(id); // #endif if(value!=null) { OAVObjectType atype = attribute.getType(); if(atype instanceof OAVJavaType) { if(!tmodel.getJavaType(value.getClass()).isSubtype(atype)) throw new RuntimeException("Value not of suitable type: "+id+" "+attribute+" "+value); } else if(!getType(value).isSubtype(atype)) { throw new RuntimeException("Value not of suitable type: "+id+" "+attribute+" "+value); } } return true; }