                 message: 'is unknown'
               break if aOptions.raiseError
     result
-  # can wrap a common object to an ObjectValue.
+  # can wrap a common json object to an ObjectValue.
+  # Note: it will replace the prototype to the ObjectValue Class directly.
   wrapValue:(aObjectValue)->
     if isObject aObjectValue
       if not (aObjectValue instanceof ObjectValue)

      type: 'Object'
      assigned: '$_attributes' # this should define the non-enumerable `$_attributes` property.
      assign: (value, dest, src, key)->
        if dest and dest.defineAttributes
          result = dest.defineAttributes(value)
        else
          result = value
        result
    $_attributes:
      value:{}
    strict:
      type: 'Boolean'

  @defaultType: Type('String')
  ###
    aOptions *(string)*: the type name.
    aOptions *(AttributeType)*
    aOptions *(Type)*: the type of this attribute.
    aOptions *(object)*:
      required: Boolean
      type: ...
  ###
  defineAttribute: (aName, aOptions, aAttributes)->
    unless aName and aName.length
      throw TypeError('defineAttribute has no attribute name')
    aAttributes = @attributes unless aAttributes?
    if aAttributes[aName]?
      throw TypeError('the attribute "' + aName + '" has already defined.')
    if isString aOptions
      vType = Type(aOptions)
      throw TypeError("no such type registered:"+aOptions) unless vType
      aOptions = {}
      aOptions.type = vType
    else if aOptions instanceof AttributeType
      vAttribute = aOptions
    else if aOptions instanceof Type
      aOptions = {type: aOptions}
    else if aOptions?
      if aOptions.type
        vType = aOptions.type
        vType = Type(vType) #if isString vType
        throw TypeError('no such type registered:'+aOptions.type) unless vType
        vType = vType.clone(aOptions) unless vType.isSame(aOptions)
        aOptions.type = vType
      else if ObjectType.defaultType
        aOptions.type = ObjectType.defaultType
    unless vAttribute
      aOptions = aOptions || {}
      aOptions.name = aName
      vAttribute = createObject AttributeType, aName, aOptions
    aAttributes[aName] = vAttribute

  ###
    attributes =
      attrName:
        required: true
        type: 'string'
  ###
  defineAttributes: (aAttributes)->
    if not isEmptyObject(aAttributes) #avoid to recusive
      result = {}
      for k,v of aAttributes
        continue if not k? or not v?
        @defineAttribute k, v, result
    return result

  _toObject:(aOptions, aNameRequired)->
    result = super
    result.attributes = vAttrs = {}
    #   delete aOptions.name
    for k,v of @attributes
      vAttrs[k] = t = v.toObject(null, false)
      #delete t[NAME]
      vAttrs[k] = t.type if getObjectKeys(t).length is 1

  #TODO: maybe should use Attributes class and put this method into it.
  attrKeys: ->
    result = []
    for k,v of @attributes.value()
      result.push v.name || k if v.enumerable isnt false
    result
  attrOwnPropertyNames: ->
    result = []
    for k,v of @attributes.value()
      result.push v.name
    result
  # Returns
