Source code: com/aendvari/tethys/context/message/MessageContext.java
1 /*
2 * MessageContext.java
3 *
4 * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5 *
6 * See the file LICENSE for terms of use.
7 *
8 */
9
10 package com.aendvari.tethys.context.message;
11
12 import com.aendvari.tethys.context.*;
13
14
15 /**
16 * <p>This class is used to hold message context information.</p>
17 *
18 * <p>A message context refers to another portion of the message
19 * context hierarchy. This allows relative message names to be used
20 * within several contexts.</p>
21 *
22 * @author Scott Milne
23 *
24 */
25
26 public class MessageContext extends Context
27 {
28 /* Attributes */
29
30 /** The context path that this context refers to. */
31 protected String contextPath;
32
33
34 /* Constructors */
35
36 /**
37 * Constructs a <code>MessageContext</code> from the supplied values.
38 *
39 * @param location The location of the context. This includes the context name.
40 * @param contextPath The context to refer to.
41 *
42 */
43
44 public MessageContext(String location, String contextPath)
45 {
46 super(location);
47
48 this.contextPath = contextPath;
49 }
50
51 /**
52 * Constructs a <code>MessageContext</code> from the supplied values.
53 *
54 * @param location The name/location of the context relative to the parent context.
55 * @param contextPath The context to refer to.
56 * @param parent The parent {@link MessageContext}.
57 *
58 */
59
60 public MessageContext(String location, String contextPath, MessageContext parent)
61 {
62 super(location, parent);
63
64 this.contextPath = contextPath;
65 }
66
67
68 /* Attributes */
69
70 public void setContextPath(String path) { this.contextPath = path; }
71 public String getContextPath() { return contextPath; }
72
73
74 /**
75 * Extends the context path of this context with the supplied relative path.
76 *
77 * @param relative The relative path to include.
78 *
79 * @return The combined context and relative paths.
80 *
81 */
82
83 public String extendContextPath(String relative)
84 {
85 return combinePaths(contextPath, relative);
86 }
87
88
89 /* Debug */
90
91 public String toString()
92 {
93 String toString = "ModelContext=[";
94
95 toString += "location=" + getLocation() + ",";
96 toString += "contextPath=" + getContextPath();
97 toString += "]";
98
99 return toString;
100 }
101 }
102