RDF::Base::Object
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.
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.
$o->defined
Returns true unless this is a RDF::Base::Undef.
$o->is_true
Returns 1 if true and 0 if false.
$o->is_list
Returns true if this is a RDF::Base::List.
$o->is_pred
Returns true is this is a RDF::Base::Pred.
$o->is_arc
Returns true if object is an RDF::Base::Arc.
$o->is_resource
Returns true if object is a Resource.
$o->is_literal
Returns true if object is a RDF::Base::Literal
$o->is_node
Returns true if object is a Node.
$o->is_value_node
Returns true if this is a Literal Resource (aka value node).
Literal Resources are nodes representing a Literal.
$o->as_html( \%args )
Preformatted text should use <pre> to preserve indentation.
This default will only preserve linefeed.
Defaults to /desig
$o->diff_as_html( \%args )
Uses /desig as base for displaying diffrence
$o->desig()
A general alphanumerical presentation of the designation of the object. Intended for presentation and not for data manipulation.
$o->longdesig()
May give a longer name of the object. Defaults to /desig
$o->shortdesig()
May give a longer name of the object. Defaults to /desig
$o->safedesig()
$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.
$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.
$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.
$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.
$o->clean
Returns the clean version of the value as a Literal obj.
TODO: Only in Literal...
$obj1->equals( $obj2 )
Tests if two objects are the same object.
$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
$o->as_string
Not used. Please be more specific. What kind of string?
$n->empty()
Returns true if this node has no properties.
Returns: 1
$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.
$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).
$o->uniq()
$o->sum()
$o->join()
$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
$o->flatten()
$o->as_listobj()
Returns a RDF::Base::List
$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)
$literal->as_array()
$literal->as_arrayref()
$literal->nodes()
Just as as_list but regards the SCALAR/ARRAY context.
Returns: The coltype of the node
Must be implemented in a subclass
$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
$literal->has_value( ... )
Returns: false
$n->sorted
This is not a list. Just give back the object!
Returns:
$n
$literal->has_pred( ... )
Returns: false
$obj->has_allowed( $u, $access )
Should be subclassed by classes giving access to users
Returns: false
$obj->contains_any_of( $node, \%args ) $obj->contains_any_of( $list, \%args )
See RDF::Base::List::contains_any_of
Only checks this single object.
$obj->sort_arg
Returns: an array ref of sortargs for the latest sorting on for the item
$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
$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
RDF::Base, RDF::Base::Node, RDF::Base::Arc, RDF::Base::Pred, RDF::Base::Search