Rit::Base::Literal
Represents a Literal.
A literal can only exist in one arc.
Rit::Base::Literal::String, Rit::Base::Literal::Time and Rit::Base::Undef are Literals.
Inherits from Rit::Base::Object.
The standard XML schema datatypes are described in http://www.w3.org/TR/xmlschema11-2/#built-in-datatypes
Supported args:
subj_new pred_new coltype valtype
121[122] 123 -name-> [124]"Apa" 125[126] 124 -is_of_language-> sv 127[122] 123 -name-> [124]"Bepa"
"Apa" isa Rit::Base::Literal [124] isa Rit::Base::Resource::Literal
$nlit = $R->get(124); $lit = $nlit->value('active'); $nlit = $lit->node; print $lit->plain; # Bepa
These can be called with the class name or any List object.
$class->new( \$val, $valtype )
Implement in subclasses!
Identifies the format and makes the apropriate literal object of it.
$this->new_from_db( $value, $valtype)
$n->get_by_arc_rec( $rec, $valtype )
This will allways re-init the literal object. It will usually be called from the arc holding the literal. The init or reinit of the arc should also reinit the literal. Thus, we will find the literal in the cache, but init with the rec, even if found.
Returns: a literal
Exceptions: see /init.
$node->reset_cache()
Does nothing here...
Returns value as Rit::Base::List
Just as /as_list but regards the SCALAR/ARRAY context.
$literal->lit_revarc
Return the arc this literal is a part of.
See /Rit::Base::Object/is_true
Should this theck the truthiness of the plain value?
Returns: 1 if plain value is true in perl boolean context
See /Rit::Base::Object/is_literal
$lit->node
$lit->set_arc( $arc )
Bind Literal to arc.
$lit->node_set $lit->node_set( $node )
Will create a node if not existing
Exceptions: If trying to explicitly set a node on a literal belonging to an arc
Returns: the node
$literal->equals( $val )
If $val
is a scalar, converts it to a Rit::Base::Literal::String
object. (Undefs will become a Rit::Base::Undef via
Rit::Base::Literal::String.)
Returns true if both are Rit::Base::Literal and has the same Rit::Base::Object/syskey.
syskey
is implemented in the subclasses to this class. For example,
Rit::Base::Literal::String, Rit::Base::Literal::Time and Rit::Base::Undef.
The API is the same as for Rit::Base::Resource/update.
The prop value
will update the literal. If the literal is not bound
to an arc, it may be updated to any type of literal or resource.
Supported args are teh same as for Rit::Base::Resource/find_by_anything.
Returns:
The value node created for representing the literal
Example:
$node->name->update({ is_of_language => $C_swedish });
$lit->this_valtype()
This is like the is
property for literals. Defaults to
/default_valtype.
See also: Rit::Base::Resource/this_valtype
$lit->this_valtype_reset()
For re-evaluating the valtype of the literal. This does nothing, since we needs to keep the given valtype. But the Resource equivalent does a re-evaluation.
Returns: -
See also: Rit::Base::Resource/this_valtype_reset
$lit->this_coltype()
This gives the coltype of the value of this literal.
returns: the plain string of table column name
See also: Rit::Base::Resource/this_coltype
$this->subj( \%args )
Get existing or planned subj
Supported args are:
arc subj_new
$this->pred( \%args )
Get existing or planned pred
Supported args are:
arc pred_new
$class->extract_string( \$val, \%args )
For use in /parse methods.
Supported args are: valtype coltype arclim
Thre $retval
will either be a scalar ref of the plain value to
parse, or a Rit::Base::Literal object.
Returns: The list ( $retval, $coltype, $valtype, $args )
Returns: the node id
$n->empty()
Returns true if the literal node has no properties.
Returns true if the literal is not coupled to a node.
Returns: boolean
NOTE: May have expected to get the 'value' arc. But we should not pretend to have one...
This will vaccum the value but NOT the value node.
Implemented in respective subclass.
Returns: The vacuumed literal
This will be automatically called by Rit::Base::Arc/vacuum
Widget for updating a node
$n->sysdesig()
The designation of an object, to be used for node administration or debugging. This version of desig indludes the node id, if existing.
Rit::Base, Rit::Base::Resource::Literal, Rit::Base::Resource, Rit::Base::Arc, Rit::Base::Pred, Rit::Base::Search