2002/css-validator/org/w3c/css/properties/css CssFont.java,NONE,1.1 CssFontFamily.java,NONE,1.1 CssFontSize.java,NONE,1.1 CssFontSizeAdjust.java,NONE,1.1 CssFontStretch.java,NONE,1.1 CssFontStyle.java,NONE,1.1 CssFontVariant.java,NONE,1.1 CssFontWeight.java,NONE,1.1 CssLineHeight.java,NONE,1.1

Update of /sources/public/2002/css-validator/org/w3c/css/properties/css
In directory hutz:/tmp/cvs-serv31218/w3c/css/properties/css

Added Files:
	CssFont.java CssFontFamily.java CssFontSize.java 
	CssFontSizeAdjust.java CssFontStretch.java CssFontStyle.java 
	CssFontVariant.java CssFontWeight.java CssLineHeight.java 
Log Message:
font revamp, still some missing properties for CSS3 and @font-face for CSS2 and CSS3

--- NEW FILE: CssFontStretch.java ---
// $Id: CssFontStretch.java,v 1.1 2012/08/04 21:17:04 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css2.Css2Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * @version $Revision: 1.1 $
 * @since CSS2
 */
public class CssFontStretch extends CssProperty {

	public CssValue value;

	/**
	 * Create a new CssFontStretch
	 */
	public CssFontStretch() {
	}

	/**
	 * Creates a new CssFontStretch
	 *
	 * @param expression The expression for this property
	 * @throws org.w3c.css.util.InvalidParamException
	 *          Expressions are incorrect
	 */
	public CssFontStretch(ApplContext ac, CssExpression expression, boolean check)
			throws InvalidParamException {
		throw new InvalidParamException("value",
				expression.getValue().toString(),
				getPropertyName(), ac);
	}

	public CssFontStretch(ApplContext ac, CssExpression expression)
			throws InvalidParamException {
		this(ac, expression, false);
	}

	/**
	 * Returns the value of this property
	 */
	public Object get() {
		return value;
	}


	/**
	 * Returns the name of this property
	 */
	public final String getPropertyName() {
		return "font-stretch";
	}

	/**
	 * Returns true if this property is "softly" inherited
	 * e.g. his value is equals to inherit
	 */
	public boolean isSoftlyInherited() {
		return value.equals(inherit);
	}

	/**
	 * Returns a string representation of the object.
	 */
	public String toString() {
		return value.toString();
	}

	/**
	 * Add this property to the CssStyle.
	 *
	 * @param style The CssStyle
	 */
	public void addToStyle(ApplContext ac, CssStyle style) {
		Css2Style s = (Css2Style) style;
		if (s.cssFontStretch != null)
			style.addRedefinitionWarning(ac, this);
		s.cssFontStretch = this;
	}


	/**
	 * Compares two properties for equality.
	 *
	 * @param property The other property.
	 */
	public boolean equals(CssProperty property) {
		return (property instanceof CssFontStretch &&
				value.equals(((CssFontStretch) property).value));
	}


	/**
	 * Get this property in the style.
	 *
	 * @param style   The style where the property is
	 * @param resolve if true, resolve the style to find this property
	 */
	public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
		if (resolve) {
			return ((Css2Style) style).getFontStretch();
		} else {
			return ((Css2Style) style).cssFontStretch;
		}
	}
}


--- NEW FILE: CssFont.java ---
// $Id: CssFont.java,v 1.1 2012/08/04 21:17:04 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.parser.CssSelectors;
import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * @version $Revision: 1.1 $
 * @since CSS1
 */
public class CssFont extends CssProperty {

	public CssValue value;
	// @since CSS1
	public CssFontFamily fontFamily;
	public CssFontSize fontSize;
	public CssFontStyle fontStyle;
	public CssFontVariant fontVariant;
	public CssFontWeight fontWeight;

	public CssLineHeight lineHeight;

	public boolean compound = false;

	/**
	 * Create a new CssFontSize
	 */
	public CssFont() {
	}

	/**
	 * Creates a new CssFontSize
	 *
	 * @param expression The expression for this property
	 * @throws org.w3c.css.util.InvalidParamException
	 *          Expressions are incorrect
	 */
	public CssFont(ApplContext ac, CssExpression expression, boolean check)
			throws InvalidParamException {
		throw new InvalidParamException("value",
				expression.getValue().toString(),
				getPropertyName(), ac);
	}

	public CssFont(ApplContext ac, CssExpression expression)
			throws InvalidParamException {
		this(ac, expression, false);
	}

