<?php
// ----------------------------------------------------------------------------------
// Class: Literal
// ----------------------------------------------------------------------------------
/**
* An RDF literal.
* The literal supports the xml:lang tag.
*
* History:
* 09-10-2002 : First version of this class.
*
* @version V0.1
* @author Chris Bizer <hide@address.com>
*
* @package model
* @todo nothing
* @access public
*
*/
class Literal extends Node {
/**
* Label of the literal
* @var string
* @access private
*/
var $label;
/**
* Language of the literal
* @var string
* @access private
*/
var $lang;
/**
* Constructor
*
* @param string $str label of the literal
* @param string $language optional language identifier
*
*/
function Literal($str, $language = NULL) {
$this->label = $str;
if ($language != NULL) {
$this->lang = $language;
} else {
$this->lang = NULL;
}
}
/**
* Returns the string value of the literal.
*
* @access public
* @return string value of the literal
*/
function getLabel() {
return $this->label;
}
/**
* Returns the language of the literal.
*
* @access public
* @return string language of the literal
*/
function getLanguage() {
return $this->lang;
}
/**
* Checks if ihe literal equals another literal.
* Two literals are equal, if they have the same label and they
* have the same language or both have no language property set.
*
* @access public
* @param object literal $that
* @return boolean
*/
function equals ($that) {
if (($that == NULL) or !(is_a($that, "Literal"))) {
return false;
}
if ($this->label == $that->getLabel() && ($this->language == $that->getLanguage() ||
($this->language == NULL && $that->getLanguage() == NULL))) {
return true;
}
return false;
}
/**
* Dumps literal.
*
* @access public
* @return string
*/
function toString() {
$dump = "Literal(\"" . $this->label ."\"";
if ($this->lang != NULL)
$dump .= ", lang=\"" . $this->lang ."\"";
$dump .= ")";
return $dump;
}
} // end: Literal
?>