   @createFromJson: (aString)->
     Type.createFrom JSON.parse aString
 
+  ###
   encode: (aOptions)->
     aOptions = @mergeOptions(aOptions, null, true)
     aOptions.encoding.encode @toObject(aOptions)
   decode: (aEncoded, aOptions) ->
+    aOptions = aOptions.encoding.decode aEncoded
     aOptions = @mergeOptions(aOptions)
-    aOptions.encoding.decode aEncoded
-
+  ###
+
+  # Get(create) a global Type class or create new Value from the parametric type object.
+  # it will create a new type object if options is not the original(default) type options.
   @from: (aObject) ->
     result = Type aObject
     if aObject.value? and result

    aOptions.name = @name unless aOptions.name
    @createType aOptions
  clone: @::cloneType
  # Get a global Type class or create new Value from the json string.
  @fromJson: (aString)->
    #aString = JSON.parse aString
    Type.from JSON.parse(aString)

      aExclude = aExclude.concat getObjectKeys(aOptions)
    else
      aExclude = getObjectKeys(aOptions)
    aExclude.push 'name'

    if @$attributes
      @$attributes.assignTo(@, aOptions, aExclude, aSerialized)
      #aOptions.encoding = @encoding unless aOptions.encoding
    else
      extend aOptions, @, (key, value)->
        result = not aOptions.hasOwnProperty(key) and not (key in aExclude)
        if aSerialized
          result = result and key[0] isnt '$' and value isnt undefined
        result
    #delete aOptions.name
    aOptions
  _validate: (aValue, aOptions)->true
  error: (aMessage, aOptions)->
