KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > comparison > CmsAttributeComparison


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/comparison/CmsAttributeComparison.java,v $
3  * Date : $Date: 2006/03/27 14:52:44 $
4  * Version: $Revision: 1.2 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (C) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.comparison;
33
34 import org.opencms.util.CmsStringUtil;
35
36 /**
37  * Comparison of resource properties.<p>
38  *
39  * @author Jan Baudisch
40  */

41 public class CmsAttributeComparison {
42
43     /** The name of the property.<p> */
44     private String JavaDoc m_name;
45
46     /** The type of the property comparison.<p> */
47     private String JavaDoc m_status;
48
49     /** The first value of the property.<p> */
50     private String JavaDoc m_version1;
51
52     /** The second value of the property.<p> */
53     private String JavaDoc m_version2;
54
55     /**
56      * Constructs a new attribute object.<p>
57      */

58     public CmsAttributeComparison() {
59
60         // no-op
61
}
62
63     /**
64      * Creates a new attribute comparison.<p>
65      *
66      * @param name the name to set
67      * @param version1 the first value of the property
68      * @param version2 the seconf value of the property
69      */

70     public CmsAttributeComparison(String JavaDoc name, String JavaDoc version1, String JavaDoc version2) {
71
72         m_name = name;
73         m_version1 = version1;
74         m_version2 = version2;
75         boolean v1Empty = CmsStringUtil.isEmptyOrWhitespaceOnly(version1);
76         boolean v2Empty = CmsStringUtil.isEmptyOrWhitespaceOnly(version2);
77         if (v1Empty && !v2Empty) {
78             m_status = CmsResourceComparison.TYPE_ADDED;
79         } else if (!v1Empty && v2Empty) {
80             m_status = CmsResourceComparison.TYPE_REMOVED;
81         } else if ((v1Empty && v2Empty) || version1.equals(version2)) {
82             m_status = CmsResourceComparison.TYPE_UNCHANGED;
83         } else {
84             m_status = CmsResourceComparison.TYPE_CHANGED;
85         }
86     }
87
88     /**
89      * Creates a new attribute comparison.<p>
90      *
91      * @param name the name to set
92      * @param version1 the first value of the property
93      * @param version2 the seconf value of the property
94      * @param type the type indicating if the element value has been added, removed, modified or is unchanged
95      * {@link CmsResourceComparison#TYPE_ADDED}.
96      */

97     public CmsAttributeComparison(String JavaDoc name, String JavaDoc version1, String JavaDoc version2, String JavaDoc type) {
98
99         m_name = name;
100         m_version1 = version1;
101         m_version2 = version2;
102         m_status = type;
103     }
104
105     /**
106      * Returns the locale.<p>
107      *
108      * @return the locale
109      */

110     public String JavaDoc getName() {
111
112         return m_name;
113     }
114
115     /**
116      * Returns the type.<p>
117      *
118      * @return the type
119      */

120     public String JavaDoc getStatus() {
121
122         return m_status;
123     }
124
125     /**
126      * Returns the attribute.<p>
127      *
128      * @return the attribute
129      */

130     public String JavaDoc getVersion1() {
131
132         return m_version1;
133     }
134
135     /**
136      * Returns the type.<p>
137      *
138      * @return the type
139      */

140     public String JavaDoc getVersion2() {
141
142         return m_version2;
143     }
144
145     /**
146      * Sets the name.<p>
147      *
148      * @param name the name to set
149      */

150     public void setName(String JavaDoc name) {
151
152         m_name = name;
153     }
154
155     /**
156      * Sets the type.<p>
157      *
158      * @param type the type to set
159      */

160     public void setStatus(String JavaDoc type) {
161
162         m_status = type;
163     }
164
165     /**
166      * Sets the version1.<p>
167      *
168      * @param version1 the version1 to set
169      */

170     public void setVersion1(String JavaDoc version1) {
171
172         m_version1 = version1;
173     }
174
175     /**
176      * Sets the type.<p>
177      *
178      * @param type the type to set
179      */

180     public void setVersion2(String JavaDoc type) {
181
182         m_version2 = type;
183     }
184
185 }
186
Popular Tags