01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.admin.dso;
05:
06: import com.tc.admin.AdminClient;
07: import com.tc.admin.ConnectionContext;
08: import com.tc.objectserver.mgmt.MapEntryFacade;
09:
10: public class DSOMapEntryField extends DSOObject {
11: private String m_name;
12: private MapEntryFacade m_facade;
13: private DSOObject m_key;
14: private DSOObject m_value;
15: private String m_label;
16:
17: private static final String TYPE = AdminClient.getContext()
18: .getMessage("map.entry");
19:
20: public DSOMapEntryField(ConnectionContext cc, String name,
21: MapEntryFacade facade, DSOObject parent) {
22: super (cc, parent);
23:
24: m_name = name;
25: m_facade = facade;
26: m_label = m_name + " (" + TYPE + ")";
27: }
28:
29: public Object getFacade() {
30: return m_facade;
31: }
32:
33: public String getName() {
34: return m_name;
35: }
36:
37: public DSOObject getKey() {
38: if (m_key == null) {
39: m_key = getElement("key", m_facade.getKey());
40: }
41:
42: return m_key;
43: }
44:
45: public DSOObject getValue() {
46: if (m_value == null) {
47: m_value = getElement("value", m_facade.getValue());
48: }
49:
50: return m_value;
51: }
52:
53: private DSOObject getElement(String field, Object value) {
54: try {
55: return createField(field, value, null);
56: } catch (Throwable t) {
57: t.printStackTrace();
58: }
59:
60: return null;
61: }
62:
63: public String toString() {
64: return m_label;
65: }
66:
67: public void accept(DSOObjectVisitor visitor) {
68: visitor.visitDSOMapEntryField(this);
69: }
70: }
|