	/**
	 * Returns the value of this property
	 */
	public Object get() {
		return value;
	}


	/**
	 * Returns the name of this property
	 */
	public final String getPropertyName() {
		return "font";
	}

	/**
	 * Returns true if this property is "softly" inherited
	 * e.g. his value is equals to inherit
	 */
	public boolean isSoftlyInherited() {
		return inherit.equals(value);
	}

	/**
	 * Returns a string representation of the object.
	 */
	public String toString() {
		if (value != null) {
			return value.toString();
		}
		boolean first = true;
		StringBuilder sb = new StringBuilder();
		if (fontStyle != null) {
			sb.append(fontSize);
			first = false;
		}
		if (fontVariant != null) {
			if (first) {
				first = false;
			} else {
				sb.append(' ');
			}
			sb.append(fontVariant);
		}
		if (fontWeight != null) {
			if (first) {
				first = false;
			} else {
				sb.append(' ');
			}
			sb.append(fontWeight);
		}
		// no need to test, if we are here we should have one!
		if (fontSize != null) {
			if (first) {
				first = false;
			} else {
				sb.append(' ');
			}
			sb.append(fontSize);
		}
		if (lineHeight != null) {
			sb.append('/');
			sb.append(lineHeight);
		}
		// should always be there...
		if (fontFamily != null) {
			sb.append(' ');
			sb.append(fontFamily);
		}
		return sb.toString();
	}

	/**
	 * Add this property to the CssStyle.
	 *
	 * @param style The CssStyle
	 */
	public void addToStyle(ApplContext ac, CssStyle style) {
		CssFont cssFont = ((Css1Style) style).cssFont;
		// if we already have a font shorthand defined
		// raise a warning
		if (cssFont.compound) {
			style.addRedefinitionWarning(ac, this);
		}
		cssFont.compound = true;
		// and now test all the individual property redefinitions
		if (fontFamily != null) {
			fontFamily.addToStyle(ac, style);
		}
		if (fontSize != null) {
			fontSize.addToStyle(ac, style);
		}
		if (fontVariant != null) {
			fontVariant.addToStyle(ac, style);
		}
		if (fontWeight != null) {
			fontWeight.addToStyle(ac, style);
		}
		if (lineHeight != null) {
			lineHeight.addToStyle(ac, style);
		}
	}


	/**
	 * Compares two properties for equality.
	 *
	 * @param property The other property.
	 */
	public boolean equals(CssProperty property) {
		return (property instanceof CssFont &&
				value.equals(((CssFont) property).value));
	}

	/**
	 * Set the context.
	 * Overrides this method for a macro
	 *
	 * @see org.w3c.css.css.CssCascadingOrder#order
	 * @see org.w3c.css.css.StyleSheetParser#handleRule
	 */
	public void setSelectors(CssSelectors selector) {
		super.setSelectors(selector);
		if (fontStyle != null) {
			fontStyle.setSelectors(selector);
		}
		if (fontVariant != null) {
			fontVariant.setSelectors(selector);
		}
		if (fontWeight != null) {
			fontWeight.setSelectors(selector);
		}
		if (fontSize != null) {
			fontSize.setSelectors(selector);
		}
		if (lineHeight != null) {
			lineHeight.setSelectors(selector);
		}
		if (fontFamily != null) {
			fontFamily.setSelectors(selector);
		}
	}

	/**
	 * Set this property to be important.
	 * Overrides this method for a macro
	 */
	public void setImportant() {
		super.setImportant();
		if (fontStyle != null)
			fontStyle.important = true;
		if (fontVariant != null)
			fontVariant.important = true;
		if (fontWeight != null)
			fontWeight.important = true;
		if (fontSize != null)
			fontSize.important = true;
		if (lineHeight != null)
			lineHeight.important = true;
		if (fontFamily != null)
			fontFamily.important = true;
	}

	/**
	 * Get this property in the style.
	 *
	 * @param style   The style where the property is
	 * @param resolve if true, resolve the style to find this property
	 */
	public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
		if (resolve) {
			return ((Css1Style) style).getFont();
		} else {
			return ((Css1Style) style).cssFont;
		}
	}
}


--- NEW FILE: CssFontVariant.java ---
// $Id: CssFontVariant.java,v 1.1 2012/08/04 21:17:04 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * @since CSS1
 * @version $Revision: 1.1 $
 */
public class CssFontVariant extends CssProperty {

