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

cz.vutbr.web.domassign.DeclarationMap 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!
/**
 * DeclarationMap.java
 *
 * Created on 22.1.2010, 16:23:07 by burgetr
 */
package cz.vutbr.web.domassign;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.w3c.dom.Element;

import cz.vutbr.web.css.Declaration;
import cz.vutbr.web.css.Selector.PseudoElementType;

/**
 * This is a map that assigns a sorted list of declarations to each element 
 * and an optional pseudo-element. 
 * 
 * @author burgetr
 */
public class DeclarationMap extends MultiMap>
{

    /**
     * Adds a declaration for a specified list. If the list does not exist yet, it is created.
     * @param el the element that the declaration belongs to
     * @param pseudo an optional pseudo-element or null
     * @param decl the new declaration
     */
    public void addDeclaration(Element el, PseudoElementType pseudo, Declaration decl)
    {
        List list = getOrCreate(el, pseudo);
        list.add(decl);
    }
    
    /**
     * Sorts the given list according to the rule specificity.
     * @param el the element to which the list is assigned
     * @param pseudo an optional pseudo-element or null
     */
    public void sortDeclarations(Element el, PseudoElementType pseudo)
    {
        List list = get(el, pseudo);
        if (list != null)
            Collections.sort(list);
    }

	@Override
	protected List createDataInstance()
	{
		return new ArrayList();
	}
    
    
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy