All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.w3c.css.values.CssFrequency Maven / Gradle / Ivy

The newest version!
//
// $Id: CssFrequency.java,v 1.7 2010-01-05 13:50:00 ylafon Exp $
// From Philippe Le Hegaret ([email protected])
//
// (c) COPYRIGHT MIT and INRIA, 1997.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.values;

import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.util.Util;

/**
 * 

Frequencies

* *

Frequency units are used with aural cascading style sheets. * *

There are two legal frequency units: * *

    *
  • Hz: Hertz *
  • kHz: kilo Hertz *
* *

For example, 200Hz is a bass sound, and 6kHz is a treble sound. * * @version $Revision: 1.7 $ */ public class CssFrequency extends CssValue { public static final int type = CssTypes.CSS_FREQUENCY; public final int getType() { return type; } /** * Create a new CssFrequency */ public CssFrequency() { value = defaultValue; } /** * Create a new CssFrequency with a float number. * * @param value the float number. */ public CssFrequency(Float value) { this.value = value; } /** * Set the value of this frequency. * * @param s the string representation of the frequency. * @param ac For errors and warnings reports. * @exception InvalidParamException The unit is incorrect */ public void set(String s, ApplContext ac) throws InvalidParamException { s = s.toLowerCase(); int length = s.length(); String unit; float v; if (s.charAt(length-3) == 'k') { unit = s.substring(length-3, length); v = Float.parseFloat(s.substring(0, length - 3)); } else { unit = s.substring(length-2, length); v = Float.parseFloat(s.substring(0, length - 2)); } int hash = unit.hashCode(); int i = 0; while (i





© 2015 - 2024 Weber Informatics LLC | Privacy Policy