NAME

RDF::Base::Object

DESCRIPTION

Base class for RDF::Base::List and RDF::Base::Node.

These holds common methods. For getting specific types of presentations of the object. There are quite a lot of them for getting the value of an object.

General syntax

See the respektive method for examples. The respective method usually starts with a $pred argument followed by a \%props or \@values argument. We will describe the syntax based on the method $n->list( $pred, @propargs ).

$value is anything that's not a hash- or arrayref and that's the only (true) argument. It will return those nodes/arcs with a matching value. For /list, it will return the value of the node $n property $pred that equals $value. That value may have to be converted to the right object type before a vomparsion.

\@values matches any value of the list. For example, $n>list($pred, [$alt1, $alt2]) will return a list with zero or more of the nodes $alt1 and $alt2 depending on if $n has those properties with pred $pred.

\%props holds key/value pairs of properties that the matches should have. RDF::Base::List/find is used to filter out the nodes/arcs having those properties. For example, $n->list('part_of', { name => 'Turk' } will give you the nodes that $n are part_of that has the name Turk.

\%args holds any extra arguments to the method as name/value pairs. The arclim argument is always parsed and converted to a RDF::Base::Arc::Lim object. This will modify the args variable in cases when arclim isn't already a valid object.

defined

  $o->defined

Returns true unless this is a RDF::Base::Undef.

is_true

  $o->is_true

Returns 1 if true and 0 if false.

is_list

  $o->is_list

Returns true if this is a RDF::Base::List.

is_pred

  $o->is_pred

Returns true is this is a RDF::Base::Pred.

is_arc

  $o->is_arc

Returns true if object is an RDF::Base::Arc.

is_resource

  $o->is_resource

Returns true if object is a Resource.

is_literal

  $o->is_literal

Returns true if object is a RDF::Base::Literal

is_node

  $o->is_node

Returns true if object is a Node.

is_value_node

  $o->is_value_node

Returns true if this is a Literal Resource (aka value node).

Literal Resources are nodes representing a Literal.

as_html

  $o->as_html( \%args )

Preformatted text should use <pre> to preserve indentation.

This default will only preserve linefeed.

Defaults to /desig

diff_as_html

  $o->diff_as_html( \%args )

Uses /desig as base for displaying diffrence

See String::ShowHTMLDiff

desig

  $o->desig()

A general alphanumerical presentation of the designation of the object. Intended for presentation and not for data manipulation.

longdesig

  $o->longdesig()

May give a longer name of the object. Defaults to /desig

shortdesig

  $o->shortdesig()

May give a longer name of the object. Defaults to /desig

safedesig

  $o->safedesig()

sysdesig

  $o->sysdesig()

The same as /desig but more suited for debugging. The alphanumerical string will include the object id number or corresponding extra info for identifying the object. Intended for presentation and not for data manipulation.

syskey

  $o->syskey

This will generate a unique alphanumerical string that cen be used for discriminating this object from all other objects. The alphanumerical code returned will usually include the type of object and the object id. Intended for data manipulation, such as caching.

loc

  $o->loc

  $o->loc(@args)

Similar to /desig, but will choose the most suitible name if there are more than one to choose from. It will pick a name based on language or priority.

Uses the args in Para::Frame::L10N/compile.

plain

  $o->plain

This method converts objects to plain perl datatypes. It will convert a Literal object to a perl string, an undef object to the undef value, etc.

See RDF::Base::Resource/plain et al.

clean

  $o->clean

Returns the clean version of the value as a Literal obj.

TODO: Only in Literal...

equals

  $obj1->equals( $obj2 )

Tests if two objects are the same object.

matches

  $n->matches( $value, \%args )

Supported args are:

  match

Default match is eq

%args must be specified

Supported matches are:

  eq
  ne
  gt
  lt
  begins
  like

Returns: true if $n $match $value

as_string

  $o->as_string

Not used. Please be more specific. What kind of string?

size

empty

  $n->empty()

Returns true if this node has no properties.

Returns: 1

get_first

  $o->get_first()

Gets the first value from a list, or the value itselft if it's not a list.

May return a second value with a error status code if the list is empty. See /get_first_nos.

get_first_nos

  $o->get_first_nos()

Gets the first value from a list, or the value itselft if it's not a list. Does not return a status code (get first with no status).

uniq

  $o->uniq()

sum

  $o->sum()

join

  $o->join()

as_list

  $o->as_list()

Returns a referens to a list. Not a List object. The list content are materialized. Compatible with Para::Frame::List/as_list

flatten

  $o->flatten()

as_listobj

  $o->as_listobj()

Returns a RDF::Base::List

list_class

  $class->list_class

This will return which subclass of RDF::Base::List to use for lits of nodes blessed into this class.

Example:

  $pred->valtype->instance_class->list_class->new(\@nodes)

as_array

  $literal->as_array()

as_arrayref

  $literal->as_arrayref()

nodes

  $literal->nodes()

Just as as_list but regards the SCALAR/ARRAY context.

this_coltype

Returns: The coltype of the node

Must be implemented in a subclass

meets_proplim

  $obj->meets_proplim( $proplim, \%args )

Implements ne and exist => 0, otherwise false if proplim is defined and has content. This is re-implemented for RDF::Base::Resource.

TODO: Generalize this

has_value

  $literal->has_value( ... )

Returns: false

sorted

  $n->sorted

This is not a list. Just give back the object!

Returns:

$n

has_pred

  $literal->has_pred( ... )

Returns: false

has_allowed

  $obj->has_allowed( $u, $access )

Should be subclassed by classes giving access to users

Returns: false

contains_any_of

  $obj->contains_any_of( $node, \%args )

  $obj->contains_any_of( $list, \%args )

See RDF::Base::List::contains_any_of

Only checks this single object.

sort_arg

  $obj->sort_arg

Returns: an array ref of sortargs for the latest sorting on for the item

random

  $obj->random

Stores the number in memory until next reset. The point of this is to keep the given order between reordering and page flipping of search results.

Returns: an random number between 1 and 99

per_node

  $obj->per_node( \%props, \%args )

Calls methods on nodes given by id. Example:

  $obj->per_node( { 123 => { add => { is => 124 } } }, \%args )

This will get node with id 123 and call $node->add( { is => 124 }, $args );

Returns: true if all methods returned true

SEE ALSO

RDF::Base, RDF::Base::Node, RDF::Base::Arc, RDF::Base::Pred, RDF::Base::Search