    public CssValue value;

    /**
     * Create a new CssFontVariant
     */
    public CssFontVariant() {
    }

    /**
     * Creates a new CssFontVariant
     *
     * @param expression The expression for this property
     * @throws org.w3c.css.util.InvalidParamException
     *          Expressions are incorrect
     */
    public CssFontVariant(ApplContext ac, CssExpression expression, boolean check)
            throws InvalidParamException {
        throw new InvalidParamException("value",
                expression.getValue().toString(),
                getPropertyName(), ac);
    }

    public CssFontVariant(ApplContext ac, CssExpression expression)
            throws InvalidParamException {
        this(ac, expression, false);
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }


    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return "font-variant";
    }

    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value is equals to inherit
     */
    public boolean isSoftlyInherited() {
        return value.equals(inherit);
    }

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        return value.toString();
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
		CssFont cssFont = ((Css1Style) style).cssFont;
		if (cssFont.fontVariant != null)
			style.addRedefinitionWarning(ac, this);
		cssFont.fontVariant = this;
	}


    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssFontVariant &&
                value.equals(((CssFontVariant) property).value));
    }


    /**
     * Get this property in the style.
     *
     * @param style   The style where the property is
     * @param resolve if true, resolve the style to find this property
     */
    public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
		if (resolve) {
			return ((Css1Style) style).getFontVariant();
		} else {
			return ((Css1Style) style).cssFont.fontVariant;
		}
    }
}


--- NEW FILE: CssFontStyle.java ---
// $Id: CssFontStyle.java,v 1.1 2012/08/04 21:17:04 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * @since CSS1
 * @version $Revision: 1.1 $
 */
public class CssFontStyle extends CssProperty {

    public CssValue value;

    /**
     * Create a new CssFontStyle
     */
    public CssFontStyle() {
    }

    /**
     * Creates a new CssFontStyle
     *
     * @param expression The expression for this property
     * @throws org.w3c.css.util.InvalidParamException
     *          Expressions are incorrect
     */
    public CssFontStyle(ApplContext ac, CssExpression expression, boolean check)
            throws InvalidParamException {
        throw new InvalidParamException("value",
                expression.getValue().toString(),
                getPropertyName(), ac);
    }

    public CssFontStyle(ApplContext ac, CssExpression expression)
            throws InvalidParamException {
        this(ac, expression, false);
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }


    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return "font-style";
    }

    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value is equals to inherit
     */
    public boolean isSoftlyInherited() {
        return value.equals(inherit);
    }

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        return value.toString();
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
		CssFont cssFont = ((Css1Style) style).cssFont;
		if (cssFont.fontStyle != null)
			style.addRedefinitionWarning(ac, this);
		cssFont.fontStyle = this;
	}


    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssFontStyle &&
                value.equals(((CssFontStyle) property).value));
    }


    /**
     * Get this property in the style.
     *
     * @param style   The style where the property is
     * @param resolve if true, resolve the style to find this property
     */
    public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
		if (resolve) {
			return ((Css1Style) style).getFontStyle();
		} else {
			return ((Css1Style) style).cssFont.fontStyle;
		}
    }
}


--- NEW FILE: CssLineHeight.java ---
// $Id: CssLineHeight.java,v 1.1 2012/08/04 21:17:04 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * @since CSS1
 * @version $Revision: 1.1 $
 */
public class CssLineHeight extends CssProperty {

    public CssValue value;

    /**
     * Create a new CssLineHeight
     */
    public CssLineHeight() {
    }

    /**
     * Creates a new CssLineHeight
     *
     * @param expression The expression for this property
     * @throws org.w3c.css.util.InvalidParamException
     *          Expressions are incorrect
     */
    public CssLineHeight(ApplContext ac, CssExpression expression, boolean check)
            throws InvalidParamException {
        throw new InvalidParamException("value",
                expression.getValue().toString(),
                getPropertyName(), ac);
    }

    public CssLineHeight(ApplContext ac, CssExpression expression)
            throws InvalidParamException {
        this(ac, expression, false);
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }


    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return "line-height";
    }

    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value is equals to inherit
     */
    public boolean isSoftlyInherited() {
        return value.equals(inherit);
    }

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        return value.toString();
    }


	/**
	 * Add this property to the CssStyle.
	 *
	 * @param style The CssStyle
	 */
	public void addToStyle(ApplContext ac, CssStyle style) {
		CssFont cssFont = ((Css1Style) style).cssFont;
		if (cssFont.lineHeight != null)
			style.addRedefinitionWarning(ac, this);
		cssFont.lineHeight = this;
	}

	/**
	 * Get this property in the style.
	 *
	 * @param style The style where the property is
	 * @param resolve if true, resolve the style to find this property
	 */
	public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
		if (resolve) {
			return ((Css1Style) style).getLineHeight();
		} else {
			return ((Css1Style) style).cssFont.lineHeight;
		}
	}

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssLineHeight &&
                value.equals(((CssLineHeight) property).value));
    }

}


