KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.w3c.css.sac.CSSException;
21 import org.w3c.css.sac.CharacterDataSelector;
22 import org.w3c.css.sac.Condition;
23 import org.w3c.css.sac.ConditionalSelector;
24 import org.w3c.css.sac.DescendantSelector;
25 import org.w3c.css.sac.ElementSelector;
26 import org.w3c.css.sac.NegativeSelector;
27 import org.w3c.css.sac.ProcessingInstructionSelector;
28 import org.w3c.css.sac.Selector;
29 import org.w3c.css.sac.SelectorFactory;
30 import org.w3c.css.sac.SiblingSelector;
31 import org.w3c.css.sac.SimpleSelector;
32
33 /**
34  * This class implements the {@link org.w3c.css.sac.SelectorFactory} interface.
35  *
36  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
37  * @version $Id: CSSSelectorFactory.java,v 1.3 2004/08/18 07:12:51 vhardy Exp $
38  */

39 public class CSSSelectorFactory implements SelectorFactory {
40
41     /**
42      * The instance of this class.
43      */

44     public final static SelectorFactory INSTANCE = new CSSSelectorFactory();
45
46     /**
47      * This class does not need to be instantiated.
48      */

49     protected CSSSelectorFactory() {
50     }
51
52     /**
53      * <b>SAC</b>: Implements {@link
54      * SelectorFactory#createConditionalSelector(SimpleSelector,Condition)}.
55      */

56     public ConditionalSelector createConditionalSelector
57         (SimpleSelector selector,
58          Condition condition)
59     throws CSSException {
60     return new CSSConditionalSelector(selector, condition);
61     }
62
63     /**
64      * <b>SAC</b>: Implements {@link
65      * org.w3c.css.sac.SelectorFactory#createAnyNodeSelector()}.
66      */

67     public SimpleSelector createAnyNodeSelector() throws CSSException {
68     throw new CSSException("Not implemented in CSS2");
69     }
70
71     /**
72      * <b>SAC</b>: Implements {@link
73      * org.w3c.css.sac.SelectorFactory#createRootNodeSelector()}.
74      */

75     public SimpleSelector createRootNodeSelector() throws CSSException {
76     throw new CSSException("Not implemented in CSS2");
77     }
78
79     /**
80      * <b>SAC</b>: Implements {@link
81      * org.w3c.css.sac.SelectorFactory#createNegativeSelector(SimpleSelector)}.
82      */

83     public NegativeSelector createNegativeSelector(SimpleSelector selector)
84     throws CSSException {
85     throw new CSSException("Not implemented in CSS2");
86     }
87
88     /**
89      * <b>SAC</b>: Implements {@link
90      * org.w3c.css.sac.SelectorFactory#createElementSelector(String,String)}.
91      */

92     public ElementSelector createElementSelector(String JavaDoc namespaceURI,
93                                                  String JavaDoc tagName)
94     throws CSSException {
95     return new CSSElementSelector(namespaceURI, tagName);
96     }
97
98     /**
99      * <b>SAC</b>: Implements {@link
100      * org.w3c.css.sac.SelectorFactory#createTextNodeSelector(String)}.
101      */

102     public CharacterDataSelector createTextNodeSelector(String JavaDoc data)
103     throws CSSException {
104     throw new CSSException("Not implemented in CSS2");
105     }
106
107     /**
108      * <b>SAC</b>: Implements {@link
109      * org.w3c.css.sac.SelectorFactory#createCDataSectionSelector(String)}.
110      */

111     public CharacterDataSelector createCDataSectionSelector(String JavaDoc data)
112     throws CSSException {
113     throw new CSSException("Not implemented in CSS2");
114     }
115
116     /**
117      * <b>SAC</b>: Implements {@link
118      * SelectorFactory#createProcessingInstructionSelector(String,String)}.
119      */

120     public ProcessingInstructionSelector createProcessingInstructionSelector
121     (String JavaDoc target,
122      String JavaDoc data) throws CSSException {
123     throw new CSSException("Not implemented in CSS2");
124     }
125
126     /**
127      * <b>SAC</b>: Implements {@link
128      * org.w3c.css.sac.SelectorFactory#createCommentSelector(String)}.
129      */

130     public CharacterDataSelector createCommentSelector(String JavaDoc data)
131     throws CSSException {
132     throw new CSSException("Not implemented in CSS2");
133     }
134
135     /**
136      * <b>SAC</b>: Implements {@link
137      * SelectorFactory#createPseudoElementSelector(String,String)}.
138      */

139     public ElementSelector createPseudoElementSelector(String JavaDoc namespaceURI,
140                                String JavaDoc pseudoName)
141     throws CSSException {
142     return new CSSPseudoElementSelector(namespaceURI, pseudoName);
143     }
144
145     /**
146      * <b>SAC</b>: Implements {@link
147      * SelectorFactory#createDescendantSelector(Selector,SimpleSelector)}.
148      */

149     public DescendantSelector createDescendantSelector
150         (Selector parent,
151          SimpleSelector descendant)
152     throws CSSException {
153     return new CSSDescendantSelector(parent, descendant);
154     }
155
156     /**
157      * <b>SAC</b>: Implements {@link
158      * SelectorFactory#createChildSelector(Selector,SimpleSelector)}.
159      */

160     public DescendantSelector createChildSelector(Selector parent,
161                           SimpleSelector child)
162     throws CSSException {
163     return new CSSChildSelector(parent, child);
164     }
165
166     /**
167      * <b>SAC</b>: Implements {@link
168      * SelectorFactory#createDirectAdjacentSelector(short,Selector,SimpleSelector)}.
169      */

170     public SiblingSelector createDirectAdjacentSelector
171         (short nodeType,
172          Selector child,
173          SimpleSelector directAdjacent)
174     throws CSSException {
175     return new CSSDirectAdjacentSelector(nodeType, child,
176                                                directAdjacent);
177     }
178 }
179
Popular Tags