[r418]: trunk / lib / SOAP / Data.pm  Maximize  Restore  History

Download this file

175 lines (154 with data), 4.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package SOAP::Data;
use strict;
use SOAP::Trace;
use vars qw(@ISA @EXPORT_OK);
use Exporter;
use Carp ();
@ISA = qw(Exporter);
@EXPORT_OK = qw(name type attr value uri);
sub DESTROY { SOAP::Trace::objects('()') }
sub new {
my $self = shift;
unless (ref $self) {
my $class = $self;
$self = bless {_attr => {}, _value => [], _signature => []} => $class;
SOAP::Trace::objects('()');
}
no strict qw(refs);
Carp::carp "Odd (wrong?) number of parameters in new()" if $^W && (@_ & 1);
while (@_) {
my $method = shift;
$self->$method(shift) if $self->can($method)
}
return $self;
}
sub name {
my $self = UNIVERSAL::isa($_[0] => __PACKAGE__) ? shift->new : __PACKAGE__->new;
if (@_) {
my ($name, $uri, $prefix) = shift;
if ($name) {
($uri, $name) = SOAP::Utils::splitlongname($name);
unless (defined $uri) {
($prefix, $name) = SOAP::Utils::splitqname($name);
$self->prefix($prefix) if defined $prefix;
} else {
$self->uri($uri);
}
}
$self->{_name} = $name;
$self->value(@_) if @_;
return $self;
}
return $self->{_name};
}
sub attr {
my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
? shift->new()
: __PACKAGE__->new();
if (@_) {
$self->{_attr} = shift;
$self->value(@_) if @_;
return $self
}
return $self->{_attr};
}
sub type {
my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
? shift->new()
: __PACKAGE__->new();
if (@_) {
$self->{_type} = shift;
$self->value(@_) if @_;
return $self;
}
if (!defined $self->{_type} && (my @types = grep {/^\{$SOAP::Constants::NS_XSI_ALL}type$/o} keys %{$self->{_attr}})) {
$self->{_type} = (SOAP::Utils::splitlongname(delete $self->{_attr}->{shift(@types)}))[1];
}
return $self->{_type};
}
BEGIN {
no strict 'refs';
for my $method (qw(root mustUnderstand)) {
my $field = '_' . $method;
*$method = sub {
my $attr = $method eq 'root'
? "{$SOAP::Constants::NS_ENC}$method"
: "{$SOAP::Constants::NS_ENV}$method";
my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
? shift->new
: __PACKAGE__->new;
if (@_) {
$self->{_attr}->{$attr} = $self->{$field} = shift() ? 1 : 0;
$self->value(@_) if @_;
return $self;
}
$self->{$field} = SOAP::Lite::Deserializer::XMLSchemaSOAP1_2->as_boolean($self->{_attr}->{$attr})
if !defined $self->{$field} && defined $self->{_attr}->{$attr};
return $self->{$field};
}
}
for my $method (qw(actor encodingStyle)) {
my $field = '_' . $method;
*$method = sub {
my $attr = "{$SOAP::Constants::NS_ENV}$method";
my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
? shift->new()
: __PACKAGE__->new();
if (@_) {
$self->{_attr}->{$attr} = $self->{$field} = shift;
$self->value(@_) if @_;
return $self;
}
$self->{$field} = $self->{_attr}->{$attr}
if !defined $self->{$field} && defined $self->{_attr}->{$attr};
return $self->{$field};
}
}
}
sub prefix {
my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
? shift->new()
: __PACKAGE__->new();
return $self->{_prefix} unless @_;
$self->{_prefix} = shift;
$self->value(@_) if @_;
return $self;
}
sub uri {
my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
? shift->new()
: __PACKAGE__->new();
return $self->{_uri} unless @_;
my $uri = $self->{_uri} = shift;
warn "Usage of '::' in URI ($uri) deprecated. Use '/' instead\n"
if defined $uri && $^W && $uri =~ /::/;
$self->value(@_) if @_;
return $self;
}
sub set_value {
my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
? shift->new()
: __PACKAGE__->new();
$self->{_value} = [@_];
return $self;
}
sub value {
my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
? shift->new()
: __PACKAGE__->new;
(@_)
? ($self->set_value(@_), return $self)
: wantarray
? return @{$self->{_value}}
: return $self->{_value}->[0];
}
sub signature {
my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
? shift->new()
: __PACKAGE__->new();
(@_)
? ($self->{_signature} = shift, return $self)
: (return $self->{_signature});
}
1;
__END__

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks