KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > entities > management > ContentTypeAttributeParameterValue


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.entities.management;
25
26 import java.util.HashMap JavaDoc;
27 import java.util.Locale JavaDoc;
28 import java.util.Map JavaDoc;
29
30 /**
31  * This javabean carries information about one attributes parameters values. For example an
32  * attribute can have a possible parameter called category. Then the category can have multiple
33  * possible values, for example division, global, local and so on. Each of these values can have
34  * multiple representations visually. Language-dependency is one obvious. All variations are kept in this bean.
35  */

36
37
38 public class ContentTypeAttributeParameterValue
39 {
40     private String JavaDoc id = null;
41     private Map JavaDoc attributes = new HashMap JavaDoc();
42     
43     public ContentTypeAttributeParameterValue()
44     {
45     }
46
47     public String JavaDoc getId()
48     {
49         return this.id;
50     }
51
52     public void setId(String JavaDoc id)
53     {
54         this.id = id;
55     }
56
57     public Map JavaDoc getAttributes()
58     {
59         return this.attributes;
60     }
61
62     public void addAttribute(String JavaDoc key, String JavaDoc value)
63     {
64         this.attributes.put(key, value);
65     }
66
67     public void setAttributes(Map JavaDoc attributes)
68     {
69         this.attributes = attributes;
70     }
71     
72     public String JavaDoc getValue(String JavaDoc key)
73     {
74         return (String JavaDoc)this.attributes.get(key);
75     }
76         
77     public String JavaDoc getLocalizedValue(String JavaDoc key, Locale JavaDoc locale)
78     {
79         String JavaDoc localizedKey = key + "_" + locale.getLanguage();
80         if(this.attributes.containsKey(localizedKey))
81             return (String JavaDoc)this.attributes.get(localizedKey);
82         else
83             return (String JavaDoc)this.attributes.get(key);
84     }
85     
86     public String JavaDoc getLocalizedValue(String JavaDoc key, String JavaDoc langugeCode)
87     {
88         String JavaDoc localizedKey = key + "_" + langugeCode;
89         if(this.attributes.containsKey(localizedKey))
90             return (String JavaDoc)this.attributes.get(localizedKey);
91         else
92             return (String JavaDoc)this.attributes.get(key);
93     }
94
95     public int getLocalizedValueAsInt(String JavaDoc key, Locale JavaDoc locale)
96     {
97         try
98         {
99             String JavaDoc localizedKey = key + "_" + locale.getLanguage();
100             if(this.attributes.containsKey(localizedKey))
101                 return Integer.parseInt((String JavaDoc)this.attributes.get(localizedKey));
102             else
103                 return Integer.parseInt((String JavaDoc)this.attributes.get(key));
104         }
105         catch(Exception JavaDoc e)
106         {
107             return 0;
108         }
109     }
110     
111     public int getLocalizedValueAsInt(String JavaDoc key, String JavaDoc langugeCode)
112     {
113         try
114         {
115             String JavaDoc localizedKey = key + "_" + langugeCode;
116             if(this.attributes.containsKey(localizedKey))
117                 return Integer.parseInt((String JavaDoc)this.attributes.get(localizedKey));
118             else
119                 return Integer.parseInt((String JavaDoc)this.attributes.get(key));
120         }
121         catch(Exception JavaDoc e)
122         {
123             return 0;
124         }
125
126     }
127
128 }
Popular Tags