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

cz.vutbr.web.csskit.AbstractRule 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 java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import cz.vutbr.web.css.Rule;

public class AbstractRule extends AbstractList implements Rule {
	
	protected List list = Collections.emptyList();
	protected int hash = 0;
	
	public List asList() {
		return this.list;
	}
	
	public Rule replaceAll(List replacement) {
        hash = 0;
		this.list = replacement;
		return this;
	}
	
	public Rule unlock() {
        hash = 0;
		this.list = new ArrayList();
		return this;
	}
	
	@Override
	public int size() {
		return list.size();
	}
	
	@Override
	public T get(int index) {
		return list.get(index);
	}	
	
	@Override
	public T set(int index, T element) {
        hash = 0;
		return list.set(index, element);
	}
	
	@Override
	public void add(int index, T element) {
        hash = 0;
		list.add(index, element);
	}
	
	@Override
	public T remove(int index) {
        hash = 0;
		return list.remove(index);
	}
	
	@Override
	public Iterator iterator() {
		return list.iterator();
	}

	@Override
	public boolean add(T o) {
	    hash = 0;
		return list.add(o);
	}

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
	@Override
	public int hashCode() {
	    if (hash == 0)
	    {
    		final int prime = 31;
    		int result = super.hashCode();
    		result = prime * result + ((list == null) ? 0 : list.hashCode());
    		hash = result;
	    }
	    return hash;
	}

	/* (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 AbstractRule))
			return false;
		AbstractRule other = (AbstractRule) obj;
		if (list == null) {
			if (other.list != null)
				return false;
		} else if (!list.equals(other.list))
			return false;
		return true;
	}

	
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy