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 ( [ %options ] )

Returns the object in DAIA/XML. The current implementation does not know element order, so it breaks the XML Schema.

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.

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.

_buildargs

Returns a property-value hash of constructor parameters.

BUGS

The XML serialization does not use the right element order and there is no strict parsing mode yet. More examples will be included too.

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.

__END__

ELEMENT ORDER:

response: ! institution? (element) - information about the institution that grants or knows about services and their availability message* (element) - (error) message(s) about the whole response document* message item

item ! label? (element) - a label that helps to identify and/or find the item (signature etc.) ! department? (element) - an administrative sub-entitity of the institution that is responsible for this item ! storage? (element) - a physical location of the item (stacks, floor etc.) message* (element) - (error) message(s) about the item. available* (element) - information about an available service with the item. unavailabile*

my $xml = "<$name";
my @children;
my $content = $self->{content};

#foreach my $property (keys %$self) {
#    if (ref $self->{$property} eq 'ARRAY') { # children
#        $struct->{$property} = [ map { $_->struct } @{$self->{$property}} ];
#    } elsif ( UNIVERSAL::isa( $self->{$property}, "DAIA::Object" ) ) {
#        $struct->{$property} = $self->{$property}->struct;
#    } else { # attribute
#        $struct->{$property} = $self->{$property};
#    }
#}
# TODO: " " x ($elementLevel * $dataIndent)
if ( @children ) {
    $xml .= ">\n" . join( "\n", @children ) . "</$name>";
} elsif ( defined $content ) {
    # TODO encode content
    $xml .= $content . "</$name>";
} else {
    $xml .= " />";
}