001: /*
002:
003: ============================================================================
004: The Apache Software License, Version 1.1
005: ============================================================================
006:
007: Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
008:
009: Redistribution and use in source and binary forms, with or without modifica-
010: tion, are permitted provided that the following conditions are met:
011:
012: 1. Redistributions of source code must retain the above copyright notice,
013: this list of conditions and the following disclaimer.
014:
015: 2. Redistributions in binary form must reproduce the above copyright notice,
016: this list of conditions and the following disclaimer in the documentation
017: and/or other materials provided with the distribution.
018:
019: 3. The end-user documentation included with the redistribution, if any, must
020: include the following acknowledgment: "This product includes software
021: developed by the Apache Software Foundation (http://www.apache.org/)."
022: Alternately, this acknowledgment may appear in the software itself, if
023: and wherever such third-party acknowledgments normally appear.
024:
025: 4. The names "Batik" and "Apache Software Foundation" must not be
026: used to endorse or promote products derived from this software without
027: prior written permission. For written permission, please contact
028: apache@apache.org.
029:
030: 5. Products derived from this software may not be called "Apache", nor may
031: "Apache" appear in their name, without prior written permission of the
032: Apache Software Foundation.
033:
034: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
035: INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
036: FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
037: APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
038: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
039: DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
040: OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
041: ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
042: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
043: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
044:
045: This software consists of voluntary contributions made by many individuals
046: on behalf of the Apache Software Foundation. For more information on the
047: Apache Software Foundation, please see <http://www.apache.org/>.
048:
049: */
050:
051: package org.apache.batik.css.parser;
052:
053: import org.w3c.css.sac.AttributeCondition;
054: import org.w3c.css.sac.CSSException;
055: import org.w3c.css.sac.CombinatorCondition;
056: import org.w3c.css.sac.Condition;
057: import org.w3c.css.sac.ConditionFactory;
058: import org.w3c.css.sac.ContentCondition;
059: import org.w3c.css.sac.LangCondition;
060: import org.w3c.css.sac.NegativeCondition;
061: import org.w3c.css.sac.PositionalCondition;
062:
063: /**
064: * This class provides an implementation of the
065: * {@link org.w3c.css.sac.ConditionFactory} interface.
066: *
067: * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
068: * @version $Id$
069: */
070:
071: public class DefaultConditionFactory implements ConditionFactory {
072:
073: /**
074: * The instance of this class.
075: */
076: public final static ConditionFactory INSTANCE = new DefaultConditionFactory();
077:
078: /**
079: * This class does not need to be instantiated.
080: */
081: protected DefaultConditionFactory() {
082: }
083:
084: /**
085: * <b>SAC</b>: Implements {@link
086: * ConditionFactory#createAndCondition(Condition,Condition)}.
087: */
088: public CombinatorCondition createAndCondition(Condition first,
089: Condition second) throws CSSException {
090: return new DefaultAndCondition(first, second);
091: }
092:
093: /**
094: * <b>SAC</b>: Implements {@link
095: * ConditionFactory#createOrCondition(Condition,Condition)}.
096: */
097: public CombinatorCondition createOrCondition(Condition first,
098: Condition second) throws CSSException {
099: throw new CSSException("Not implemented in CSS2");
100: }
101:
102: /**
103: * <b>SAC</b>: Implements {@link
104: * org.w3c.css.sac.ConditionFactory#createNegativeCondition(Condition)}.
105: */
106: public NegativeCondition createNegativeCondition(Condition condition)
107: throws CSSException {
108: throw new CSSException("Not implemented in CSS2");
109: }
110:
111: /**
112: * <b>SAC</b>: Implements {@link
113: * ConditionFactory#createPositionalCondition(int,boolean,boolean)}.
114: */
115: public PositionalCondition createPositionalCondition(int position,
116: boolean typeNode, boolean type) throws CSSException {
117: throw new CSSException("Not implemented in CSS2");
118: }
119:
120: /**
121: * <b>SAC</b>: Implements {@link
122: *ConditionFactory#createAttributeCondition(String,String,boolean,String)}.
123: */
124: public AttributeCondition createAttributeCondition(
125: String localName, String namespaceURI, boolean specified,
126: String value) throws CSSException {
127: return new DefaultAttributeCondition(localName, namespaceURI,
128: specified, value);
129: }
130:
131: /**
132: * <b>SAC</b>: Implements {@link
133: * org.w3c.css.sac.ConditionFactory#createIdCondition(String)}.
134: */
135: public AttributeCondition createIdCondition(String value)
136: throws CSSException {
137: return new DefaultIdCondition(value);
138: }
139:
140: /**
141: * <b>SAC</b>: Implements {@link
142: * org.w3c.css.sac.ConditionFactory#createLangCondition(String)}.
143: */
144: public LangCondition createLangCondition(String lang)
145: throws CSSException {
146: return new DefaultLangCondition(lang);
147: }
148:
149: /**
150: * <b>SAC</b>: Implements {@link
151: ConditionFactory#createOneOfAttributeCondition(String,String,boolean,String)}.
152: */
153: public AttributeCondition createOneOfAttributeCondition(
154: String localName, String nsURI, boolean specified,
155: String value) throws CSSException {
156: return new DefaultOneOfAttributeCondition(localName, nsURI,
157: specified, value);
158: }
159:
160: /**
161: * <b>SAC</b>: Implements {@link
162: * ConditionFactory#createBeginHyphenAttributeCondition(String,String,boolean,String)}.
163: */
164: public AttributeCondition createBeginHyphenAttributeCondition(
165: String localName, String namespaceURI, boolean specified,
166: String value) throws CSSException {
167: return new DefaultBeginHyphenAttributeCondition(localName,
168: namespaceURI, specified, value);
169: }
170:
171: /**
172: * <b>SAC</b>: Implements {@link
173: * org.w3c.css.sac.ConditionFactory#createClassCondition(String,String)}.
174: */
175: public AttributeCondition createClassCondition(String namespaceURI,
176: String value) throws CSSException {
177: return new DefaultClassCondition(namespaceURI, value);
178: }
179:
180: /**
181: * <b>SAC</b>: Implements {@link
182: * ConditionFactory#createPseudoClassCondition(String,String)}.
183: */
184: public AttributeCondition createPseudoClassCondition(
185: String namespaceURI, String value) throws CSSException {
186: return new DefaultPseudoClassCondition(namespaceURI, value);
187: }
188:
189: /**
190: * <b>SAC</b>: Implements {@link
191: * org.w3c.css.sac.ConditionFactory#createOnlyChildCondition()}.
192: */
193: public Condition createOnlyChildCondition() throws CSSException {
194: throw new CSSException("Not implemented in CSS2");
195: }
196:
197: /**
198: * <b>SAC</b>: Implements {@link
199: * org.w3c.css.sac.ConditionFactory#createOnlyTypeCondition()}.
200: */
201: public Condition createOnlyTypeCondition() throws CSSException {
202: throw new CSSException("Not implemented in CSS2");
203: }
204:
205: /**
206: * <b>SAC</b>: Implements {@link
207: * org.w3c.css.sac.ConditionFactory#createContentCondition(String)}.
208: */
209: public ContentCondition createContentCondition(String data)
210: throws CSSException {
211: throw new CSSException("Not implemented in CSS2");
212: }
213: }
|