hillion     02/03/18 02:31:10

  Added:       sources/org/apache/batik/css/engine/sac
                        AbstractAttributeCondition.java
                        AbstractCombinatorCondition.java
                        AbstractDescendantSelector.java
                        AbstractElementSelector.java
                        AbstractSiblingSelector.java CSSAndCondition.java
                        CSSAttributeCondition.java
                        CSSBeginHyphenAttributeCondition.java
                        CSSChildSelector.java CSSClassCondition.java
                        CSSConditionFactory.java
                        CSSConditionalSelector.java
                        CSSDescendantSelector.java
                        CSSDirectAdjacentSelector.java
                        CSSElementSelector.java CSSIdCondition.java
                        CSSLangCondition.java
                        CSSOneOfAttributeCondition.java
                        CSSPseudoClassCondition.java
                        CSSPseudoElementSelector.java
                        CSSSelectorFactory.java ExtendedCondition.java
                        ExtendedSelector.java
  Log:
  - css engine commit 2
  
  Revision  Changes    Path
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/AbstractAttributeCondition.java
  
  Index: AbstractAttributeCondition.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.AttributeCondition;
  
  /**
   * This class provides an abstract implementation of the {@link
   * org.w3c.css.sac.AttributeCondition} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: AbstractAttributeCondition.java,v 1.1 2002/03/18 10:31:09 hillion 
Exp $
   */
  public abstract class AbstractAttributeCondition
      implements AttributeCondition,
               ExtendedCondition {
  
      /**
       * The attribute value.
       */
      protected String value;
  
      /**
       * Creates a new AbstractAttributeCondition object.
       */
      protected AbstractAttributeCondition(String value) {
        this.value = value;
      }
  
      /**
       * Indicates whether some other object is "equal to" this one.
       * @param obj the reference object with which to compare.
       */
      public boolean equals(Object obj) {
        if (obj == null || !(obj.getClass() != getClass())) {
            return false;
        }
        AbstractAttributeCondition c = (AbstractAttributeCondition)obj;
        return c.value.equals(value);
      }
  
      /**
       * Returns the specificity of this condition.
       */
      public int getSpecificity() {
        return 1 << 8;
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.AttributeCondition#getValue()}.
       */
      public String getValue() {
        return value;
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/AbstractCombinatorCondition.java
  
  Index: AbstractCombinatorCondition.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.CombinatorCondition;
  import org.w3c.css.sac.Condition;
  
  /**
   * This class provides an abstract implementation of the {@link
   * org.w3c.css.sac.CombinatorCondition} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: AbstractCombinatorCondition.java,v 1.1 2002/03/18 10:31:09 hillion 
Exp $
   */
  public abstract class AbstractCombinatorCondition
      implements CombinatorCondition,
                 ExtendedCondition {
  
      /**
       * The first condition.
       */
      protected Condition firstCondition;
  
      /**
       * The second condition.
       */
      protected Condition secondCondition;
  
      /**
       * Creates a new CombinatorCondition object.
       */
      protected AbstractCombinatorCondition(Condition c1, Condition c2) {
        firstCondition = c1;
        secondCondition = c2;
      }
  
      /**
       * Indicates whether some other object is "equal to" this one.
       * @param obj the reference object with which to compare.
       */
      public boolean equals(Object obj) {
        if (obj == null || !(obj.getClass() != getClass())) {
            return false;
        }
        AbstractCombinatorCondition c = (AbstractCombinatorCondition)obj;
        return c.firstCondition.equals(firstCondition) &&
               c.secondCondition.equals(secondCondition);
      }
  
      /**
       * Returns the specificity of this condition.
       */
      public int getSpecificity() {
        return ((ExtendedCondition)getFirstCondition()).getSpecificity() +
                 ((ExtendedCondition)getSecondCondition()).getSpecificity();
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.CombinatorCondition#getFirstCondition()}.
       */    
      public Condition getFirstCondition() {
        return firstCondition;
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.CombinatorCondition#getSecondCondition()}.
       */    
      public Condition getSecondCondition() {
        return secondCondition;
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/AbstractDescendantSelector.java
  
  Index: AbstractDescendantSelector.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.DescendantSelector;
  import org.w3c.css.sac.Selector;
  import org.w3c.css.sac.SimpleSelector;
  
  /**
   * This class provides an abstract implementation of the {@link
   * org.w3c.css.sac.DescendantSelector} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: AbstractDescendantSelector.java,v 1.1 2002/03/18 10:31:09 hillion 
Exp $
   */
  public abstract class AbstractDescendantSelector
      implements DescendantSelector,
               ExtendedSelector {
  
      /**
       * The ancestor selector.
       */
      protected Selector ancestorSelector;
  
      /**
       * The simple selector.
       */
      protected SimpleSelector simpleSelector;
  
      /**
       * Creates a new DescendantSelector object.
       */
      protected AbstractDescendantSelector(Selector ancestor,
                                           SimpleSelector simple) {
        ancestorSelector = ancestor;
        simpleSelector = simple;
      }
  
      /**
       * Indicates whether some other object is "equal to" this one.
       * @param obj the reference object with which to compare.
       */
      public boolean equals(Object obj) {
        if (obj == null || !(obj.getClass() != getClass())) {
            return false;
        }
        AbstractDescendantSelector s = (AbstractDescendantSelector)obj;
        return s.simpleSelector.equals(simpleSelector);
      }
  
      /**
       * Returns the specificity of this selector.
       */
      public int getSpecificity() {
        return ((ExtendedSelector)ancestorSelector).getSpecificity() +
                       ((ExtendedSelector)simpleSelector).getSpecificity();
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.DescendantSelector#getAncestorSelector()}.
       */    
      public Selector getAncestorSelector() {
        return ancestorSelector;
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.DescendantSelector#getSimpleSelector()}.
       */    
      public SimpleSelector getSimpleSelector() {
        return simpleSelector;
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/AbstractElementSelector.java
  
  Index: AbstractElementSelector.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.ElementSelector;
  
  /**
   * This class provides an abstract implementation of the ElementSelector
   * interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: AbstractElementSelector.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public abstract class AbstractElementSelector
      implements ElementSelector,
               ExtendedSelector {
  
      /**
       * The namespace URI.
       */
      protected String namespaceURI;
  
      /**
       * The local name.
       */
      protected String localName;
  
      /**
       * Creates a new ElementSelector object.
       */
      protected AbstractElementSelector(String uri, String name) {
        namespaceURI = uri;
        localName    = name;
      }
  
      /**
       * Indicates whether some other object is "equal to" this one.
       * @param obj the reference object with which to compare.
       */
      public boolean equals(Object obj) {
        if (obj == null || !(obj.getClass() != getClass())) {
            return false;
        }
        AbstractElementSelector s = (AbstractElementSelector)obj;
        return s.namespaceURI.equals(namespaceURI) &&
               s.localName.equals(localName);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.ElementSelector#getNamespaceURI()}.
       */
      public String getNamespaceURI() {
        return namespaceURI;
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.ElementSelector#getLocalName()}.
       */
      public String getLocalName() {
        return localName;
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/AbstractSiblingSelector.java
  
  Index: AbstractSiblingSelector.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.SiblingSelector;
  import org.w3c.css.sac.Selector;
  import org.w3c.css.sac.SimpleSelector;
  
  /**
   * This class provides an abstract implementation of the {@link
   * org.w3c.css.sac.SiblingSelector} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: AbstractSiblingSelector.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public abstract class AbstractSiblingSelector
      implements SiblingSelector,
               ExtendedSelector {
  
      /**
       * The node type.
       */
      protected short nodeType;
  
      /**
       * The selector.
       */
      protected Selector selector;
  
      /**
       * The simple selector.
       */
      protected SimpleSelector simpleSelector;
  
      /**
       * Creates a new SiblingSelector object.
       */
      protected AbstractSiblingSelector(short type,
                                        Selector sel,
                                        SimpleSelector simple) {
          nodeType = type;
        selector = sel;
        simpleSelector = simple;
      }
  
      /**
       * Returns the node type.
       */
      public short getNodeType() {
          return nodeType;
      }
  
      /**
       * Indicates whether some other object is "equal to" this one.
       * @param obj the reference object with which to compare.
       */
      public boolean equals(Object obj) {
        if (obj == null || !(obj.getClass() != getClass())) {
            return false;
        }
        AbstractSiblingSelector s = (AbstractSiblingSelector)obj;
        return s.simpleSelector.equals(simpleSelector);
      }
  
      /**
       * Returns the specificity of this selector.
       */
      public int getSpecificity() {
        return ((ExtendedSelector)selector).getSpecificity() +
                       ((ExtendedSelector)simpleSelector).getSpecificity();
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.SiblingSelector#getSelector()}.
       */    
      public Selector getSelector() {
        return selector;
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.SiblingSelector#getSiblingSelector()}.
       */    
      public SimpleSelector getSiblingSelector() {
        return simpleSelector;
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSAndCondition.java
  
  Index: CSSAndCondition.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.Condition;
  import org.w3c.dom.Element;
  
  /**
   * This class provides an implementation of the
   * {@link org.w3c.css.sac.CombinatorCondition} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSAndCondition.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public class CSSAndCondition extends AbstractCombinatorCondition {
      /**
       * Creates a new CombinatorCondition object.
       */
      public CSSAndCondition(Condition c1, Condition c2) {
        super(c1, c2);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Condition#getConditionType()}.
       */    
      public short getConditionType() {
        return SAC_AND_CONDITION;
      }
  
      /**
       * Tests whether this condition matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        return ((ExtendedCondition)getFirstCondition()).match(e, pseudoE) &&
                 ((ExtendedCondition)getSecondCondition()).match(e, pseudoE);
      }
  
      /**
       * Returns a text representation of this object.
       */
      public String toString() {
        return "" + getFirstCondition() + getSecondCondition();
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSAttributeCondition.java
  
  Index: CSSAttributeCondition.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.dom.Element;
  
  /**
   * This class provides an implementation of the
   * {@link org.w3c.css.sac.AttributeCondition} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSAttributeCondition.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public class CSSAttributeCondition extends AbstractAttributeCondition {
      /**
       * The attribute's local name.
       */
      protected String localName;
  
      /**
       * The attribute's namespace URI.
       */
      protected String namespaceURI;
  
      /**
       * Whether this condition applies to specified attributes.
       */
      protected boolean specified;
  
      /**
       * Creates a new CSSAttributeCondition object.
       */
      public CSSAttributeCondition(String localName,
                                   String namespaceURI,
                                   boolean specified,
                                   String value) {
        super(value);
        this.localName = localName;
        this.namespaceURI = namespaceURI;
        this.specified = specified;
      }
  
      /**
       * Indicates whether some other object is "equal to" this one.
       * @param obj the reference object with which to compare.
       */
      public boolean equals(Object obj) {
        if (!super.equals(obj)) {
            return false;
        }
        CSSAttributeCondition c = (CSSAttributeCondition)obj;
        return c.namespaceURI.equals(namespaceURI) &&
               c.localName.equals(localName) &&
               c.specified == specified;
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Condition#getConditionType()}.
       */    
      public short getConditionType() {
        return SAC_ATTRIBUTE_CONDITION;
      }
      
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.AttributeCondition#getNamespaceURI()}.
       */    
      public String getNamespaceURI() {
        return namespaceURI;
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.AttributeCondition#getLocalName()}.
       */
      public String getLocalName() {
        return localName;
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.AttributeCondition#getSpecified()}.
       */
      public boolean getSpecified() {
        return specified;
      }
  
      /**
       * Tests whether this condition matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        String val = getValue();
        if (val == null) {
            return !e.getAttribute(getLocalName()).equals("");
        }
        return e.getAttribute(getLocalName()).equals(val);
      }
  
      /**
       * Returns a text representation of this object.
       */
      public String toString() {
        if (value == null) {
            return "[" + localName + "]";
        }
        return "[" + localName + "=\"" + value + "\"]";
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSBeginHyphenAttributeCondition.java
  
  Index: CSSBeginHyphenAttributeCondition.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.dom.Element;
  
  /**
   * This class provides an implementation of the
   * {@link org.w3c.css.sac.AttributeCondition} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSBeginHyphenAttributeCondition.java,v 1.1 2002/03/18 10:31:09 
hillion Exp $
   */
  public class CSSBeginHyphenAttributeCondition
      extends CSSAttributeCondition {
  
      /**
       * Creates a new CSSAttributeCondition object.
       */
      public CSSBeginHyphenAttributeCondition(String localName,
                                              String namespaceURI,
                                              boolean specified,
                                              String value) {
        super(localName, namespaceURI, specified, value);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Condition#getConditionType()}.
       */    
      public short getConditionType() {
        return SAC_BEGIN_HYPHEN_ATTRIBUTE_CONDITION;
      }
      
      /**
       * Tests whether this condition matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        return e.getAttribute(getLocalName()).startsWith(getValue());
      }
  
      /**
       * Returns a text representation of this object.
       */
      public String toString() {
        return "[" + getLocalName() + "|=\"" + getValue() + "\"]";
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSChildSelector.java
  
  Index: CSSChildSelector.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.Selector;
  import org.w3c.css.sac.SimpleSelector;
  import org.w3c.dom.Element;
  import org.w3c.dom.Node;
  
  /**
   * This class provides an implementation of the
   * {@link org.w3c.css.sac.DescendantSelector} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSChildSelector.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public class CSSChildSelector extends AbstractDescendantSelector {
  
      /**
       * Creates a new CSSChildSelector object.
       */
      public CSSChildSelector(Selector ancestor, SimpleSelector simple) {
        super(ancestor, simple);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Selector#getSelectorType()}.
       */
      public short getSelectorType() {
        return SAC_CHILD_SELECTOR;
      }
  
      /**
       * Tests whether this selector matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        Node n = e.getParentNode();
        if (n != null && n.getNodeType() == Node.ELEMENT_NODE) {
            return ((ExtendedSelector)getAncestorSelector()).match((Element)n,
                                                                     null) &&
                   ((ExtendedSelector)getSimpleSelector()).match(e, pseudoE);
        }
        return false;
      }
  
      /**
       * Returns a representation of the selector.
       */
      public String toString() {
        SimpleSelector s = getSimpleSelector();
        if (s.getSelectorType() == SAC_PSEUDO_ELEMENT_SELECTOR) {
            return "" + getAncestorSelector() + s;
        }
        return getAncestorSelector() + " > " + s;
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSClassCondition.java
  
  Index: CSSClassCondition.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.apache.batik.css.engine.CSSStylableElement;
  
  import org.w3c.dom.Element;
  
  /**
   * This class provides an implementation of the
   * {@link org.w3c.css.sac.AttributeCondition} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSClassCondition.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public class CSSClassCondition extends CSSAttributeCondition {
  
      /**
       * Creates a new CSSAttributeCondition object.
       */
      public CSSClassCondition(String namespaceURI,
                               String value) {
        super("class", namespaceURI, true, value);
      }
      
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Condition#getConditionType()}.
       */    
      public short getConditionType() {
        return SAC_CLASS_CONDITION;
      }
      
      /**
       * Tests whether this condition matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        String attr = ((CSSStylableElement)e).getCSSClass();
        String val = getValue();
        int i = attr.indexOf(val);
        if (i == -1) {
            return false;
        }
        if (i != 0 && !Character.isSpaceChar(attr.charAt(i - 1))) {
            return false;
        }
        int j = i + val.length();
        return (j == attr.length() ||
                (j < attr.length() && Character.isSpaceChar(attr.charAt(j))));
      }
  
      /**
       * Returns a text representation of this object.
       */
      public String toString() {
        return "." + getValue();
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSConditionFactory.java
  
  Index: CSSConditionFactory.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.AttributeCondition;
  import org.w3c.css.sac.CombinatorCondition;
  import org.w3c.css.sac.Condition;
  import org.w3c.css.sac.ConditionFactory;
  import org.w3c.css.sac.ContentCondition;
  import org.w3c.css.sac.CSSException;
  import org.w3c.css.sac.LangCondition;
  import org.w3c.css.sac.NegativeCondition;
  import org.w3c.css.sac.PositionalCondition;
  
  
  /**
   * This class provides an implementation of the
   * {@link org.w3c.css.sac.ConditionFactory} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSConditionFactory.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public class CSSConditionFactory implements ConditionFactory {
  
      /**
       * The instance of this class.
       */
      public final static ConditionFactory INSTANCE = new CSSConditionFactory();
  
      /**
       * This class does not need to be instantiated.
       */
      protected CSSConditionFactory() {
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * ConditionFactory#createAndCondition(Condition,Condition)}.
       */    
      public CombinatorCondition createAndCondition(Condition first,
                                                    Condition second)
        throws CSSException {
        return new CSSAndCondition(first, second);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * ConditionFactory#createOrCondition(Condition,Condition)}.
       */    
      public CombinatorCondition createOrCondition(Condition first,
                                                   Condition second)
        throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.ConditionFactory#createNegativeCondition(Condition)}.
       */    
      public NegativeCondition createNegativeCondition(Condition condition)
        throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * ConditionFactory#createPositionalCondition(int,boolean,boolean)}.
       */    
      public PositionalCondition createPositionalCondition(int position, 
                                                         boolean typeNode, 
                                                         boolean type)
        throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
      
      /**
       * <b>SAC</b>: Implements {@link
       *ConditionFactory#createAttributeCondition(String,String,boolean,String)}.
       */    
      public AttributeCondition createAttributeCondition(String localName,
                                                       String namespaceURI,
                                                       boolean specified,
                                                       String value)
        throws CSSException {
        return new CSSAttributeCondition(localName, namespaceURI, specified,
                                             value);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.ConditionFactory#createIdCondition(String)}.
       */    
      public AttributeCondition createIdCondition(String value)
          throws CSSException {
        return new CSSIdCondition(value);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.ConditionFactory#createLangCondition(String)}.
       */    
      public LangCondition createLangCondition(String lang) throws CSSException {
        return new CSSLangCondition(lang);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
   ConditionFactory#createOneOfAttributeCondition(String,String,boolean,String)}.
       */    
      public AttributeCondition createOneOfAttributeCondition(String localName,
                                                            String nsURI,
                                                            boolean specified,
                                                            String value)
        throws CSSException {
        return new CSSOneOfAttributeCondition(localName, nsURI, specified,
                                                  value);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * 
ConditionFactory#createBeginHyphenAttributeCondition(String,String,boolean,String)}.
       */    
      public AttributeCondition createBeginHyphenAttributeCondition
          (String localName,
           String namespaceURI,
           boolean specified,
           String value)
        throws CSSException {
        return new CSSBeginHyphenAttributeCondition
            (localName, namespaceURI, specified, value);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.ConditionFactory#createClassCondition(String,String)}.
       */    
      public AttributeCondition createClassCondition(String namespaceURI,
                                                   String value)
        throws CSSException {
        return new CSSClassCondition(namespaceURI, value);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * ConditionFactory#createPseudoClassCondition(String,String)}.
       */    
      public AttributeCondition createPseudoClassCondition(String namespaceURI,
                                                         String value)
        throws CSSException {
        return new CSSPseudoClassCondition(namespaceURI, value);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.ConditionFactory#createOnlyChildCondition()}.
       */    
      public Condition createOnlyChildCondition() throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.ConditionFactory#createOnlyTypeCondition()}.
       */    
      public Condition createOnlyTypeCondition() throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.ConditionFactory#createContentCondition(String)}.
       */    
      public ContentCondition createContentCondition(String data)
          throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSConditionalSelector.java
  
  Index: CSSConditionalSelector.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.Condition;
  import org.w3c.css.sac.ConditionalSelector;
  import org.w3c.css.sac.SimpleSelector;
  import org.w3c.dom.Element;
  
  /**
   * This class provides an implementation of the
   * {@link org.w3c.css.sac.ConditionalSelector} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSConditionalSelector.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public class CSSConditionalSelector
      implements ConditionalSelector,
               ExtendedSelector {
  
      /**
       * The simple selector.
       */
      protected SimpleSelector simpleSelector;
  
      /**
       * The condition.
       */
      protected Condition condition;
  
      /**
       * Creates a new ConditionalSelector object.
       */
      public CSSConditionalSelector(SimpleSelector s, Condition c) {
        simpleSelector = s;
        condition      = c;
      }
  
      /**
       * Indicates whether some other object is "equal to" this one.
       * @param obj the reference object with which to compare.
       */
      public boolean equals(Object obj) {
        if (obj == null || !(obj.getClass() != getClass())) {
            return false;
        }
        CSSConditionalSelector s = (CSSConditionalSelector)obj;
        return s.simpleSelector.equals(simpleSelector) &&
               s.condition.equals(condition);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Selector#getSelectorType()}.
       */
      public short getSelectorType() {
        return SAC_CONDITIONAL_SELECTOR;
      }
  
      /**
       * Tests whether this selector matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        return ((ExtendedSelector)getSimpleSelector()).match(e, pseudoE) &&
               ((ExtendedCondition)getCondition()).match(e, pseudoE);
      }
  
      /**
       * Returns the specificity of this selector.
       */
      public int getSpecificity() {
        return ((ExtendedSelector)getSimpleSelector()).getSpecificity() +
               ((ExtendedCondition)getCondition()).getSpecificity();
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.ConditionalSelector#getSimpleSelector()}.
       */    
      public SimpleSelector getSimpleSelector() {
        return simpleSelector;
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.ConditionalSelector#getCondition()}.
       */    
      public Condition getCondition() {
        return condition;
      }
  
      /**
       * Returns a representation of the selector.
       */
      public String toString() {
        return "" + simpleSelector + condition;
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSDescendantSelector.java
  
  Index: CSSDescendantSelector.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.Selector;
  import org.w3c.css.sac.SimpleSelector;
  import org.w3c.dom.Element;
  import org.w3c.dom.Node;
  
  /**
   * This class provides an implementation for the
   * {@link org.w3c.css.sac.DescendantSelector} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSDescendantSelector.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public class CSSDescendantSelector extends AbstractDescendantSelector {
  
      /**
       * Creates a new CSSDescendantSelector object.
       */
      public CSSDescendantSelector(Selector ancestor, SimpleSelector simple) {
        super(ancestor, simple);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Selector#getSelectorType()}.
       */
      public short getSelectorType() {
        return SAC_DESCENDANT_SELECTOR;
      }
  
      /**
       * Tests whether this selector matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        ExtendedSelector p = (ExtendedSelector)getAncestorSelector();
        for (Node n = e.getParentNode(); n != null; n = n.getParentNode()) {
            if (n.getNodeType() == Node.ELEMENT_NODE) {
                if (n.getNodeType() == Node.ELEMENT_NODE &&
                    p.match((Element)n, null)) {
                    return
                          ((ExtendedSelector)getSimpleSelector()).match(e,
                                                                        pseudoE);
                }
            }
        }
        return false;
      }
  
      /**
       * Returns a representation of the selector.
       */
      public String toString() {
        return getAncestorSelector() + " " + getSimpleSelector();
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSDirectAdjacentSelector.java
  
  Index: CSSDirectAdjacentSelector.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.Selector;
  import org.w3c.css.sac.SimpleSelector;
  import org.w3c.dom.Element;
  import org.w3c.dom.Node;
  
  /**
   * This class provides an implementation for the
   * {@link org.w3c.css.sac.DescendantSelector} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSDirectAdjacentSelector.java,v 1.1 2002/03/18 10:31:09 hillion 
Exp $
   */
  
  public class CSSDirectAdjacentSelector extends AbstractSiblingSelector {
  
      /**
       * Creates a new CSSDirectAdjacentSelector object.
       */
      public CSSDirectAdjacentSelector(short type,
                                       Selector parent,
                                       SimpleSelector simple) {
        super(type, parent, simple);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Selector#getSelectorType()}.
       */
      public short getSelectorType() {
        return SAC_DIRECT_ADJACENT_SELECTOR;
      }
  
      /**
       * Tests whether this selector matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        Node n = e;
          while ((n = n.getPreviousSibling()) != null &&
                 n.getNodeType() != Node.ELEMENT_NODE);
        if (n != null) {
            return ((ExtendedSelector)getSelector()).match((Element)n,
                                                                   null) &&
                   ((ExtendedSelector)getSiblingSelector()).match(e, pseudoE);
        }       
        return false;
      }
  
      /**
       * Returns a representation of the selector.
       */
      public String toString() {
        return getSelector() + " + " + getSiblingSelector();
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSElementSelector.java
  
  Index: CSSElementSelector.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.dom.Element;
  
  /**
   * This class implements the {@link org.w3c.css.sac.ElementSelector} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSElementSelector.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public class CSSElementSelector extends AbstractElementSelector {
  
      /**
       * Creates a new ElementSelector object.
       */
      public CSSElementSelector(String uri, String name) {
        super(uri, name);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Selector#getSelectorType()}.
       */
      public short getSelectorType() {
        return SAC_ELEMENT_NODE_SELECTOR;
      }
  
      /**
       * Tests whether this selector matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        String name = getLocalName();
        if (name == null) {
            return true;
        }
        return (e.getPrefix() == null)
            ? e.getNodeName().equalsIgnoreCase(name)
            : e.getLocalName().equalsIgnoreCase(name);
      }
  
      /**
       * Returns the specificity of this selector.
       */
      public int getSpecificity() {
        return (getLocalName() == null) ? 0 : 1;
      }
  
      /**
       * Returns a representation of the selector.
       */
      public String toString() {
        String name = getLocalName();
        if (name == null) {
            return "*";
        }
        return name;
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSIdCondition.java
  
  Index: CSSIdCondition.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.apache.batik.css.engine.CSSStylableElement;
  import org.w3c.dom.Element;
  
  /**
   * This class provides an implementation of the
   * {@link org.w3c.css.sac.AttributeCondition} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSIdCondition.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  
  public class CSSIdCondition extends AbstractAttributeCondition {
      /**
       * Creates a new CSSAttributeCondition object.
       */
      public CSSIdCondition(String value) {
        super(value);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Condition#getConditionType()}.
       */    
      public short getConditionType() {
        return SAC_ID_CONDITION;
      }
      
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.AttributeCondition#getNamespaceURI()}.
       */    
      public String getNamespaceURI() {
        return null;
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.AttributeCondition#getLocalName()}.
       */
      public String getLocalName() {
        return "id";
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.AttributeCondition#getSpecified()}.
       */
      public boolean getSpecified() {
        return true;
      }
  
      /**
       * Tests whether this condition matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        return (e instanceof CSSStylableElement)
            ? ((CSSStylableElement)e).getXMLId().equals(getValue())
            : false;
      }
  
      /**
       * Returns the specificity of this condition.
       */
      public int getSpecificity() {
        return 1 << 16;
      }
  
      /**
       * Returns a text representation of this object.
       */
      public String toString() {
        return "#" + getValue();
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSLangCondition.java
  
  Index: CSSLangCondition.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.LangCondition;
  import org.w3c.dom.Element;
  
  /**
   * This class provides an implementation of the
   * {@link org.w3c.css.sac.LangCondition} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSLangCondition.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  
  public class CSSLangCondition
      implements LangCondition,
               ExtendedCondition {
      /**
       * The language.
       */
      protected String lang;
  
      /**
       * Creates a new LangCondition object.
       */
      public CSSLangCondition(String lang) {
        this.lang = lang;
      }
  
      /**
       * Indicates whether some other object is "equal to" this one.
       * @param obj the reference object with which to compare.
       */
      public boolean equals(Object obj) {
        if (obj == null || !(obj.getClass() != getClass())) {
            return false;
        }
        CSSLangCondition c = (CSSLangCondition)obj;
        return c.lang.equals(lang);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Condition#getConditionType()}.
       */    
      public short getConditionType() {
        return SAC_LANG_CONDITION;
      }
  
      /**
       * <b>SAC</b>: Implements {@link org.w3c.css.sac.LangCondition#getLang()}.
       */
      public String getLang() {
        return lang;
      }
  
      /**
       * Returns the specificity of this condition.
       */
      public int getSpecificity() {
        return 1 << 8;
      }
  
      /**
       * Tests whether this condition matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        return e.getAttribute("lang").startsWith(getLang());
      }
  
      /**
       * Returns a text representation of this object.
       */
      public String toString() {
        return ":lang(" + lang + ")";
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSOneOfAttributeCondition.java
  
  Index: CSSOneOfAttributeCondition.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.dom.Element;
  
  /**
   * This class provides an implementation of the
   * {@link org.w3c.css.sac.AttributeCondition} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSOneOfAttributeCondition.java,v 1.1 2002/03/18 10:31:09 hillion 
Exp $
   */
  public class CSSOneOfAttributeCondition extends CSSAttributeCondition {
      /**
       * Creates a new CSSAttributeCondition object.
       */
      public CSSOneOfAttributeCondition(String localName,
                                        String namespaceURI,
                                        boolean specified,
                                        String value) {
        super(localName, namespaceURI, specified, value);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Condition#getConditionType()}.
       */    
      public short getConditionType() {
        return SAC_ONE_OF_ATTRIBUTE_CONDITION;
      }
      
      /**
       * Tests whether this condition matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        String attr = e.getAttribute(getLocalName());
        String val = getValue();
        int i = attr.indexOf(val);
        if (i == -1) {
            return false;
        }
        if (i != 0 && !Character.isSpaceChar(attr.charAt(i - 1))) {
            return false;
        }
        int j = i + val.length();
        return (j == attr.length() ||
                (j < attr.length() && Character.isSpaceChar(attr.charAt(j))));
      }
  
      /**
       * Returns a text representation of this object.
       */
      public String toString() {
        return "[" + getLocalName() + "~=\"" + getValue() + "\"]";
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSPseudoClassCondition.java
  
  Index: CSSPseudoClassCondition.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.apache.batik.css.engine.CSSStylableElement;
  import org.w3c.dom.Element;
  
  /**
   * This class provides an implementation of the
   * {@link org.w3c.css.sac.AttributeCondition} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSPseudoClassCondition.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public class CSSPseudoClassCondition extends AbstractAttributeCondition {
      /**
       * The namespaceURI.
       */
      protected String namespaceURI;
  
      /**
       * Creates a new CSSAttributeCondition object.
       */
      public CSSPseudoClassCondition(String namespaceURI, String value) {
        super(value);
        this.namespaceURI = namespaceURI;
      }
  
      /**
       * Indicates whether some other object is "equal to" this one.
       * @param obj the reference object with which to compare.
       */
      public boolean equals(Object obj) {
        if (!super.equals(obj)) {
            return false;
        }
        CSSPseudoClassCondition c = (CSSPseudoClassCondition)obj;
        return c.namespaceURI.equals(namespaceURI);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Condition#getConditionType()}.
       */    
      public short getConditionType() {
        return SAC_PSEUDO_CLASS_CONDITION;
      }
      
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.AttributeCondition#getNamespaceURI()}.
       */    
      public String getNamespaceURI() {
        return namespaceURI;
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.AttributeCondition#getLocalName()}.
       */
      public String getLocalName() {
        return null;
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.AttributeCondition#getSpecified()}.
       */
      public boolean getSpecified() {
        return false;
      }
  
      /**
       * Tests whether this selector matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        return (e instanceof CSSStylableElement)
            ? ((CSSStylableElement)e).isPseudoInstanceOf(getValue())
            : false;
      }
  
      /**
       * Returns a text representation of this object.
       */
      public String toString() {
        return ":" + getValue();
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSPseudoElementSelector.java
  
  Index: CSSPseudoElementSelector.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.dom.Element;
  
  /**
   * This class implements the {@link org.w3c.css.sac.ElementSelector} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSPseudoElementSelector.java,v 1.1 2002/03/18 10:31:09 hillion Exp 
$
   */
  public class CSSPseudoElementSelector extends AbstractElementSelector {
  
      /**
       * Creates a new CSSPseudoElementSelector object.
       */
      public CSSPseudoElementSelector(String uri, String name) {
        super(uri, name);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.Selector#getSelectorType()}.
       */
      public short getSelectorType() {
        return SAC_PSEUDO_ELEMENT_SELECTOR;
      }
  
      /**
       * Tests whether this selector matches the given element.
       */
      public boolean match(Element e, String pseudoE) {
        return getLocalName().equalsIgnoreCase(pseudoE);
      }
  
      /**
       * Returns the specificity of this selector.
       */
      public int getSpecificity() {
        return 0;
      }
  
      /**
       * Returns a representation of the selector.
       */
      public String toString() {
        return ":" + getLocalName();
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/CSSSelectorFactory.java
  
  Index: CSSSelectorFactory.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.CSSException;
  import org.w3c.css.sac.CharacterDataSelector;
  import org.w3c.css.sac.Condition;
  import org.w3c.css.sac.ConditionalSelector;
  import org.w3c.css.sac.DescendantSelector;
  import org.w3c.css.sac.ElementSelector;
  import org.w3c.css.sac.NegativeSelector;
  import org.w3c.css.sac.ProcessingInstructionSelector;
  import org.w3c.css.sac.Selector;
  import org.w3c.css.sac.SelectorFactory;
  import org.w3c.css.sac.SiblingSelector;
  import org.w3c.css.sac.SimpleSelector;
  
  /**
   * This class implements the {@link org.w3c.css.sac.SelectorFactory} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: CSSSelectorFactory.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public class CSSSelectorFactory implements SelectorFactory {
  
      /**
       * The instance of this class.
       */
      public final static SelectorFactory INSTANCE = new CSSSelectorFactory();
  
      /**
       * This class does not need to be instantiated.
       */
      protected CSSSelectorFactory() {
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * SelectorFactory#createConditionalSelector(SimpleSelector,Condition)}.
       */    
      public ConditionalSelector createConditionalSelector
          (SimpleSelector selector,
           Condition condition) 
        throws CSSException {
        return new CSSConditionalSelector(selector, condition);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.SelectorFactory#createAnyNodeSelector()}.
       */    
      public SimpleSelector createAnyNodeSelector() throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.SelectorFactory#createRootNodeSelector()}.
       */    
      public SimpleSelector createRootNodeSelector() throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.SelectorFactory#createNegativeSelector(SimpleSelector)}.
       */    
      public NegativeSelector createNegativeSelector(SimpleSelector selector) 
        throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.SelectorFactory#createElementSelector(String,String)}.
       */    
      public ElementSelector createElementSelector(String namespaceURI,
                                                   String tagName)
        throws CSSException {
        return new CSSElementSelector(namespaceURI, tagName);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.SelectorFactory#createTextNodeSelector(String)}.
       */    
      public CharacterDataSelector createTextNodeSelector(String data)
        throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.SelectorFactory#createCDataSectionSelector(String)}.
       */    
      public CharacterDataSelector createCDataSectionSelector(String data)
        throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * SelectorFactory#createProcessingInstructionSelector(String,String)}.
       */    
      public ProcessingInstructionSelector createProcessingInstructionSelector
        (String target,
         String data) throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * org.w3c.css.sac.SelectorFactory#createCommentSelector(String)}.
       */    
      public CharacterDataSelector createCommentSelector(String data)
        throws CSSException {
        throw new CSSException("Not implemented in CSS2");
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * SelectorFactory#createPseudoElementSelector(String,String)}.
       */    
      public ElementSelector createPseudoElementSelector(String namespaceURI, 
                                                       String pseudoName) 
        throws CSSException {
        return new CSSPseudoElementSelector(namespaceURI, pseudoName);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * SelectorFactory#createDescendantSelector(Selector,SimpleSelector)}.
       */    
      public DescendantSelector createDescendantSelector
          (Selector parent,
           SimpleSelector descendant)
        throws CSSException {
        return new CSSDescendantSelector(parent, descendant);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * SelectorFactory#createChildSelector(Selector,SimpleSelector)}.
       */    
      public DescendantSelector createChildSelector(Selector parent,
                                                  SimpleSelector child)
        throws CSSException {
        return new CSSChildSelector(parent, child);
      }
  
      /**
       * <b>SAC</b>: Implements {@link
       * SelectorFactory#createDirectAdjacentSelector(short,Selector,SimpleSelector)}.
       */
      public SiblingSelector createDirectAdjacentSelector
          (short          nodeType,
           Selector       child,
           SimpleSelector directAdjacent)
        throws CSSException {
        return new CSSDirectAdjacentSelector(nodeType, child,
                                                 directAdjacent);
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/ExtendedCondition.java
  
  Index: ExtendedCondition.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.Condition;
  import org.w3c.dom.Element;
  
  /**
   * This interface provides additional features to the
   * {@link org.w3c.css.sac.Condition} interface.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: ExtendedCondition.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public interface ExtendedCondition extends Condition {
  
      /**
       * Tests whether this condition matches the given element.
       */
      boolean match(Element e, String pseudoE);
  
      /**
       * Returns the specificity of this condition.
       */
      int getSpecificity();
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/css/engine/sac/ExtendedSelector.java
  
  Index: ExtendedSelector.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.engine.sac;
  
  import org.w3c.css.sac.Selector;
  import org.w3c.dom.Element;
  
  /**
   * This interface extends the {@link org.w3c.css.sac.Selector}.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: ExtendedSelector.java,v 1.1 2002/03/18 10:31:09 hillion Exp $
   */
  public interface ExtendedSelector extends Selector {
  
      /**
       * Tests whether this selector matches the given element.
       */
      boolean match(Element e, String pseudoE);
  
      /**
       * Returns the specificity of this selector.
       */
      int getSpecificity();
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to