--- NEW FILE: CssFontSizeAdjust.java ---
// $Id: CssFontSizeAdjust.java,v 1.1 2012/08/04 21:17:04 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css2.Css2Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * @version $Revision: 1.1 $
 * @since CSS2
 */
public class CssFontSizeAdjust extends CssProperty {

	public CssValue value;

	/**
	 * Create a new CssFontSizeAdjust
	 */
	public CssFontSizeAdjust() {
	}

	/**
	 * Creates a new CssFontSizeAdjust
	 *
	 * @param expression The expression for this property
	 * @throws org.w3c.css.util.InvalidParamException
	 *          Expressions are incorrect
	 */
	public CssFontSizeAdjust(ApplContext ac, CssExpression expression, boolean check)
			throws InvalidParamException {
		throw new InvalidParamException("value",
				expression.getValue().toString(),
				getPropertyName(), ac);
	}

	public CssFontSizeAdjust(ApplContext ac, CssExpression expression)
			throws InvalidParamException {
		this(ac, expression, false);
	}

	/**
	 * Returns the value of this property
	 */
	public Object get() {
		return value;
	}


	/**
	 * Returns the name of this property
	 */
	public final String getPropertyName() {
		return "font-size-adjust";
	}

	/**
	 * Returns true if this property is "softly" inherited
	 * e.g. his value is equals to inherit
	 */
	public boolean isSoftlyInherited() {
		return value.equals(inherit);
	}

	/**
	 * Returns a string representation of the object.
	 */
	public String toString() {
		return value.toString();
	}

	/**
	 * Add this property to the CssStyle.
	 *
	 * @param style The CssStyle
	 */
	public void addToStyle(ApplContext ac, CssStyle style) {
		Css2Style s = (Css2Style) style;
		if (s.cssFontSizeAdjust != null)
			style.addRedefinitionWarning(ac, this);
		s.cssFontSizeAdjust = this;
	}


	/**
	 * Compares two properties for equality.
	 *
	 * @param property The other property.
	 */
	public boolean equals(CssProperty property) {
		return (property instanceof CssFontSizeAdjust &&
				value.equals(((CssFontSizeAdjust) property).value));
	}


	/**
	 * Get this property in the style.
	 *
	 * @param style   The style where the property is
	 * @param resolve if true, resolve the style to find this property
	 */
	public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
		if (resolve) {
			return ((Css2Style) style).getFontSizeAdjust();
		} else {
			return ((Css2Style) style).cssFontSizeAdjust;
		}
	}
}


--- NEW FILE: CssFontSize.java ---
// $Id: CssFontSize.java,v 1.1 2012/08/04 21:17:04 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * @since CSS1
 * @version $Revision: 1.1 $
 */
public class CssFontSize extends CssProperty {

    public CssValue value;

    /**
     * Create a new CssFontSize
     */
    public CssFontSize() {
    }

    /**
     * Creates a new CssFontSize
     *
     * @param expression The expression for this property
     * @throws org.w3c.css.util.InvalidParamException
     *          Expressions are incorrect
     */
    public CssFontSize(ApplContext ac, CssExpression expression, boolean check)
            throws InvalidParamException {
        throw new InvalidParamException("value",
                expression.getValue().toString(),
                getPropertyName(), ac);
    }

    public CssFontSize(ApplContext ac, CssExpression expression)
            throws InvalidParamException {
        this(ac, expression, false);
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }


    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return "font-size";
    }

    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value is equals to inherit
     */
    public boolean isSoftlyInherited() {
        return value.equals(inherit);
    }

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        return value.toString();
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
		CssFont cssFont = ((Css1Style) style).cssFont;
		if (cssFont.fontSize != null)
			style.addRedefinitionWarning(ac, this);
		cssFont.fontSize = this;
	}


    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssFontSize &&
                value.equals(((CssFontSize) property).value));
    }


    /**
     * Get this property in the style.
     *
     * @param style   The style where the property is
     * @param resolve if true, resolve the style to find this property
     */
    public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
		if (resolve) {
			return ((Css1Style) style).getFontSize();
		} else {
			return ((Css1Style) style).cssFont.fontSize;
		}
    }
}


