![JAR search and dependency download from the Maven repository](/logo.png)
cz.vutbr.web.csskit.RuleMediaImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jstyleparser Show documentation
Show all versions of jstyleparser Show documentation
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.Collections;
import java.util.List;
import cz.vutbr.web.css.MediaQuery;
import cz.vutbr.web.css.RuleMedia;
import cz.vutbr.web.css.RuleSet;
import cz.vutbr.web.css.StyleSheet;
/**
* Implementation of RuleMedia
*
* @author kapy
* @author Jan Svercl, VUT Brno, 2008
*
*/
public class RuleMediaImpl extends AbstractRuleBlock implements RuleMedia {
/** List of medias */
protected List media;
/**
* Creates an empty object to be filled by interface methods
*/
protected RuleMediaImpl() {
this.media = Collections.emptyList();
}
@Override
public List getMediaQueries() {
return media;
}
@Override
public RuleMedia setMediaQueries(List medias) {
this.media = medias;
return this;
}
@Override
public void setStyleSheet(StyleSheet stylesheet)
{
super.setStyleSheet(stylesheet);
//assign the style sheet recursively to the contained rule sets
for (RuleSet set : list)
set.setStyleSheet(stylesheet);
}
@Override
public String toString() {
return this.toString(0);
}
public String toString(int depth) {
StringBuilder sb = new StringBuilder();
// append medias
sb = OutputUtil.appendTimes(sb, OutputUtil.DEPTH_DELIM, depth);
sb.append(OutputUtil.MEDIA_KEYWORD);
sb = OutputUtil.appendList(sb, media, OutputUtil.MEDIA_DELIM);
// append rules
sb = OutputUtil.appendTimes(sb, OutputUtil.DEPTH_DELIM, depth);
sb.append(OutputUtil.RULE_OPENING);
sb = OutputUtil.appendList(sb, list, OutputUtil.RULE_DELIM, depth + 1);
sb.append(OutputUtil.RULE_CLOSING);
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 + ((media == null) ? 0 : media.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 RuleMediaImpl))
return false;
RuleMediaImpl other = (RuleMediaImpl) obj;
if (media == null) {
if (other.media != null)
return false;
} else if (!media.equals(other.media))
return false;
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy