Source code: com/steadystate/css/parser/selectors/SelectorFactoryImpl.java
1 /*
2 * SelectorFactoryImpl.java
3 *
4 * Steady State CSS2 Parser
5 *
6 * Copyright (C) 1999, 2002 Steady State Software Ltd. All rights reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * To contact the authors of the library, write to Steady State Software Ltd.,
23 * 49 Littleworth, Wing, Buckinghamshire, LU7 0JX, England
24 *
25 * http://www.steadystate.com/css/
26 * mailto:css@steadystate.co.uk
27 *
28 * $Id: SelectorFactoryImpl.java,v 1.1.1.1 2003/12/28 21:23:43 davidsch Exp $
29 */
30
31 package com.steadystate.css.parser.selectors;
32
33 import org.w3c.css.sac.*;
34
35 public class SelectorFactoryImpl implements SelectorFactory {
36
37 public ConditionalSelector createConditionalSelector(
38 SimpleSelector selector,
39 Condition condition) throws CSSException {
40 return new ConditionalSelectorImpl(selector, condition);
41 }
42
43 public SimpleSelector createAnyNodeSelector() throws CSSException {
44 throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
45 }
46
47 public SimpleSelector createRootNodeSelector() throws CSSException {
48 throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
49 }
50
51 public NegativeSelector createNegativeSelector(SimpleSelector selector)
52 throws CSSException {
53 throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
54 }
55
56 public ElementSelector createElementSelector(String namespaceURI, String localName)
57 throws CSSException {
58 if (namespaceURI != null) {
59 throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
60 } else {
61 return new ElementSelectorImpl(localName);
62 }
63 }
64
65 public CharacterDataSelector createTextNodeSelector(String data)
66 throws CSSException {
67 throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
68 }
69
70 public CharacterDataSelector createCDataSectionSelector(String data)
71 throws CSSException {
72 throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
73 }
74
75 public ProcessingInstructionSelector createProcessingInstructionSelector(
76 String target,
77 String data) throws CSSException {
78 throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
79 }
80
81 public CharacterDataSelector createCommentSelector(String data)
82 throws CSSException {
83 throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
84 }
85
86 public ElementSelector createPseudoElementSelector(
87 String namespaceURI,
88 String pseudoName) throws CSSException {
89 if (namespaceURI != null) {
90 throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
91 } else {
92 return new PseudoElementSelectorImpl(pseudoName);
93 }
94 }
95
96 public DescendantSelector createDescendantSelector(
97 Selector parent,
98 SimpleSelector descendant) throws CSSException {
99 return new DescendantSelectorImpl(parent, descendant);
100 }
101
102 public DescendantSelector createChildSelector(
103 Selector parent,
104 SimpleSelector child) throws CSSException {
105 return new ChildSelectorImpl(parent, child);
106 }
107
108 public SiblingSelector createDirectAdjacentSelector(
109 short nodeType,
110 Selector child,
111 SimpleSelector directAdjacent) throws CSSException {
112 return new DirectAdjacentSelectorImpl(nodeType, child, directAdjacent);
113 }
114 }