49
|
1 package Form::ItemId;
|
|
2 use strict;
|
|
3 use Common;
|
|
4 our @ISA = qw(Object);
|
|
5
|
|
6 BEGIN {
|
|
7 DeclareProperty Name => ACCESS_READ;
|
|
8 DeclareProperty Canonical => ACCESS_READ;
|
|
9 DeclareProperty InstanceID => ACCESS_READ;
|
|
10 DeclareProperty Parent => ACCESS_READ;
|
|
11 }
|
|
12
|
|
13 sub CTOR {
|
|
14 my ($this,$name,$instance_id,$parent) = @_;
|
|
15
|
|
16 $this->{$Name} = $name or die new Exception('A name is required for the item id');
|
|
17 $this->{$InstanceID} = $instance_id;
|
|
18 $this->{$Parent} = $parent;
|
|
19
|
|
20 $this->{$Canonical} = ($parent && !$parent->isa('Form::ItemId::Root') ? $parent->Canonical.'/':'').$name.(defined $instance_id ? $instance_id : '');
|
|
21 }
|
|
22
|
|
23 sub ToNAVPath {
|
|
24 my ($this) = @_;
|
|
25
|
|
26 return ($this->{$Parent} ? ($this->{$Parent}->ToNAVPath,$this) : $this);
|
|
27 }
|
|
28
|
|
29 package Form::ItemId::Prev;
|
|
30 our @ISA = qw(Form::ItemId);
|
|
31
|
|
32 sub CTOR {
|
|
33 my ($this,$parent) = @_;
|
|
34 $this->SUPER::CTOR('(prev)',undef,$parent);
|
|
35 }
|
|
36
|
|
37 package Form::ItemId::Root;
|
|
38 our @ISA = qw(Form::ItemId);
|
|
39
|
|
40 sub CTOR {
|
|
41 my ($this,$parent) = @_;
|
|
42 $this->SUPER::CTOR('(root)',undef,$parent);
|
|
43 }
|
|
44
|
|
45
|
|
46 1;
|