KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xmlc > metadata > URLEdit


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: URLEdit.java,v 1.2 2005/01/26 08:29:24 jkjome Exp $
22  */

23
24 package org.enhydra.xml.xmlc.metadata;
25
26 import org.enhydra.xml.xmlc.XMLCException;
27 import org.w3c.dom.Document JavaDoc;
28
29 /**
30  * Abstract type uses as a base for all URL editing definition.
31  */

32 public abstract class URLEdit extends ElementEdit {
33     /**
34      * Attribute names.
35      */

36     private static final String JavaDoc EDIT_ATTRS_ATTR = "editAttrs";
37     
38     /**
39      * Cache of parsed attributes.
40      */

41     private String JavaDoc[] editAttrs;
42
43     /**
44      * Constructor.
45      */

46     protected URLEdit(Document JavaDoc ownerDoc,
47                       String JavaDoc tagName) {
48         super(ownerDoc, tagName);
49     }
50
51     /**
52      * Get the editAttrs value.
53      */

54     public String JavaDoc[] getEditAttrs() {
55         return getStringArrayAttribute(EDIT_ATTRS_ATTR);
56     }
57
58     /**
59      * Set the editAttrs attribute value.
60      */

61     public void setEditAttrs(String JavaDoc[] values) {
62         setRemoveStringArrayAttribute(EDIT_ATTRS_ATTR, values);
63     }
64
65     /**
66      * Add an attribute name to the editAttr attribute value.
67      */

68     public void addEditAttrs(String JavaDoc value) {
69         addStringArrayAttribute(EDIT_ATTRS_ATTR, value);
70     }
71
72     /**
73      * Determine if an id matches the element id constraints on
74      * this object. If there are no id constraints, all elements
75      * match.
76      */

77     public boolean matchesEditAttrConstraints(String JavaDoc attrName,
78                                               boolean ignoreCase) {
79         if (editAttrs == null) {
80             editAttrs = getEditAttrs();
81         }
82         if (editAttrs.length == 0) {
83             return true;
84         }
85         if (ignoreCase) {
86             for (int idx = 0; idx < editAttrs.length; idx++) {
87                 if (attrName.equalsIgnoreCase(editAttrs[idx])) {
88                     return true;
89                 }
90             }
91         } else {
92             for (int idx = 0; idx < editAttrs.length; idx++) {
93                 if (attrName.equals(editAttrs[idx])) {
94                     return true;
95                 }
96             }
97         }
98         return false;
99     }
100
101     /**
102      * Complete modifications to DOM. This clears cache of parsed
103      * attributes.
104      * @see MetaDataElement#completeModifications
105      */

106     protected void completeModifications() throws XMLCException {
107         super.completeModifications();
108         editAttrs = null;
109     }
110 }
111
Popular Tags