Class Index | File Index

## Classes

- Environment
- InitializationError
- JSONInstance
- JSONSchema
- JSV
- Report
- ValidationError

# Class JSONInstance

Defined in: jsv.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| JSONInstance(env, json, uri, fd) A wrapper class for binding an Environment, URI and helper methods to an instance.

Method Summary
Method Attributes | Method Name and Description
--- | ---
| equals(instance) Return if the provided value is the same as the value of the instance.
| getEnvironment() Returns the environment the instance is bound to.
| getProperties() Returns all the property instances of the target instance.
| getProperty(key) Returns a JSONInstance of the value of the provided property name.
| getPropertyNames() Returns an array of the names of all the properties.
| getType() Returns the name of the type of the instance.
| getURI() Returns the URI of the instance.
| getValue() Returns the JSON value of the instance.
| getValueOfProperty(key) Returns the JSON value of the provided property name.
| resolveURI(uri) Returns a resolved URI of a provided relative URI against the URI of the instance.

Class Detail
JSONInstance(env, json, uri, fd)
A wrapper class for binding an Environment, URI and helper methods to an instance. This class is most commonly instantiated with Environment#createInstance.

Parameters:
{Environment} env
  The environment this instance belongs to
{JSONInstance|Any} json
  The value of the instance
{String} uri Optional
  The URI of the instance. If undefined, the URI will be a randomly generated UUID.
{String} fd Optional
  The fragment delimiter for properties. If undefined, uses the environment default.

Method Detail
{Boolean} equals(instance)
Return if the provided value is the same as the value of the instance.

Parameters:
{JSONInstance|Any} instance
  The value to compare

Returns:
  {Boolean} If both the instance and the value match

{Environment} getEnvironment()
Returns the environment the instance is bound to.

Returns:
  {Environment} The environment of the instance

{Object|Array|undefined} getProperties()
Returns all the property instances of the target instance.

If the target instance is an Object, then the method will return a hash table of JSONInstances of all the properties. If the target instance is an Array, then the method will return an array of JSONInstances of all the items.

Returns:
  {Object|Array|undefined} The list of instances for all the properties

{JSONInstance} getProperty(key)
Returns a JSONInstance of the value of the provided property name.

Parameters:
{String} key
  The name of the property to fetch

Returns:
  {JSONInstance} The instance of the property value

{Array} getPropertyNames()
Returns an array of the names of all the properties.

Returns:
  {Array} An array of strings which are the names of all the properties

{String} getType()
Returns the name of the type of the instance.

Returns:
  {String} The name of the type of the instance

{String} getURI()
Returns the URI of the instance.

Returns:
  {String} The URI of the instance

{Any} getValue()
Returns the JSON value of the instance.

Returns:
  {Any} The actual JavaScript value of the instance

{Any} getValueOfProperty(key)
Returns the JSON value of the provided property name. This method is a faster version of calling `instance.getProperty(key).getValue()`.

Parameters:
{String} key
  The name of the property

Returns:
  {Any} The JavaScript value of the instance

See:
  JSONInstance#getProperty
  JSONInstance#getValue

{String} resolveURI(uri)
Returns a resolved URI of a provided relative URI against the URI of the instance.

Parameters:
{String} uri
  The relative URI to resolve

Returns:
  {String} The resolved URI

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Sep 14 2011 18:53:24 GMT-0600 (MDT)