NAME

DAIA::Message - An optional information text or error message

DESCRIPTION

Messages can occurr as property of DAIA::Response, DAIA::Document, DAIA::Item, and DAIA::Availability objects.

PROPERTIES

content

The message as plain Unicode string. The default value is the empty string.

lang

A mandatory RFC 3066 language code. The default value is defined in $DAIA::Message::DEFAULT_LANG and set to 'en'.

errno

An integer value error code. By default a message has no error code.

The message function is a shortcut for the DAIA::Message constructor:

$msg = DAIA::Message->new( ... );
$msg = message( ... );

The constructor understands several abbreviated ways to define a message:

$msg = message( $content [, lang => $lang ] [, errno => $errno ] )
$msg = message( $lang => $content [, errno => $errno ] )
$msg = message( $lang => $content [, $errno ] )

The value undef as error code is ignored on construction. You can undefine an error code by explicitely setting it to undef.

$msg->errno( undef );

To set or get all messages of an object, you use the messages accessor. You can pass an array reference or an array:

$messages = $document->message;  # returns an array reference

$document->message( [ $msg1, $msg2 ] );
$document->message( [ $msg ] );
$document->message( $msg1, $msg2);
$document->message( $msg );

To append a message you can use the add or the addMessage method:

$document->add( $msg );         # $msg must be a DAIA::Message
$document->addMessage( ... );   # ... is passed to message constructor

$document += $msg;              # same as $document->add( $msg );

In addition to the message function there is the error function to quickly construct error messages. The first parameter is always treated as error number:

error() # errno = 0
error( $errno [, $lang => $content ] ) 
error( $errno, $content [, lang => $lang ] )

FUNCTIONS

is_language_tag ( $tag )

Returns whether $tag is a formally valid language tag. The regular expression follows XML Schema type xs:language instead of RFC 3066. For true RFC 3066 support have a look at I18N::LangTags.

AUTHOR

Jakob Voss <jakob.voss@gbv.de>

LICENSE

Copyright (C) 2009-2010 by Verbundzentrale Goettingen (VZG) and Jakob Voss

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.