diff Lib/IMPL/DOM/Schema/ValidationError.pm @ 389:5aff94ba842f

DOM Schema refactoring complete
author cin
date Wed, 12 Feb 2014 13:36:24 +0400
parents 2f16f13b000c
children
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema/ValidationError.pm	Tue Feb 11 20:22:01 2014 +0400
+++ b/Lib/IMPL/DOM/Schema/ValidationError.pm	Wed Feb 12 13:36:24 2014 +0400
@@ -6,24 +6,32 @@
     '""' => \&toString,
     'fallback' => 1;
 
-use parent qw(IMPL::Object);
-use IMPL::Class::Property;
+use IMPL::lang qw(is);
+use IMPL::Const qw(:prop);
+use IMPL::declare {
+	require => {
+		Label => '-IMPL::DOM::Schema::Label' 
+	},
+	base => [
+		'IMPL::Object' => undef
+	],
+	props => [
+		node => PROP_RO | PROP_DIRECT,
+		schemaNode => PROP_RO | PROP_DIRECT,
+		schemaType => PROP_RO | PROP_DIRECT,
+		parent => PROP_RO | PROP_DIRECT,
+		message => PROP_RO | PROP_DIRECT  
+	]
+};
 use IMPL::Resources::Format qw(FormatMessage);
 
-BEGIN {
-    public _direct property node => prop_get; # target document node (if exists)
-    public _direct property schema => prop_get; # a schema for the target node (if exists) 
-    public _direct property source => prop_get; # a schema which triggered this error (can be equal to the Schema)
-    public _direct property parent => prop_get; 
-    public _direct property message => prop_get; # displayable message
-}
-
 sub CTOR {
     my ($this,%args) = @_;
     
     $this->{$node} = $args{node};
-    $this->{$schema} = $args{schema} if $args{schema};
-    $this->{$source} = $args{source} if $args{source};
+    $this->{$schemaNode} = $args{schemaNode} if $args{schemaNode};
+    $this->{$schemaType} = $args{schemaType} if $args{schemaType};
+    
     if ($args{parent}) {
         $this->{$parent} = $args{parent};
     } elsif ($args{node}) {
@@ -32,13 +40,10 @@
         die new IMPL::InvalidArgumentException("A 'parent' or a 'node' parameter is required");
     }
     
-    if(my $msg = $args{message}) {
-    	if (my($msgId) = ( $msg =~ /^ID:([\w\.]+)$/ ) ) {
-    		$this->{$message} = ($args{schema} || $args{source})->document->stringMap->GetString($msgId, \%args);
-    	} else {
-    		$this->{$message} = FormatMessage(delete $args{message}, \%args) if $args{message};
-    	}
+    if ($args{message}) {
+    	$this->{$message} = is($args{message},Label) ? $args{message}->Format(\%args) : FormatMessage($args{message}, \%args) ;
     }
+    
 }
 
 sub toString {