KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > admin > dso > DSOMapEntryField


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.admin.dso;
5
6 import com.tc.admin.AdminClient;
7 import com.tc.admin.ConnectionContext;
8 import com.tc.objectserver.mgmt.MapEntryFacade;
9
10 public class DSOMapEntryField extends DSOObject {
11   private String JavaDoc m_name;
12   private MapEntryFacade m_facade;
13   private DSOObject m_key;
14   private DSOObject m_value;
15   private String JavaDoc m_label;
16
17   private static final String JavaDoc TYPE =
18     AdminClient.getContext().getMessage("map.entry");
19
20   public DSOMapEntryField(
21     ConnectionContext cc,
22     String JavaDoc name,
23     MapEntryFacade facade,
24     DSOObject parent)
25   {
26     super(cc, parent);
27
28     m_name = name;
29     m_facade = facade;
30     m_label = m_name + " (" + TYPE + ")";
31   }
32
33   public Object JavaDoc getFacade() {
34     return m_facade;
35   }
36   
37   public String JavaDoc getName() {
38     return m_name;
39   }
40
41   public DSOObject getKey() {
42     if(m_key == null) {
43       m_key = getElement("key", m_facade.getKey());
44     }
45
46     return m_key;
47   }
48
49   public DSOObject getValue() {
50     if(m_value == null) {
51       m_value = getElement("value", m_facade.getValue());
52     }
53
54     return m_value;
55   }
56
57   private DSOObject getElement(String JavaDoc field, Object JavaDoc value) {
58     try {
59       return createField(field, value);
60     }
61     catch(Throwable JavaDoc t) {
62       t.printStackTrace();
63     }
64
65     return null;
66   }
67
68   public String JavaDoc toString() {
69     return m_label;
70   }
71
72   public void accept(DSOObjectVisitor visitor) {
73     visitor.visitDSOMapEntryField(this);
74   }
75 }
76
Popular Tags