comparison Lib/IMPL/Serialization.pm @ 202:5146e17a7b76

IMPL::Web::Application::RestResource fixes, documentation
author sergey
date Wed, 25 Apr 2012 02:49:23 +0400
parents e743a8481327
children f534a60d5b01
comparison
equal deleted inserted replaced
201:0c018a247c8a 202:5146e17a7b76
240 if ((not defined($rhObject)) && $rhPrevObject) { 240 if ((not defined($rhObject)) && $rhPrevObject) {
241 $this->{$CurrentObject} = $rhPrevObject; 241 $this->{$CurrentObject} = $rhPrevObject;
242 return 1; 242 return 1;
243 } 243 }
244 244
245 my $refObj = $this->{$ObjectFactory} ?$this->{$ObjectFactory}->($rhObject->{'Type'},$rhObject->{'Data'},$rhObject->{'Id'} ? $this->{$Context}->{$rhObject->{'Id'}} : undef) : DefaultFactory($rhObject->{'Type'},$rhObject->{'Data'} || [],$rhObject->{'Id'} ? $this->{$Context}->{$rhObject->{'Id'}} : undef); 245 my $refObj = $this->{$ObjectFactory} ?$this->{$ObjectFactory}->($rhObject->{'Type'},$rhObject->{'Data'},$rhObject->{'Id'} ? $this->{$Context}->{$rhObject->{'Id'}} : undef) : DefaultFactory($rhObject->{'Type'},$rhObject->{'Data'},$rhObject->{'Id'} ? $this->{$Context}->{$rhObject->{'Id'}} : undef);
246 246
247 die new Exception("Trying to close a non existing oject") if not $rhObject; 247 die new Exception("Trying to close a non existing oject") if not $rhObject;
248 248
249 my $Data; 249 my $Data;
250 250
327 return $refSurogate; 327 return $refSurogate;
328 } else { 328 } else {
329 return \$Data; 329 return \$Data;
330 } 330 }
331 } elsif ($Type eq 'ARRAY') { 331 } elsif ($Type eq 'ARRAY') {
332 $Data ||= [];
332 die new Exception("Invalid a deserialization context when deserializing ARRAY") if not ref $Data and defined $Data; 333 die new Exception("Invalid a deserialization context when deserializing ARRAY") if not ref $Data and defined $Data;
333 if (not ref $refSurogate) { 334 if (not ref $refSurogate) {
334 my @Array; 335 my @Array;
335 $refSurogate = \@Array; 336 $refSurogate = \@Array;
336 } 337 }
337 for (my $i = 0; $i < scalar(@{$Data})/2; $i++) { 338 for (my $i = 0; $i < scalar(@{$Data})/2; $i++) {
338 push @$refSurogate,$Data->[$i*2+1]; 339 push @$refSurogate,$Data->[$i*2+1];
339 } 340 }
340 return $refSurogate; 341 return $refSurogate;
341 } elsif ($Type eq 'HASH') { 342 } elsif ($Type eq 'HASH') {
343 $Data ||= [];
342 die new Exception("Invalid a deserialization context when deserializing HASH") if not ref $Data and defined $Data; 344 die new Exception("Invalid a deserialization context when deserializing HASH") if not ref $Data and defined $Data;
343 if (not ref $refSurogate) { 345 if (not ref $refSurogate) {
344 $refSurogate = {}; 346 $refSurogate = {};
345 } 347 }
346 for (my $i = 0; $i< @$Data; $i+= 2) { 348 for (my $i = 0; $i< @$Data; $i+= 2) {
347 $refSurogate->{$Data->[$i]} = $Data->[$i+1]; 349 $refSurogate->{$Data->[$i]} = $Data->[$i+1];
348 } 350 }
349 return $refSurogate; 351 return $refSurogate;
350 } elsif ($Type eq 'REF') { 352 } elsif ($Type eq 'REF') {
353 $Data ||= [];
351 die new Exception("Invalid a deserialization context when deserializing REF") if not ref $Data and defined $Data; 354 die new Exception("Invalid a deserialization context when deserializing REF") if not ref $Data and defined $Data;
352 if (not ref $refSurogate) { 355 if (not ref $refSurogate) {
353 my $ref = $Data->[1]; 356 my $ref = $Data->[1];
354 return \$ref; 357 return \$ref;
355 } else { 358 } else {