--- NEW FILE: CssFontWeight.java ---
// $Id: CssFontWeight.java,v 1.1 2012/08/04 21:17:04 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * @since CSS1
 * @version $Revision: 1.1 $
 */
public class CssFontWeight extends CssProperty {

    public CssValue value;

    /**
     * Create a new CssFontWeight
     */
    public CssFontWeight() {
    }

    /**
     * Creates a new CssFontWeight
     *
     * @param expression The expression for this property
     * @throws org.w3c.css.util.InvalidParamException
     *          Expressions are incorrect
     */
    public CssFontWeight(ApplContext ac, CssExpression expression, boolean check)
            throws InvalidParamException {
        throw new InvalidParamException("value",
                expression.getValue().toString(),
                getPropertyName(), ac);
    }

    public CssFontWeight(ApplContext ac, CssExpression expression)
            throws InvalidParamException {
        this(ac, expression, false);
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }


    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return "font-weight";
    }

    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value is equals to inherit
     */
    public boolean isSoftlyInherited() {
        return value.equals(inherit);
    }

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        return value.toString();
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
		CssFont cssFont = ((Css1Style) style).cssFont;
		if (cssFont.fontWeight != null)
			style.addRedefinitionWarning(ac, this);
		cssFont.fontWeight = this;
	}


    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssFontWeight &&
                value.equals(((CssFontWeight) property).value));
    }


    /**
     * Get this property in the style.
     *
     * @param style   The style where the property is
     * @param resolve if true, resolve the style to find this property
     */
    public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
		if (resolve) {
			return ((Css1Style) style).getFontWeight();
		} else {
			return ((Css1Style) style).cssFont.fontWeight;
		}
    }
}


--- NEW FILE: CssFontFamily.java ---
// $Id: CssFontFamily.java,v 1.1 2012/08/04 21:17:04 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

import java.util.ArrayList;

/**
 * @since CSS1
 * @version $Revision: 1.1 $
 */
public class CssFontFamily extends CssProperty {

    public Object value;
	public boolean hasGenericFontFamily = false;

    /**
     * Create a new CssFontFamily
     */
    public CssFontFamily() {
    }

    /**
     * Creates a new CssFontFamily
     *
     * @param expression The expression for this property
     * @throws org.w3c.css.util.InvalidParamException
     *          Expressions are incorrect
     */
    public CssFontFamily(ApplContext ac, CssExpression expression, boolean check)
            throws InvalidParamException {
        throw new InvalidParamException("value",
                expression.getValue().toString(),
                getPropertyName(), ac);
    }

    public CssFontFamily(ApplContext ac, CssExpression expression)
            throws InvalidParamException {
        this(ac, expression, false);
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

	public boolean containsGenericFamily() {
		return hasGenericFontFamily;
	}

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return "font-family";
    }

    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value is equals to inherit
     */
    public boolean isSoftlyInherited() {
        return value.equals(inherit);
    }

	/**
	 * Returns a string representation of the object.
	 */
	public String toString() {
		if (value instanceof ArrayList) {
			StringBuilder sb = new StringBuilder();
			boolean first = true;
			for (CssValue aCssValue : (ArrayList<CssValue>) value) {
				if (!first) {
					sb.append(',');
				} else {
					first = false;
				}
				sb.append(aCssValue.toString());
			}
			return sb.toString();
		}
		return value.toString();
	}

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
		CssFont cssFont = ((Css1Style) style).cssFont;
		if (cssFont.fontFamily != null)
			style.addRedefinitionWarning(ac, this);
		cssFont.fontFamily = this;
	}


    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssFontFamily &&
                value.equals(((CssFontFamily) property).value));
    }


    /**
     * Get this property in the style.
     *
     * @param style   The style where the property is
     * @param resolve if true, resolve the style to find this property
     */
    public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
		if (resolve) {
			return ((Css1Style) style).getFontFamily();
		} else {
			return ((Css1Style) style).cssFont.fontFamily;
		}
    }

	/**
	 * Used to check that the value contains a generic font family
	 * @return a boolean, true if it contains one
	 */
	public boolean hasGenericFamily() {
		return hasGenericFontFamily;
	}
}

Received on Saturday, 4 August 2012 21:17:09 UTC