line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WSST::Schema::Node; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
28
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
168
|
|
4
|
5
|
|
|
5
|
|
25
|
use base qw(WSST::Schema::Base); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
571
|
|
5
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(name title desc examples type children multiple |
6
|
|
|
|
|
|
|
nullable)); |
7
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw(parent depth)); |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
34
|
use constant BOOL_FIELDS => qw(multiple nullable); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
2452
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.1.1'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
12
|
|
|
12
|
1
|
19
|
my $class = shift; |
15
|
12
|
|
|
|
|
47
|
my $self = $class->SUPER::new(@_); |
16
|
12
|
100
|
|
|
|
54
|
$self->{depth} = ($self->parent ? $self->parent->depth + 1 : 1); |
17
|
12
|
100
|
|
|
|
130
|
if ($self->{children}) { |
18
|
4
|
|
|
|
|
5
|
foreach my $node (@{$self->{children}}) { |
|
4
|
|
|
|
|
10
|
|
19
|
6
|
|
|
|
|
10
|
$node->{parent} = $self; |
20
|
6
|
|
|
|
|
15
|
$node = $class->new($node); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
12
|
|
|
|
|
44
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub path { |
27
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
28
|
0
|
|
0
|
|
|
|
my $min = shift || 0; |
29
|
0
|
|
|
|
|
|
my $path = []; |
30
|
0
|
|
0
|
|
|
|
for (my $p = $self; $p && $p->depth >= $min; $p = $p->parent) { |
31
|
0
|
|
|
|
|
|
unshift(@$path, $p); |
32
|
|
|
|
|
|
|
} |
33
|
0
|
|
|
|
|
|
return $path; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub path_names { |
37
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
38
|
0
|
|
0
|
|
|
|
my $min = shift || 0; |
39
|
0
|
|
|
|
|
|
return [map {$_->name} @{$self->path($min)}]; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub to_array { |
43
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $array = [$self]; |
46
|
0
|
|
|
|
|
|
my $stack = [[$self, 0]]; |
47
|
0
|
|
|
|
|
|
while (my $val = pop(@$stack)) { |
48
|
0
|
|
|
|
|
|
my ($node, $i) = @$val; |
49
|
0
|
|
|
|
|
|
for (; $i < @{$node->{children}}; $i++) { |
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $child = $node->{children}->[$i]; |
51
|
0
|
|
|
|
|
|
push(@$array, $child); |
52
|
0
|
0
|
|
|
|
|
if ($child->{children}) { |
53
|
0
|
|
|
|
|
|
push(@$stack, [$node, $i+1]); |
54
|
0
|
|
|
|
|
|
push(@$stack, [$child, 0]); |
55
|
0
|
|
|
|
|
|
last; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return $array; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
WSST::Schema::Node - Schema::Node class of WSST |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This is a base class for tree structure of schema. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 METHODS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 new |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Constructor. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 name |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Accessor for the name. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 title |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Accessor for the title. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 desc |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Accessor for the desc. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 examples |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Accessor for the examples. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 type |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Accessor for the type. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 children |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Accessor for the children. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 multiple |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Accessor for the multiple. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 nullable |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Accessor for the nullable. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 path |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns Node objects of path. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 path_names |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Returns names of path |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 to_array |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Returns arrayref which contains all child nodes. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 SEE ALSO |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
http://code.google.com/p/wsst/ |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 AUTHORS |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Mitsuhisa Oshikawa |
128
|
|
|
|
|
|
|
Yusuke Kawasaki |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Copyright 2008 WSS Project Team |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
1; |