KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > compiler > model > MessageResourcesModel


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.compiler.model;
19
20 import org.apache.beehive.netui.compiler.model.schema.struts11.MessageResourcesDocument;
21
22 public class MessageResourcesModel extends StrutsElementSupport
23 {
24     private String JavaDoc _parameter; // the target resources
25
private String JavaDoc _key; // the ServletContext attribute in which to store the resources
26
private Boolean JavaDoc _returnNull; // if false, will return '???keyname???' instead of null for missing resources
27
private String JavaDoc _factory; // configuration bean class -- org.apache.struts.config.MessageResourcesConfig
28

29     public MessageResourcesModel( StrutsApp parent )
30     {
31         super( parent );
32     }
33
34     public String JavaDoc getParameter()
35     {
36         return _parameter;
37     }
38
39     public void setParameter( String JavaDoc parameter )
40     {
41         _parameter = parameter;
42     }
43
44     public String JavaDoc getKey()
45     {
46         return _key;
47     }
48
49     public void setKey( String JavaDoc key )
50     {
51         _key = key;
52     }
53
54     public boolean doesReturnNull()
55     {
56         return _returnNull == null || _returnNull.booleanValue();
57     }
58
59     public void setReturnNull( boolean aNull )
60     {
61         _returnNull = new Boolean JavaDoc( aNull );
62     }
63
64     public String JavaDoc getFactory()
65     {
66         return _factory;
67     }
68
69     public void setFactory( String JavaDoc factory )
70     {
71         _factory = factory;
72     }
73
74     public Boolean JavaDoc getReturnNull()
75     {
76         return _returnNull;
77     }
78
79     public void setReturnNull( Boolean JavaDoc returnNull )
80     {
81         _returnNull = returnNull;
82     }
83
84     public void writeToXMLBean( MessageResourcesDocument.MessageResources mr )
85     {
86         if ( mr.getKey() == null && _key != null )
87         {
88             mr.setKey( _key );
89         }
90         
91         if ( mr.getParameter() == null )
92         {
93             assert _parameter != null;
94             mr.setParameter( _parameter );
95         }
96         
97         if ( mr.getNull() == null && _returnNull != null )
98         {
99             if ( _returnNull.booleanValue() )
100             {
101                 mr.setNull( MessageResourcesDocument.MessageResources.Null.TRUE );
102             }
103             else
104             {
105                 mr.setNull( MessageResourcesDocument.MessageResources.Null.FALSE );
106             }
107         }
108         
109         if ( mr.getFactory() == null && _factory != null )
110         {
111             mr.setFactory( _factory );
112         }
113     }
114     
115     
116 }
117
Popular Tags