Class Index | File Index

## Classes

- _global_
- jQuery
- jQuery.rdf
- jQuery.rdf.blank
- jQuery.rdf.databank
- jQuery.rdf.literal
- jQuery.rdf.pattern
- jQuery.rdf.resource
- jQuery.rdf.rule
- jQuery.rdf.ruleset
- jQuery.rdf.triple
- jQuery.typedValue
- jQuery.uri

# Class jQuery.rdf.pattern

Represents a pattern that may or may not match a given jQuery.rdf.triple.
Defined in: jquery.rdf.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| jQuery.rdf.pattern(subject, property, value, options) Creates a new jQuery.rdf.pattern object.

Field Summary
Field Attributes | Field Name and Description
--- | ---
| object The placeholder for the object of triples matching against this pattern.
| optional Whether the pattern should only optionally match against the triple
| property The placeholder for the property of triples matching against this pattern.
| subject The placeholder for the subject of triples matching against this pattern.

Method Summary
Method Attributes | Method Name and Description
--- | ---
| exec(triple) Creates a new Object holding variable bindings by matching the passed triple against this pattern.
| fill(bindings) Creates a new jQuery.rdf.pattern with any variable placeholders within this one's subject, property or object filled in with values from the bindings passed as the argument.
| isFixed() Tests whether this pattern has any variable placeholders in it or not.
| toString() Returns a string representation of the pattern by concatenating the subject, property and object.
| triple(bindings) Creates a new triple based on the bindings passed to the pattern, if possible.

Class Detail
jQuery.rdf.pattern(subject, property, value, options)

Creates a new jQuery.rdf.pattern object. This should be invoked as a method rather than constructed using new; indeed you will not usually want to generate these objects directly, since they are automatically created from strings where necessary, such as by jQuery.rdf#where.

    pattern = $.rdf.pattern('?person', $.rdf.type, 'foaf:Person', { namespaces: { foaf: "http://xmlns.com/foaf/0.1/" }});

    pattern = $.rdf.pattern('?person a foaf:Person', {
      namespaces: { foaf: "http://xmlns.com/foaf/0.1/" },
      optional: true
    });

Parameters:
{String|jQuery.rdf.resource|jQuery.rdf.blank} subject
  The subject pattern, or a single string that defines the entire pattern. If the subject is specified as a string, it can be a fixed resource (`<uri>` or `curie`), a blank node (`_:id`) or a variable placeholder (`?name`).
{String|jQuery.rdf.resource} property Optional
  The property pattern. If the property is specified as a string, it can be a fixed resource (`<uri>` or `curie`) or a variable placeholder (`?name`).
{String|jQuery.rdf.resource|jQuery.rdf.blank|jQuery.rdf.literal} value Optional
  The value pattern. If the property is specified as a string, it can be a fixed resource (`<uri>` or `curie`), a blank node (`_:id`), a literal (`"value"`) or a variable placeholder (`?name`).
{Object} options Optional
  Initialisation of the pattern.
{Object} options.namespaces Optional
  An object representing a set of namespace bindings used when interpreting the CURIEs in the subject, property and object.
{String|jQuery.uri} options.base Optional
  The base URI used to interpret any relative URIs used within the subject, property and object.
{boolean} options.optional Optional

Throws:
{String}
  Errors if any of the strings are not in a recognised format.

Returns:
  {jQuery.rdf.pattern} The newly-created pattern.

See:
  jQuery.rdf#where
  jQuery.rdf.resource
  jQuery.rdf.blank
  jQuery.rdf.literal

Field Detail
{String|jQuery.rdf.resource|jQuery.rdf.blank|jQuery.rdf.literal} object
The placeholder for the object of triples matching against this pattern.

{boolean} optional
Whether the pattern should only optionally match against the triple

{String|jQuery.rdf.resource} property
The placeholder for the property of triples matching against this pattern.

{String|jQuery.rdf.resource|jQuery.rdf.blank} subject
The placeholder for the subject of triples matching against this pattern.
Method Detail
{null|Object} exec(triple)
Creates a new Object holding variable bindings by matching the passed triple against this pattern.

Parameters:
{jQuery.rdf.triple} triple
  A jQuery.rdf.triple for this pattern to match against.

Returns:
  {null|Object} An object containing the bindings of variables (as specified in this pattern) to values (as specified in the triple), or `null` if the triple doesn't match the pattern. pattern = $.rdf.pattern('?thing a ?class'); bindings = pattern.exec($.rdf.triple('<> a foaf:Person', { namespaces: ns })); thing = bindings.thing; // the resource for this page class = bindings.class; // a resource for foaf:Person

{jQuery.rdf.pattern} fill(bindings)
Creates a new jQuery.rdf.pattern with any variable placeholders within this one's subject, property or object filled in with values from the bindings passed as the argument.

    pattern = $.rdf.pattern('?thing a ?class');
    // pattern2 matches all triples that indicate the classes of this page.
    pattern2 = pattern.fill({ thing: $.rdf.resource('<>') });

Parameters:
{Object} bindings
  An object holding the variable bindings to be used to replace any placeholders in the pattern. These bindings are of the type held by the jQuery.rdf object.

Returns:
  {jQuery.rdf.pattern} A new jQuery.rdf.pattern object.

{boolean} isFixed()
Tests whether this pattern has any variable placeholders in it or not.

    $.rdf.pattern('?thing a ?class').isFixed(); // false
    $.rdf.pattern('<> a foaf:Person', { namespaces: ns }).isFixed(); // true

Returns:
  {boolean} True if the pattern doesn't contain any variable placeholders.

{String} toString()
Returns a string representation of the pattern by concatenating the subject, property and object.

Returns:
  {String}

{null|jQuery.rdf.triple} triple(bindings)
Creates a new triple based on the bindings passed to the pattern, if possible.

    pattern = $.rdf.pattern('?thing a ?class');
    // triple is a new triple '<> a foaf:Person'
    triple = pattern.triple({
      thing: $.rdf.resource('<>'),
      class: $.rdf.resource('foaf:Person', { namespaces: ns })
    });

Parameters:
{Object} bindings
  An object holding the variable bindings to be used to replace any placeholders in the pattern. These bindings are of the type held by the jQuery.rdf object.

Returns:
  {null|jQuery.rdf.triple} A new jQuery.rdf.triple object, or null if not all the variable placeholders in the pattern are specified in the bindings. The jQuery.rdf.triple#source of the generated triple is set to the string value of this pattern.

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Feb 04 2011 16:40:11 GMT+0100 (MEZ)