KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > css > parser > DefaultSelectorFactory


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.parser;
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: DefaultSelectorFactory.java,v 1.3 2004/08/18 07:13:03 vhardy Exp $
38  */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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