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

cz.vutbr.web.csskit.TermNumericImpl Maven / Gradle / Ivy

Go to download

jStyleParser is a CSS parser written in Java. It has its own application interface that is designed to allow an efficient CSS processing in Java and mapping the values to the Java data types. It parses CSS 2.1 style sheets into structures that can be efficiently assigned to DOM elements. It is intended be the primary CSS parser for the CSSBox library. While handling errors, it is user agent conforming according to the CSS specification.

The newest version!
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.TermNumeric;

public abstract class TermNumericImpl extends TermImpl implements TermNumeric {

	protected Unit unit;
	
	/**
	 * @return the unit
	 */
	public Unit getUnit() {
		return unit;
	}

	/**
	 * @param unit the unit to set
	 */
	public TermNumeric setUnit(Unit unit) {
		this.unit = unit;
		return this;
	}

	@Override
    public String toString() {
		StringBuilder sb = new StringBuilder();
		if(operator!=null) sb.append(operator.value());
		if (value != null) {
			if ((double)value.intValue() == value.doubleValue()) {
				sb.append(value.intValue());
			} else {
				sb.append(value);
			}
		}
		if(unit!=null) sb.append(unit.value());
		return sb.toString();
    }
	
	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((unit == null) ? 0 : unit.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (!(obj instanceof TermNumericImpl))
			return false;
		@SuppressWarnings("unchecked")
		TermNumericImpl other = (TermNumericImpl) obj;
		if (unit == null) {
			if (other.unit != null)
				return false;
		} else if (!unit.equals(other.unit))
			return false;
		return true;
	}
	
	
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy