NAME
Wikibase::Datatype::Property - Wikibase property datatype.
SYNOPSIS
use Wikibase::Datatype::Property;
my $obj = Wikibase::Datatype::Property->new(%params);
my $aliases_ar = $obj->aliases;
my $datatype = $obj->datatype;
my $descriptions_ar = $obj->descriptions;
my $id = $obj->id;
my $labels_ar = $obj->labels;
my $lastrevid = $obj->lastrevid;
my $modified = $obj->modified;
my $ns = $obj->ns;
my $page_id = $obj->page_id;
my $statements_ar = $obj->statements;
my $title = $obj->title;
DESCRIPTION
This datatype is property class for representing property.
METHODS
new
my $obj = Wikibase::Datatype::Property->new(%params);
Constructor.
Returns instance of object.
aliases
Item aliases. Multiple per language. Reference to array with Wikibase::Datatype::Value::Monolingual instances. Parameter is optional.
datatype
Type of data. Parameter is required.
Possible datatypes are (datavalue instance in parenthesis): - commonsMedia (Wikibase::Datatype::Value::String) - external-id (Wikibase::Datatype::Value::String) - geo-shape (Wikibase::Datatype::Value::String) - globe-coordinate (Wikibase::Datatype::Value::Globecoordinate) - math (Wikibase::Datatype::Value::String) - monolingualtext (Wikibase::Datatype::Value::Monolingual) - musical-notation (Wikibase::Datatype::Value::String) - quantity (Wikibase::Datatype::Value::Quantity) - string (Wikibase::Datatype::Value::String) - tabular-data (Wikibase::Datatype::Value::String) - time (Wikibase::Datatype::Value::Time) - url (Wikibase::Datatype::Value::String) - wikibase-item (Wikibase::Datatype::Value::Item) - wikibase-property (Wikibase::Datatype::Value::Property)
descriptions
Item descriptions. One per language. Reference to array with Wikibase::Datatype::Value::Monolingual instances. Parameter is optional.
id
Id. Parameter is optional.
labels
Item descriptions. One per language. Reference to array with Wikibase::Datatype::Value::Monolingual instances. Parameter is optional.
lastrevid
Last revision ID. Parameter is optional.
modified
Date of modification. Parameter is optional.
ns
Namespace. Default value is 120.
page_id
Page id. Numeric value. Parameter is optional.
statements
Item statements. Reference to array with Wikibase::Datatype::Statement instances. Parameter is optional.
title
Item title. Parameter is optional.
aliases
my $aliases_ar = $obj->aliases;
Get aliases.
Returns reference to array with Wikibase::Datatype::Value::Monolingual instances.
datatype
my $datatype = $obj->datatype;
Get data type.
Returns string.
descriptions
my $descriptions_ar = $obj->descriptions;
Get descriptions.
Returns reference to array with Wikibase::Datatype::Value::Monolingual instances.
id
my $id = $obj->id;
Get id.
Returns string.
labels
my $labels_ar = $obj->labels;
Get labels.
Returns reference to array with Wikibase::Datatype::Value::Monolingual instances.
lastrevid
my $lastrevid = $obj->lastrevid;
Get last revision ID.
Returns string.
modified
my $modified = $obj->modified;
Get date of modification.
Returns string.
ns
my $ns = $obj->ns;
Get namespace.
Returns number.
page_id
my $page_id = $obj->page_id;
Get page id.
Returns number.
statements
my $statements_ar = $obj->statements;
Get statements.
Returns reference to array with Wikibase::Datatype::Statement instances.
title
my $title = $obj->title;
Get title.
Returns string.
ERRORS
new():
From Mo::utils::check_array_object():
Alias isn't 'Wikibase::Datatype::Value::Monolingual' object.
Description isn't 'Wikibase::Datatype::Value::Monolingual' object.
Label isn't 'Wikibase::Datatype::Value::Monolingual' object.
Parameter 'aliases' must be a array.
Parameter 'descriptions' must be a array.
Parameter 'labels' must be a array.
Parameter 'statements' must be a array.
Statement isn't 'Wikibase::Datatype::Statement' object.
From Mo::utils::check_page_id():
Parameter 'page_id' must a number.
From Mo::utils::check_number_of_items():
Description for language '%s' has multiple values.
Label for language '%s' has multiple values.
From Mo::utils::check_required():
Parameter 'datatype' is required.
Parameter 'datatype' = '%s' isn't supported.
EXAMPLE
use strict;
use warnings;
use Unicode::UTF8 qw(decode_utf8 encode_utf8);
use Wikibase::Datatype::Property;
use Wikibase::Datatype::Reference;
use Wikibase::Datatype::Sitelink;
use Wikibase::Datatype::Snak;
use Wikibase::Datatype::Statement;
use Wikibase::Datatype::Value::Item;
use Wikibase::Datatype::Value::Monolingual;
use Wikibase::Datatype::Value::String;
use Wikibase::Datatype::Value::Time;
# Statement.
my $statement1 = Wikibase::Datatype::Statement->new(
# instance of (P31) Wikidata property (Q18616576)
'snak' => Wikibase::Datatype::Snak->new(
'datatype' => 'wikibase-item',
'datavalue' => Wikibase::Datatype::Value::Item->new(
'value' => 'Q18616576',
),
'property' => 'P31',
),
);
# Main item.
my $obj = Wikibase::Datatype::Property->new(
'aliases' => [
Wikibase::Datatype::Value::Monolingual->new(
'language' => 'cs',
'value' => 'je',
),
Wikibase::Datatype::Value::Monolingual->new(
'language' => 'en',
'value' => 'is a',
),
Wikibase::Datatype::Value::Monolingual->new(
'language' => 'en',
'value' => 'is an',
),
],
'datatype' => 'wikibase-item',
'descriptions' => [
Wikibase::Datatype::Value::Monolingual->new(
'language' => 'cs',
'value' => decode_utf8('tato položka je jedna konkrétní věc (exemplář, '.
'příklad) patřící do této třídy, kategorie nebo skupiny předmětů'),
),
Wikibase::Datatype::Value::Monolingual->new(
'language' => 'en',
'value' => 'that class of which this subject is a particular example and member',
),
],
'id' => 'P31',
'labels' => [
Wikibase::Datatype::Value::Monolingual->new(
'language' => 'cs',
'value' => decode_utf8('instance (čeho)'),
),
Wikibase::Datatype::Value::Monolingual->new(
'language' => 'en',
'value' => 'instance of',
),
],
'page_id' => 3918489,
'statements' => [
$statement1,
],
'title' => 'Property:P31',
);
# Print out.
print "Title: ".$obj->title."\n";
print 'Id: '.$obj->id."\n";
print 'Data type: '.$obj->datatype."\n";
print 'Page id: '.$obj->page_id."\n";
print "Labels:\n";
foreach my $label (sort { $a->language cmp $b->language } @{$obj->labels}) {
print "\t".encode_utf8($label->value).' ('.$label->language.")\n";
}
print "Descriptions:\n";
foreach my $desc (sort { $a->language cmp $b->language } @{$obj->descriptions}) {
print "\t".encode_utf8($desc->value).' ('.$desc->language.")\n";
}
print "Aliases:\n";
foreach my $alias (sort { $a->language cmp $b->language } @{$obj->aliases}) {
print "\t".encode_utf8($alias->value).' ('.$alias->language.")\n";
}
print "Statements:\n";
foreach my $statement (@{$obj->statements}) {
print "\tStatement:\n";
print "\t\t".$statement->snak->property.' -> '.$statement->snak->datavalue->value."\n";
}
# Output:
# Title: Property:P31
# Id: P31
# Data type: wikibase-item
# Page id: 3918489
# Labels:
# instance (čeho) (cs)
# instance of (en)
# Descriptions:
# tato položka je jedna konkrétní věc (exemplář, příklad) patřící do této třídy, kategorie nebo skupiny předmětů (cs)
# that class of which this subject is a particular example and member (en)
# Aliases:
# je (cs)
# is a (en)
# is an (en)
# Statements:
# Statement:
# P31 -> Q18616576
DEPENDENCIES
Error::Pure, List::Util, Mo, Mo:utils, Readonly.
SEE ALSO
- Wikibase::Datatype
-
Wikibase datatypes.
REPOSITORY
https://github.com/michal-josef-spacek/Wikibase-Datatype
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2020-2023 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.33