2002/css-validator/org/w3c/css/selectors/attributes AttributeAny.java,NONE,1.1 AttributeBegin.java,NONE,1.1 AttributeExact.java,NONE,1.1 AttributeOneOf.java,NONE,1.1 AttributeStart.java,NONE,1.1 AttributeSubstr.java,NONE,1.1 AttributeSuffix.java,NONE,1.1

Update of /sources/public/2002/css-validator/org/w3c/css/selectors/attributes
In directory hutz:/tmp/cvs-serv8236/org/w3c/css/selectors/attributes

Added Files:
	AttributeAny.java AttributeBegin.java AttributeExact.java 
	AttributeOneOf.java AttributeStart.java AttributeSubstr.java 
	AttributeSuffix.java 
Log Message:
Changes from Jean-Guilhem Rouel
Bug fixed: 1174 845 160 766
See
http://www.w3.org/Bugs/Public/show_bug.cgi?id=1174
http://www.w3.org/Bugs/Public/show_bug.cgi?id=845
http://www.w3.org/Bugs/Public/show_bug.cgi?id=160
http://www.w3.org/Bugs/Public/show_bug.cgi?id=766

The handling of selectors has been redone almost entirely.

Also, changelog in files has been removed.



--- NEW FILE: AttributeOneOf.java ---
// $Id: AttributeOneOf.java,v 1.1 2005/09/08 12:24:09 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.selectors.attributes;

import org.w3c.css.selectors.AttributeSelector;
import org.w3c.css.selectors.Selector;
import org.w3c.css.util.ApplContext;

/**
 * AttributeOneOf<br />
 * Created: Sep 1, 2005 4:30:13 PM<br />
 */
public class AttributeOneOf extends AttributeSelector {

    String value;
    
    public AttributeOneOf(String name, String value) {
	setName(name);
	this.value = value;
    }
    
    /**
     * @return Returns the value.
     */
    public String getValue() {
        return value;
    }

    /**
     * @param value The value to set.
     */
    public void setValue(String value) {
        this.value = value;
    }

    public boolean canApply(Selector other) {
	if (other instanceof AttributeAny) {
	    // [lang~=fr][lang]
	    // return [lang~=fr]
	    return true;
	} else if (other instanceof AttributeExact) {
	    String exact = ((AttributeExact) other).getValue();
	    // [lang~=fr][lang=fr]
	    if(value.equals(exact)) {	    
		// [lang~=fr][lang=fr]
		return true;		
	    }
	    // [lang~=en][lang=fr]
	    return false;
	} else if (other instanceof AttributeOneOf) {
	    return true;
	} else if (other instanceof AttributeBegin) {
	    // [lang=~fr][lang|=fr]
	    return true;
	}
	return false;
    }

    public String toString() {
	return "[" + getName() + "~=\"" + value + "\"]";
    }

    public void applyAttribute(ApplContext ac, AttributeSelector attr) {
	if((attr instanceof AttributeExact) &&
		!value.equals(((AttributeExact) attr).getValue())) {
	    ac.getFrame().addWarning("incompatible", toString(), attr.toString());
	}
    }

}

--- NEW FILE: AttributeBegin.java ---
// $Id: AttributeBegin.java,v 1.1 2005/09/08 12:24:09 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.selectors.attributes;

import org.w3c.css.selectors.AttributeSelector;
import org.w3c.css.selectors.Selector;
import org.w3c.css.util.ApplContext;

/**
 * AttributeBegin<br />
 * Created: Sep 1, 2005 4:26:18 PM<br />
 */
public class AttributeBegin extends AttributeSelector {

    private String value;
    
    public AttributeBegin(String name, String value) {
	setName(name);
	this.value = value;
    }
    
    /**
     * @return Returns the value.
     */
    public String getValue() {
        return value;
    }

    /**
     * @param value The value to set.
     */
    public void setValue(String value) {
        this.value = value;
    }

    public boolean canApply(Selector other) {
	if (other instanceof AttributeAny) {
	    // [lang|=fr][lang]
	    return true;
	} else if (other instanceof AttributeExact) {
	    String v = ((AttributeExact) other).getValue();
	    int index = v.indexOf('-');
	    if (index > 0) {
		v = v.substring(0, index);
	    }
	    if (!value.equals(v)) {
		// [lang|=fr][lang=en-US]
		return false;
	    } else {
		// [lang|=en][lang=en-US]
		return true;
	    }
	} else if (other instanceof AttributeOneOf) {
	    return true;
	} else if (other instanceof AttributeBegin) {
	    if (!value.equals(((AttributeBegin) other).value)) {
		// [lang|=fr][lang|=en]
		return false;
	    } else {
		// [lang|=en][lang|=en]
		return true;
	    }	    
	}
	return false;
    }

    public void applyAttribute(ApplContext ac, AttributeSelector attr) {
	if (attr instanceof AttributeExact) {
	    String v = ((AttributeExact) attr).getValue();
	    int index = v.indexOf('-');
	    if (index > 0) {
		v = v.substring(0, index);
	    }
	    if (!value.equals(v)) {
		// [lang|=fr][lang=en-US]
		ac.getFrame().addWarning("incompatible", toString(), attr.toString());
	    }
	} else if (attr instanceof AttributeBegin) {
	    if (!value.equals(((AttributeBegin) attr).value)) {
		// [lang|=fr][lang|=en]
		ac.getFrame().addWarning("incompatible", toString(), attr.toString());
	    }    
	}
	
    }
    
    public String toString() {
	return "[" + getName() + "|=\"" + value + "\"]";
    }

}

--- NEW FILE: AttributeExact.java ---
// $Id: AttributeExact.java,v 1.1 2005/09/08 12:24:09 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.selectors.attributes;

