KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > css > engine > sac > CSSPseudoClassCondition


1 /*
2
3    Copyright 2002 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.css.engine.sac;
19
20 import java.util.Set JavaDoc;
21
22 import org.apache.batik.css.engine.CSSStylableElement;
23 import org.w3c.dom.Element JavaDoc;
24
25 /**
26  * This class provides an implementation of the
27  * {@link org.w3c.css.sac.AttributeCondition} interface.
28  *
29  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
30  * @version $Id: CSSPseudoClassCondition.java,v 1.4 2004/08/18 07:12:51 vhardy Exp $
31  */

32 public class CSSPseudoClassCondition extends AbstractAttributeCondition {
33     /**
34      * The namespaceURI.
35      */

36     protected String JavaDoc namespaceURI;
37
38     /**
39      * Creates a new CSSAttributeCondition object.
40      */

41     public CSSPseudoClassCondition(String JavaDoc namespaceURI, String JavaDoc value) {
42     super(value);
43     this.namespaceURI = namespaceURI;
44     }
45
46     /**
47      * Indicates whether some other object is "equal to" this one.
48      * @param obj the reference object with which to compare.
49      */

50     public boolean equals(Object JavaDoc obj) {
51     if (!super.equals(obj)) {
52         return false;
53     }
54     CSSPseudoClassCondition c = (CSSPseudoClassCondition)obj;
55     return c.namespaceURI.equals(namespaceURI);
56     }
57
58     /**
59      * <b>SAC</b>: Implements {@link
60      * org.w3c.css.sac.Condition#getConditionType()}.
61      */

62     public short getConditionType() {
63     return SAC_PSEUDO_CLASS_CONDITION;
64     }
65     
66     /**
67      * <b>SAC</b>: Implements {@link
68      * org.w3c.css.sac.AttributeCondition#getNamespaceURI()}.
69      */

70     public String JavaDoc getNamespaceURI() {
71     return namespaceURI;
72     }
73
74     /**
75      * <b>SAC</b>: Implements {@link
76      * org.w3c.css.sac.AttributeCondition#getLocalName()}.
77      */

78     public String JavaDoc getLocalName() {
79     return null;
80     }
81
82     /**
83      * <b>SAC</b>: Implements {@link
84      * org.w3c.css.sac.AttributeCondition#getSpecified()}.
85      */

86     public boolean getSpecified() {
87     return false;
88     }
89
90     /**
91      * Tests whether this selector matches the given element.
92      */

93     public boolean match(Element e, String JavaDoc pseudoE) {
94     return (e instanceof CSSStylableElement)
95         ? ((CSSStylableElement)e).isPseudoInstanceOf(getValue())
96         : false;
97     }
98
99     /**
100      * Fills the given set with the attribute names found in this selector.
101      */

102     public void fillAttributeSet(Set JavaDoc attrSet) {
103     }
104
105     /**
106      * Returns a text representation of this object.
107      */

108     public String JavaDoc toString() {
109     return ":" + getValue();
110     }
111 }
112
Popular Tags