KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > dd > impl > common > Comparator


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.dd.impl.common;
21
22 import org.netbeans.modules.schema2beans.BaseBean;
23 import org.netbeans.modules.schema2beans.BaseProperty;
24 import org.netbeans.modules.j2ee.dd.api.web.*;
25
26 /**
27  * Customized comparator for web.xml
28  *
29  * @author Milan Kuchtiak
30  */

31 public class Comparator extends org.netbeans.modules.schema2beans.BeanComparator
32 {
33     public BaseBean compareBean(String JavaDoc beanName,
34                 BaseBean curBean,
35                 BaseBean newBean) {
36         if (curBean!=null && newBean!= null) {
37             if (curBean instanceof EnclosingBean && newBean instanceof EnclosingBean) {
38                 if (((EnclosingBean) curBean).getOriginal() == ((EnclosingBean) newBean).getOriginal()) {
39                     return curBean;
40                 }
41             }
42             if (curBean instanceof KeyBean) {
43                 String JavaDoc prop = ((KeyBean) curBean).getKeyProperty();
44                 Object JavaDoc key1 = curBean.getValue(prop);
45                 Object JavaDoc key2 = newBean.getValue(prop);
46                 if (key1 != null) {
47                     if (key1.equals(key2)) {
48                         return curBean;
49                     }
50                 }
51             } else {
52                 if (beanName.equals("SessionConfig")) { //NOI18N
53
return curBean;
54                 } else if (beanName.equals("WelcomeFileList")) { //NOI18N
55
return curBean;
56                 } else if (beanName.equals("LoginConfig")) { //NOI18N
57
return curBean;
58                 } else if (beanName.equals("FormLoginConfig")) { //NOI18N
59
return curBean;
60                 } else if (beanName.equals("FilterMapping")) { //NOI18N
61
return curBean;
62                 } else if (beanName.equals("Listener")) { //NOI18N
63
return curBean;
64                 } else if (beanName.equals("RunAs")) { //NOI18N
65
return curBean;
66                 } else if (beanName.equals("AuthConstraint")) { //NOI18N
67
return curBean;
68                 } else if (beanName.equals("UserDataConstraint")) { //NOI18N
69
return curBean;
70                 } else if (beanName.equals("JspConfig")) { //NOI18N
71
return curBean;
72                 } else if (beanName.equals("JspPropertyGroup")) { //NOI18N
73
return curBean;
74                 } else if (beanName.equals("LocaleEncodingMappingList")) { //NOI18N
75
return curBean;
76                 }
77             }
78         }
79         return super.compareBean(beanName, curBean, newBean);
80     }
81     
82     public Object JavaDoc compareProperty(String JavaDoc propertyName,
83                                   BaseBean curBean,
84                                   Object JavaDoc curValue,
85                                   int curIndex,
86                                   BaseBean newBean,
87                                   Object JavaDoc newValue,
88                                   int newIndex) {
89         return super.compareProperty(propertyName, curBean,curValue,curIndex,newBean,newValue, newIndex);
90     }
91 }
92
Popular Tags