KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > event > ConfigChangeCategory


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /**
25  * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
26  *
27  * Copyright 2001-2002 by iPlanet/Sun Microsystems, Inc.,
28  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
29  * All rights reserved.
30  */

31 package com.sun.enterprise.admin.event;
32
33 import java.util.regex.Pattern JavaDoc;
34
35 /**
36  * Configuration change category. Configuration changes can be categorized by
37  * their associated attributes. All config attributes are identified by their
38  * XPath location and a regular expression matching one or more attribues XPath
39  * defines a category of Configuration Changes.
40  */

41 public class ConfigChangeCategory {
42
43     private String JavaDoc configChangeCategoryName;
44     private Pattern JavaDoc configXPathPattern;
45
46     /**
47      * Create a new ConfigChangeCategory
48      */

49     public ConfigChangeCategory() {
50     }
51
52     /**
53      * Create a new ConfigChangeCategory using specified name and regular
54      * expression pattern expressed as string.
55      * @throws PatternSyntaxException if regular expression can not be compiled
56      */

57     public ConfigChangeCategory(String JavaDoc name, String JavaDoc regex) {
58         configChangeCategoryName = name;
59         configXPathPattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
60     }
61
62     /**
63      * Create a new ConfigChangeCategory using specified name and regular
64      * expression pattern.
65      */

66     public ConfigChangeCategory(String JavaDoc name, Pattern JavaDoc regex) {
67         configChangeCategoryName = name;
68         configXPathPattern = regex;
69     }
70
71     /**
72      * Get name of this configuration change category.
73      */

74     public String JavaDoc getName() {
75         return configChangeCategoryName;
76     }
77
78     /**
79      * Set name of this configuration change category to specified value.
80      */

81     public void setName(String JavaDoc name) {
82         configChangeCategoryName = name;
83     }
84
85     /**
86      * Get regular expression pattern on attribute XPath that defines this
87      * category.
88      */

89     public Pattern JavaDoc getConfigXPathPattern() {
90         return configXPathPattern;
91     }
92
93     /**
94      * Set regular expression pattern over attribute XPath that defines this
95      * category.
96      * @throws PatternSyntaxException if regular expression can not be compiled
97      */

98     public void setConfigXPathPattern(String JavaDoc regex) {
99         configXPathPattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
100     }
101
102     /**
103      * Set regular expression pattern over attribute XPath that defines this
104      * category.
105      */

106     public void setConfigXPathPattern(Pattern JavaDoc regex) {
107         configXPathPattern = regex;
108     }
109
110     /**
111      * Two config change categories are same if they share the same regular
112      * expression pattern (irrespective of the name given to them).
113      */

114     public boolean equals(ConfigChangeCategory other) {
115         if (configXPathPattern == null) {
116             if (other.configXPathPattern == null) {
117                 return ((configChangeCategoryName != null) ?
118                         configChangeCategoryName.equals(
119                             other.configChangeCategoryName) :
120                         (other.configChangeCategoryName == null));
121             } else {
122                 return false;
123             }
124         } else {
125             return configXPathPattern.equals(other.configXPathPattern);
126         }
127     }
128 }
129
Popular Tags