view Lib/IMPL/DOM/Schema/SimpleNode.pm @ 134:44977efed303

Significant performance optimizations Fixed recursion problems due converting objects to JSON Added cache support for the templates Added discovery feature for the web methods
author wizard
date Mon, 21 Jun 2010 02:39:53 +0400
parents e30bdd040fe3
children 1e7f03414b65
line wrap: on
line source

package IMPL::DOM::Schema::SimpleNode;
use strict;
use warnings;

use base qw(IMPL::DOM::Schema::Node);
use IMPL::Class::Property;
use IMPL::Class::Property::Direct;

BEGIN {
	public _direct property inflator => prop_get;
	public _direct property messageInflateError => prop_get;
}

our %CTOR = (
    'IMPL::DOM::Schema::Node' => sub {
    	my %args = @_;
    	$args{nodeName} ||= 'SimpleNode';
    	delete @args{qw(inflator messageInflateError)};
    	%args
    }
);

sub CTOR {
	my ($this,%args) = @_;
	
	$this->{$inflator} = $args{inflator} if $args{inflator};
	$this->{$messageInflateError} = $args{messageInflateError} || 'Failed to inflate nodeValue %Node.path%: %Error%';
}

sub Validate {
    my ($this,$node,$ctx) = @_;
    
    my @result;
    
    push @result, $_->Validate($node,$ctx) foreach $this->childNodes;
    
    return @result;
}

sub inflateValue {
	my ($this,$value) = @_;
	
	if ( my $inflator = $this->inflator ) {
		return $inflator->new($value);
	} else {
		return $value;
	}
}

1;

__END__

=pod

=head1 NAME

C<IMPL::DOM::SimpleNode> - узел с текстом.

=head1 DESCRIPTION

Узел имеющий простое значение. Данный узел может содержать ограничения
на простое значение.

Производит валидацию содержимого, при постоении DOM модели не имеет специального
типа и будет создан в виде C<IMPL::DOM::Node>.

Также определяет как будет воссоздано значение узла в DOM модели.

=cut