import org.w3c.css.selectors.AttributeSelector;
import org.w3c.css.selectors.Selector;
import org.w3c.css.util.ApplContext;

/**
 * AttributeExact<br />
 * Created: Sep 1, 2005 4:22:42 PM<br />
 */
public class AttributeExact extends AttributeSelector {

    private String value;
    
    public AttributeExact(String name, String value) {
	setName(name);
	this.value = value;
    }
    
    /**
     * @return Returns the value.
     */
    public String getValue() {
        return value;
    }

    /**
     * @param value The value to set.
     */
    public void setValue(String value) {
        this.value = value;
    }

    public boolean canApply(Selector other) {
	if (other instanceof AttributeAny) {
	    // [lang=fr][lang]
	    return true;
	} else if (other instanceof AttributeExact ||
		other instanceof AttributeOneOf ||
		other instanceof AttributeBegin) {
	    if (!value.equals(((AttributeExact) other).getValue())) {
		// [lang=fr][lang=en]
		return false;
	    } else {
		// [lang=en][lang=en]
		return true;
	    }
	}
	return false;
    }

    public void applyAttribute(ApplContext ac, AttributeSelector attr) {
	if (attr instanceof AttributeExact) {
	    if (!value.equals(((AttributeExact) attr).getValue())) {
		ac.getFrame().addWarning("incompatible", toString(), attr.toString());
	    }
	}
	else if(attr instanceof AttributeOneOf) {
	    if (!value.equals(((AttributeOneOf) attr).getValue())) {
		ac.getFrame().addWarning("incompatible", toString(), attr.toString());
	    }
	}
	else if(attr instanceof AttributeBegin) {
	    if (!value.equals(((AttributeBegin) attr).getValue())) {
		ac.getFrame().addWarning("incompatible", toString(), attr.toString());
	    }
	}
    }
    
    public String toString() {
	return "[" + getName() + "=\"" + value + "\"]";
    }

}

--- NEW FILE: AttributeStart.java ---
// $Id: AttributeStart.java,v 1.1 2005/09/08 12:24:09 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.selectors.attributes;

import org.w3c.css.selectors.AttributeSelector;
import org.w3c.css.selectors.Selector;
import org.w3c.css.util.ApplContext;

/**
 * AttributeStart<br />
 * Created: Sep 1, 2005 4:32:57 PM<br />
 */
public class AttributeStart extends AttributeSelector {

private String value;
    
    public AttributeStart(String name, String value) {
	setName(name);
	this.value = value;
    }
    
    /**
     * @return Returns the value.
     */
    public String getValue() {
        return value;
    }

    /**
     * @param value The value to set.
     */
    public void setValue(String value) {
        this.value = value;
    }

    public boolean canApply(Selector other) {
	return true;
    }
 
    public String toString() {
	return "[" + getName() + "^=\"" + value + "\"]";
    }

    public void applyAttribute(ApplContext ac, AttributeSelector attr) {

    }

}

--- NEW FILE: AttributeAny.java ---
// $Id: AttributeAny.java,v 1.1 2005/09/08 12:24:09 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.selectors.attributes;

import org.w3c.css.selectors.AttributeSelector;
import org.w3c.css.selectors.Selector;
import org.w3c.css.util.ApplContext;

/**
 * AttributeAny<br />
 * Created: Sep 1, 2005 4:20:49 PM<br />
 */
public class AttributeAny extends AttributeSelector {

    public AttributeAny(String name) {
	super(name);
    }
    
    public boolean canApply(Selector other) {
	return true;
    }

    public void applyAttribute(ApplContext ac, AttributeSelector attr) {
    }

    
}

--- NEW FILE: AttributeSuffix.java ---
// $Id: AttributeSuffix.java,v 1.1 2005/09/08 12:24:09 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.selectors.attributes;

import org.w3c.css.selectors.AttributeSelector;
import org.w3c.css.selectors.Selector;
import org.w3c.css.util.ApplContext;

/**
 * AttributeSuffix<br />
 * Created: Sep 1, 2005 4:34:31 PM<br />
 */
public class AttributeSuffix extends AttributeSelector {

private String value;
    
    public AttributeSuffix(String name, String value) {
	setName(name);
	this.value = value;
    }
    
    /**
     * @return Returns the value.
     */
    public String getValue() {
        return value;
    }

    /**
     * @param value The value to set.
     */
    public void setValue(String value) {
        this.value = value;
    }

    public boolean canApply(Selector other) {
	return true;
    }

    public String toString() {
	return "[" + getName() + "$=\"" + value + "\"]";
    }

    public void applyAttribute(ApplContext ac, AttributeSelector attr) {
	
    }

}

--- NEW FILE: AttributeSubstr.java ---
// $Id: AttributeSubstr.java,v 1.1 2005/09/08 12:24:09 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.selectors.attributes;

import org.w3c.css.selectors.AttributeSelector;
import org.w3c.css.selectors.Selector;
import org.w3c.css.util.ApplContext;

/**
 * AttributeSubstr<br />
 * Created: Sep 1, 2005 4:35:13 PM<br />
 */
public class AttributeSubstr extends AttributeSelector {

private String value;
    
    public AttributeSubstr(String name, String value) {
	setName(name);
	this.value = value;
    }
    
    /**
     * @return Returns the value.
     */
    public String getValue() {
        return value;
    }

    /**
     * @param value The value to set.
     */
    public void setValue(String value) {
        this.value = value;
    }

    public boolean canApply(Selector other) {
	return true;
    }
    
    public String toString() {
	return "[" + getName() + "*=\"" + value + "\"]";
    }

    public void applyAttribute(ApplContext ac, AttributeSelector attr) {
	// TODO Auto-generated method stub
	
    }

}

Received on Thursday, 8 September 2005 12:24:24 UTC