NAME

DAIA::Object - Abstract base class of all DAIA classes

DESCRIPTION

This package implements just another Perl meta-class framework. Just ignore it unless you have a clue what "meta-class framework" could mean. Some concepts are borrowed from the mighty Moose object system but this framework is much smaller. Maybe you should better have a look at Moose and stop reading now.

In a nutshell DAIA::Object handles all method calls via AUTOLOAD. Each derived package must provide a %PROPERTIES hash that defines an object's attributes. Each property is defined by a hash that must either contain a type value pointing to a class name (typed property) or a filter value containing a plain value ar a filter method (untyped property).

METHDOS

Constructor methods

All derived DAIA classed use this constructor. As DAIA::Object is an abstract base class directly calling is of little use.

new ( ..attributes... )

Constructs a new DAIA object. Unknown properties are ignored.

Modification methods

add ( ... )

Adds typed properties to an object.

Serialization methods

A DAIA object can be serialized by the following methods:

xml ( [ xmlns => 0|1 ] [ xslt => $xslt ] [ header => 0|1 ] )

Returns the object in DAIA/XML. With the xmlns as parameter you can specify that a namespace declaration is added (disabled by default unless you enable xslt or header). With xslt you can add an XSLT processing instruction. If you enable header, an XML-header is prepended.

struct ( [ $json ] )

Returns the object as unblessed Perl data structure. If you specify a true parameter, only boolean values will be kept as blessed JSON::Boolean objects (see JSON). The label property will only be included unless it is not the empty string.

json ( [ $callback ] )

Returns the object in DAIA/JSON, optionally wrapped by a JavaScript callback function call. Invalid callback names are ignored without warning.

serve ( [ [ format => ] $format | [ cgi => $CGI ] ] [ %more_options ] )

Serialize the object and send it to STDOUT or a another stream with the appropriate HTTP headers. This method is available for all DAIA objects but mostly used to serve a DAIA::Response. The serialized object must already be encoded in UTF-8 (but it can contain Unicode strings).

The serialization format should be specified with the first parameter as format string (json or xml) or cgi object. If no format is given, it is searched for in the CGI query parameters. The default format is xml. Other possible options are:

Print HTTP headers (default). Use header => 0 to disable headers.

xslt

Add a link to the given XSLT stylesheet if XML format is requested.

callback

Add this JavaScript callback function in JSON format. If no callback function is specified, it is searched for in the CGI query parameters. You can disable callback support by setting callback => undef.

to

Serialize to a given stream (IO::Handle, GLOB, or string reference) instead of STDOUT. You probably also want to set exitif if you use this option.

exitif

By default this method exits the program. You can change this behavior with this parameter. With exitif = 0 the method never calls exit. If you provide a method, the method is called and the script exits if only if the return value is true.

INTERNAL METHODS

The following methods are only used internally; don't directly call or modify them unless you want to damage data integrity or to fix a bug!

AUTOLOAD

Called if an unknown method is called. Almost all method calls go through this magic method. Thanks, AUTOLOAD, thanks Perl.

xml_write ( $roottag, $content, $level )

Simple, adopted XML::Simple::XMLOut replacement with support of element order and special treatment of label elements.

xml_escape_value ( $string )

Escape special XML characters.

_buildargs

Returns a property-value hash of constructor parameters.

_enable_utf8_layer

Enable :utf8 layer for a given filehandle unless it or some other encoding has already been enabled.

AUTHOR

Jakob Voss <jakob.voss@gbv.de>

LICENSE

Copyright (C) 2009 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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 276:

You forgot a '=back' before '=head1'