line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AMF::Perl::Util::Object; |
2
|
|
|
|
|
|
|
# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved. |
3
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it |
4
|
|
|
|
|
|
|
# under the same terms as Perl itself. |
5
|
|
|
|
|
|
|
# The code is based on the -PHP project (http://amfphp.sourceforge.net/) |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
AMF::Perl::Object |
10
|
|
|
|
|
|
|
Translated from PHP Remoting v. 0.5b from the -PHP project. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Package used for building and retreiving header and body information |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 CHANGES |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 Wed Apr 14 11:06:28 EDT 2004 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=item Saving column types in the __columnTypes__ field for the recordset object. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Sun Jul 27 16:52:12 EDT 2003 |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item Added the pseudo_query() method to create a recordset object wanted by Flash. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
534
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# constructor |
31
|
|
|
|
|
|
|
sub new |
32
|
|
|
|
|
|
|
{ |
33
|
0
|
|
|
0
|
0
|
|
my ($proto)=@_; |
34
|
0
|
|
|
|
|
|
my $self = {}; |
35
|
0
|
|
|
|
|
|
bless $self, $proto; |
36
|
|
|
|
|
|
|
# init the headers and bodys arrays |
37
|
0
|
|
|
|
|
|
$self->{_headers} = []; |
38
|
0
|
|
|
|
|
|
$self->{_bodies} = []; |
39
|
0
|
|
|
|
|
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# adds a header to our object |
43
|
|
|
|
|
|
|
# requires three arguments key, required, and value |
44
|
|
|
|
|
|
|
sub addHeader |
45
|
|
|
|
|
|
|
{ |
46
|
0
|
|
|
0
|
0
|
|
my ($self, $k, $r, $v)=@_; |
47
|
0
|
|
|
|
|
|
my $header = {}; |
48
|
0
|
|
|
|
|
|
$header->{"key"} = $k; |
49
|
0
|
|
|
|
|
|
$header->{"required"} = $r; |
50
|
0
|
|
|
|
|
|
$header->{"value"} = $v; |
51
|
0
|
|
|
|
|
|
push @{$self->{_headers}}, $header; |
|
0
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# returns the number of headers |
55
|
|
|
|
|
|
|
sub numHeader |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
0
|
0
|
|
my ($self)=@_; |
58
|
0
|
|
|
|
|
|
return scalar(@{$self->{_headers}}); |
|
0
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub getHeaderAt |
62
|
|
|
|
|
|
|
{ |
63
|
0
|
|
|
0
|
0
|
|
my ($self, $id)=@_; |
64
|
0
|
0
|
|
|
|
|
$id=0 unless $id; |
65
|
0
|
|
|
|
|
|
return $self->{_headers}->[$id]; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# adds a body to our bodys object |
69
|
|
|
|
|
|
|
# requires three arguments target, response, and value |
70
|
|
|
|
|
|
|
sub addBody |
71
|
|
|
|
|
|
|
{ |
72
|
0
|
|
|
0
|
0
|
|
my ($self, $t, $r, $v, $ty)=@_; |
73
|
0
|
0
|
|
|
|
|
$ty="unknown" unless $ty; |
74
|
0
|
|
|
|
|
|
my $body = {}; |
75
|
0
|
|
|
|
|
|
$body->{"target"} = $t; |
76
|
0
|
|
|
|
|
|
$body->{"response"} = $r; |
77
|
0
|
|
|
|
|
|
$body->{"value"} = $v; |
78
|
0
|
|
|
|
|
|
$body->{"type"} = $ty; |
79
|
0
|
|
|
|
|
|
push @{$self->{_bodies}}, $body; |
|
0
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
# returns the number of body elements |
82
|
|
|
|
|
|
|
sub numBody |
83
|
|
|
|
|
|
|
{ |
84
|
0
|
|
|
0
|
0
|
|
my ($self)=@_; |
85
|
0
|
|
|
|
|
|
return scalar(@{$self->{_bodies}}); |
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
# returns the body element at a specific index |
88
|
|
|
|
|
|
|
sub getBodyAt |
89
|
|
|
|
|
|
|
{ |
90
|
0
|
|
|
0
|
0
|
|
my ($self, $id)=@_; |
91
|
0
|
0
|
|
|
|
|
$id=0 unless $id; |
92
|
0
|
|
|
|
|
|
return $self->{_bodies}->[$id]; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub pseudo_query |
96
|
|
|
|
|
|
|
{ |
97
|
0
|
|
|
0
|
1
|
|
my ($self, $columnNames, $data, $columnTypes) = @_; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
my $result = new AMF::Perl::Util::Object; |
100
|
|
|
|
|
|
|
# create the serverInfo array |
101
|
0
|
|
|
|
|
|
$result->{"serverInfo"} = {}; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# create an initialData array |
104
|
0
|
|
|
|
|
|
my (@initialData, @columnNames); |
105
|
0
|
|
|
|
|
|
$result->{serverInfo}->{initialData} = $data; |
106
|
0
|
|
|
|
|
|
$result->{serverInfo}->{columnNames} = $columnNames; |
107
|
0
|
|
|
|
|
|
$result->{serverInfo}->{totalCount}= scalar @$data; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# create the id field --> i think this is used for pageable recordsets |
110
|
0
|
|
|
|
|
|
$result->{"serverInfo"}->{"id"} = "AMF::Perl"; |
111
|
0
|
|
|
|
|
|
$result->{"serverInfo"}->{"cursor"} = 1; # maybe the current record ???? |
112
|
0
|
|
|
|
|
|
$result->{"serverInfo"}->{"serviceName"} = "doStuff"; # in CF this is PageAbleResult not here |
113
|
|
|
|
|
|
|
# versioning |
114
|
0
|
|
|
|
|
|
$result->{"serverInfo"}->{"version"} = 1; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
$result->{_explicitType}='RecordSet'; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
$result->{__columnTypes__}=$columnTypes; |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
return $result; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |