Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/aendvari/common/notices/Notice.java


1   /*
2    * Notice.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.common.notices;
11  
12  
13  /**
14   * <p>Represents a single notice sent from various places.</p>
15   *
16   * <p>
17   * Up to four placeholder objects may be specified for parametric replacement
18   * of the notice text.
19   * </p>
20   *
21   * <p>
22   * The {@link NoticeTranslator} interface is used to translate {@link Notice}
23   * objects into strings.
24   * </p>
25   *
26   * @author Scott Milne
27   *
28   */
29  
30  public class Notice
31  {
32    /** The raw notice text. */
33    protected String notice = null;
34  
35      /** The replacement values for this notice. */
36      private Object values[] = { null, null, null, null };
37  
38  
39    /**
40     * Constructs a notice with no replacement values.
41     *
42     * @param  notice              Text for this notice.
43     *
44     */
45  
46    public Notice(String notice)
47    {
48      this.notice = notice;
49      setValues(null, null, null, null);
50    }
51  
52    /**
53     * Constructs a notice with the specified replacement values.
54     *
55     * @param  notice              Text for this notice.
56     * @param  value0              First replacement value.
57     *
58     */
59  
60    public Notice(String notice, Object value0)
61    {
62      this.notice = notice;
63      setValues(value0, null, null, null);
64    }
65  
66    /**
67     * Constructs a notice with the specified replacement values.
68     *
69     * @param  notice              Text for this notice.
70     * @param  value0              First replacement value.
71     * @param  value1              Second replacement value.
72     *
73     */
74  
75    public Notice(String notice, Object value0, Object value1)
76    {
77      this.notice = notice;
78      setValues(value0, value1, null, null);
79    }
80  
81    /**
82     * Constructs a notice with the specified replacement values.
83     *
84     * @param  notice              Text for this notice.
85     * @param  value0              First replacement value.
86     * @param  value1              Second replacement value.
87     * @param  value2              Third replacement value.
88     *
89     */
90  
91    public Notice(String notice, Object value0, Object value1, Object value2)
92    {
93      this.notice = notice;
94      setValues(value0, value1, value2, null);
95    }
96  
97    /**
98     * Constructs a notice with the specified replacement values.
99     *
100    * @param  notice              Text for this notice.
101    * @param  value0              First replacement value.
102    * @param  value1              Second replacement value.
103    * @param  value2              Third replacement value.
104    * @param  value3              Fourth replacement value.
105    *
106    */
107 
108   public Notice(String notice, Object value0, Object value1, Object value2, Object value3)
109   {
110     this.notice = notice;
111     setValues(value0, value1, value2, value3);
112   }
113 
114   /**
115    * Gets the text for this notice.
116    *
117    * @return                   String value of the notice text.
118    *
119    */
120 
121   public String getNotice()
122   {
123     return this.notice;
124   }
125 
126   /**
127    * Sets the replacement values for this notice.
128    *
129    * @param  value0              First replacement value.
130    * @param  value1              Second replacement value.
131    * @param  value2              Third replacement value.
132    * @param  value3              Fourth replacement value.
133    *
134    */
135 
136   public void setValues(Object value0, Object value1, Object value2, Object value3)
137   {
138     values[0] = value0;
139     values[1] = value1;
140     values[2] = value2;
141     values[3] = value3;
142   }
143 
144   /**
145    * Gets the replacement values for this notice.
146    *
147    * @return                   An array of the <code>Objects</code> used for replacement values.
148    *
149    */
150 
151   public Object[] getValues()
152   {
153     return this.values;
154   }
155 }
156