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

19 package org.apache.batik.css.parser;
20
21 import org.w3c.css.sac.AttributeCondition;
22 import org.w3c.css.sac.CSSException;
23 import org.w3c.css.sac.CombinatorCondition;
24 import org.w3c.css.sac.Condition;
25 import org.w3c.css.sac.ConditionFactory;
26 import org.w3c.css.sac.ContentCondition;
27 import org.w3c.css.sac.LangCondition;
28 import org.w3c.css.sac.NegativeCondition;
29 import org.w3c.css.sac.PositionalCondition;
30
31
32 /**
33  * This class provides an implementation of the
34  * {@link org.w3c.css.sac.ConditionFactory} interface.
35  *
36  * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
37  * @version $Id: DefaultConditionFactory.java 1733416 2016-03-03 07:07:13Z gadams $
38  */

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

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

51     protected DefaultConditionFactory() {
52     }
53
54     /**
55      * <b>SAC</b>: Implements {@link
56      * ConditionFactory#createAndCondition(Condition,Condition)}.
57      */

58     public CombinatorCondition createAndCondition(Condition first,
59                                                   Condition second)
60         throws CSSException {
61         return new DefaultAndCondition(first, second);
62     }
63
64     /**
65      * <b>SAC</b>: Implements {@link
66      * ConditionFactory#createOrCondition(Condition,Condition)}.
67      */

68     public CombinatorCondition createOrCondition(Condition first,
69                                                  Condition second)
70         throws CSSException {
71         throw new CSSException("Not implemented in CSS2");
72     }
73
74     /**
75      * <b>SAC</b>: Implements {@link
76      * org.w3c.css.sac.ConditionFactory#createNegativeCondition(Condition)}.
77      */

78     public NegativeCondition createNegativeCondition(Condition condition)
79         throws CSSException {
80         throw new CSSException("Not implemented in CSS2");
81     }
82
83     /**
84      * <b>SAC</b>: Implements {@link
85      * ConditionFactory#createPositionalCondition(int,boolean,boolean)}.
86      */

87     public PositionalCondition createPositionalCondition(int position,
88                                                          boolean typeNode,
89                                                          boolean type)
90         throws CSSException {
91         throw new CSSException("Not implemented in CSS2");
92     }
93
94     /**
95      * <b>SAC</b>: Implements {@link
96      *ConditionFactory#createAttributeCondition(String,String,boolean,String)}.
97      */

98     public AttributeCondition createAttributeCondition(String localName,
99                                                        String namespaceURI,
100                                                        boolean specified,
101                                                        String value)
102         throws CSSException {
103         return new DefaultAttributeCondition(localName, namespaceURI,
104                                              specified, value);
105     }
106
107     /**
108      * <b>SAC</b>: Implements {@link
109      * org.w3c.css.sac.ConditionFactory#createIdCondition(String)}.
110      */

111     public AttributeCondition createIdCondition(String value)
112         throws CSSException {
113         return new DefaultIdCondition(value);
114     }
115
116     /**
117      * <b>SAC</b>: Implements {@link
118      * org.w3c.css.sac.ConditionFactory#createLangCondition(String)}.
119      */

120     public LangCondition createLangCondition(String lang) throws CSSException {
121         return new DefaultLangCondition(lang);
122     }
123
124     /**
125      * <b>SAC</b>: Implements {@link
126  ConditionFactory#createOneOfAttributeCondition(String,String,boolean,String)}.
127      */

128     public AttributeCondition createOneOfAttributeCondition(String localName,
129                                                             String nsURI,
130                                                             boolean specified,
131                                                             String value)
132         throws CSSException {
133         return new DefaultOneOfAttributeCondition(localName, nsURI, specified,
134                                                 value);
135     }
136
137     /**
138      * <b>SAC</b>: Implements {@link
139      * ConditionFactory#createBeginHyphenAttributeCondition(String,String,boolean,String)}.
140      */

141     public AttributeCondition createBeginHyphenAttributeCondition
142         (String localName,
143          String namespaceURI,
144          boolean specified,
145          String value)
146         throws CSSException {
147         return new DefaultBeginHyphenAttributeCondition
148             (localName, namespaceURI, specified, value);
149     }
150
151     /**
152      * <b>SAC</b>: Implements {@link
153      * org.w3c.css.sac.ConditionFactory#createClassCondition(String,String)}.
154      */

155     public AttributeCondition createClassCondition(String namespaceURI,
156                                                    String value)
157         throws CSSException {
158         return new DefaultClassCondition(namespaceURI, value);
159     }
160
161     /**
162      * <b>SAC</b>: Implements {@link
163      * ConditionFactory#createPseudoClassCondition(String,String)}.
164      */

165     public AttributeCondition createPseudoClassCondition(String namespaceURI,
166                                                          String value)
167         throws CSSException {
168         return new DefaultPseudoClassCondition(namespaceURI, value);
169     }
170
171     /**
172      * <b>SAC</b>: Implements {@link
173      * org.w3c.css.sac.ConditionFactory#createOnlyChildCondition()}.
174      */

175     public Condition createOnlyChildCondition() throws CSSException {
176         throw new CSSException("Not implemented in CSS2");
177     }
178
179     /**
180      * <b>SAC</b>: Implements {@link
181      * org.w3c.css.sac.ConditionFactory#createOnlyTypeCondition()}.
182      */

183     public Condition createOnlyTypeCondition() throws CSSException {
184         throw new CSSException("Not implemented in CSS2");
185     }
186
187     /**
188      * <b>SAC</b>: Implements {@link
189      * org.w3c.css.sac.ConditionFactory#createContentCondition(String)}.
190      */

191     public ContentCondition createContentCondition(String data)
192         throws CSSException {
193         throw new CSSException("Not implemented in CSS2");
194     }
195 }
196