Author: spadkins
Date: Fri Mar 6 09:21:06 2009
New Revision: 12574
Modified:
p5ee/trunk/App-Context/lib/App/ValueDomain.pm
Log:
Added sub get_label and _load_label
Modified: p5ee/trunk/App-Context/lib/App/ValueDomain.pm
==============================================================================
--- p5ee/trunk/App-Context/lib/App/ValueDomain.pm (original)
+++ p5ee/trunk/App-Context/lib/App/ValueDomain.pm Fri Mar 6 09:21:06 2009
@@ -167,6 +167,41 @@
}
#############################################################################
+# get_label()
+#############################################################################
+
+=head2 get_label()
+
+ * Signature: $label = $dom->get_label($value);
+ * Param: $value string
+ * Return: $label string
+
+ Sample Usage:
+
+ $context = App->context();
+ $dom = $context->value_domain("product_type");
+ $label = $dom->get_label($value);
+
+=cut
+
+sub get_label {
+ my ($self, $value) = @_;
+ &App::sub_entry if ($App::trace);
+ $self->_load() if (!$self->{labels});
+ my $labels = $self->{labels};
+ my ($label);
+ if (exists $labels->{$value}) {
+ $label = $labels->{$value} || $value;
+ }
+ else {
+ $label = $self->_load_label($value);
+ $labels->{$value} = $label;
+ }
+ &App::sub_exit($label) if ($App::trace);
+ return($label);
+}
+
+#############################################################################
# _load()
#############################################################################
@@ -202,6 +237,13 @@
&App::sub_exit() if ($App::trace);
}
+sub _load_label {
+ my ($self, $value) = @_;
+ &App::sub_entry if ($App::trace);
+ my $label = undef;
+ &App::sub_exit($label) if ($App::trace);
+ return($label);
+}
sub unload {
&App::sub_entry if ($App::trace);