/**
  * 
  */
 public function __construct(MEntityDescription $entity, MString $name, MString $type)
 {
     parent::__construct($entity, $name);
     $this->type = $type;
     $this->to = MEntityDescriptionRelationship::ToOne;
     $this->inverseRelationship = null;
     $this->singular = null;
 }
 /**
  *
  */
 public function __construct(MEntityDescription $entity, MString $name)
 {
     parent::__construct($entity, $name);
     $this->type = MEntityDescriptionProperty::StringType;
     $this->defaultValue = null;
 }
 /**
  * Sets the object which represents the value for a certain attribute of this object
  *
  * Attributes are the properties and relationships of this object. This method sets
  * the object which represents the value of that attribute.
  *
  * You cannot use this method to set the value of a ToMany relationship, for that
  * you should use MManagedObject::addObjectToRelationship and
  * MManagedObject::removeObjectFromRelationship
  *
  * @see MManagedObject::addObjectToRelationship
  * @see MManagedObject::removeObjectFromRelationship
  *
  * @param MEntityDescriptionAttribute $attribute The attribute which you'd like to set
  * the value of
  * @param MObject $object The Object representing the value for that attribute
  *
  * @return void
  */
 public function setObjectForAttribute(MEntityDescriptionAttribute $attribute, MObject $object = null)
 {
     $this->fireFault();
     if ($attribute instanceof MEntityDescriptionProperty) {
         if ($object) {
             if ($attribute->type() == MEntityDescriptionProperty::StringType) {
                 if (!$object instanceof MString) {
                     throw new MInvalidManagedObjectOperationException($this, Sf("Invalid type [%s], expected [%s]!", str($object->className()), str(MString::className())));
                 }
             } else {
                 if ($attribute->type() == MEntityDescriptionProperty::IntegerType) {
                     if (!$object instanceof MNumber) {
                         throw new MInvalidManagedObjectOperationException($this, Sf("Invalid type [%s], expected [%s]!", str($object->className()), str(MNumber::className())));
                     }
                 } else {
                     if ($attribute->type() == MEntityDescriptionProperty::FloatType) {
                         if (!$object instanceof MNumber) {
                             throw new MInvalidManagedObjectOperationException($this, Sf("Invalid type [%s], expected [%s]!", str($object->className()), str(MNumber::className())));
                         }
                     } else {
                         if ($attribute->type() == MEntityDescriptionProperty::BooleanType) {
                             if (!$object instanceof MNumber) {
                                 throw new MInvalidManagedObjectOperationException($this, Sf("Invalid type [%s], expected [%s]!", str($object->className()), str(MNumber::className())));
                             }
                         } else {
                             if ($attribute->type() == MEntityDescriptionProperty::DateType) {
                                 if (!$object instanceof MDate) {
                                     throw new MInvalidManagedObjectOperationException($this, Sf("Invalid type [%s], expected [%s]!", str($object->className()), str(MDate::className())));
                                 }
                             } else {
                                 if ($attribute->type() == MEntityDescriptionProperty::BinaryType) {
                                     if (!$object instanceof MData) {
                                         throw new MInvalidManagedObjectOperationException($this, Sf("Invalid type [%s], expected [%s]!", str($object->className()), str(MData::className())));
                                     }
                                 } else {
                                     throw new MInvalidManagedObjectOperationException($this, Sf("Unsupported type [%s]!", $attribute->type()));
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $this->updatedData->setObjectForKey($attribute->name(), $object);
     } else {
         if ($attribute instanceof MEntityDescriptionRelationship) {
             if ($attribute->to() == MEntityDescriptionRelationship::ToMany) {
                 throw new MInvalidManagedObjectOperationException($this, S("Could not set a ToMany relationship, please use add/remove"));
             }
             if (($oldArr = $this->relationships->objectForKey($attribute->name())) != null) {
                 if ($oldArr->lastObject()) {
                     $this->removeObjectFromRelationship($attribute, $oldArr->lastObject());
                 }
             }
             $this->addObjectToRelationship($attribute, $object);
         } else {
             throw new MManagedObjectException($this, S("Unknown attribute type!"));
         }
     }
 }