use of com.gargoylesoftware.css.parser.CSSOMParser in project LoboEvolution by LoboEvolution.
the class CSSStyleSheetImpl method setMediaText.
/**
* Set the media text.
*
* @param mediaText the new media text
*/
public void setMediaText(final String mediaText) {
if (mediaText == null || mediaText.length() == 0) {
final MediaQueryList sml = new MediaQueryList();
sml.add(new MediaQuery(null));
media_ = new MediaListImpl(sml);
return;
}
try {
final CSSOMParser parser = new CSSOMParser();
final MediaQueryList sml = parser.parseMedia(mediaText);
media_ = new MediaListImpl(sml);
} catch (final IOException e) {
// TODO handle exception
}
}
use of com.gargoylesoftware.css.parser.CSSOMParser in project LoboEvolution by LoboEvolution.
the class CSSUnknownRuleImpl method setCssText.
/**
* {@inheritDoc}
*/
@Override
public void setCssText(final String cssText) throws DOMException {
try {
final CSSOMParser parser = new CSSOMParser();
final AbstractCSSRuleImpl r = parser.parseRule(cssText);
// The rule must be an unknown rule
if (r instanceof CSSUnknownRuleImpl) {
text_ = ((CSSUnknownRuleImpl) r).text_;
} else {
throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, DOMException.EXPECTING_FONT_FACE_RULE);
}
} catch (final CSSException e) {
throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
} catch (final IOException e) {
throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
}
}
use of com.gargoylesoftware.css.parser.CSSOMParser in project LoboEvolution by LoboEvolution.
the class CSSFontFaceRuleImpl method setCssText.
/**
* {@inheritDoc}
*/
@Override
public void setCssText(final String cssText) throws DOMException {
try {
final CSSOMParser parser = new CSSOMParser();
final AbstractCSSRuleImpl r = parser.parseRule(cssText);
// The rule must be a font face rule
if (r instanceof CSSFontFaceRuleImpl) {
style_ = ((CSSFontFaceRuleImpl) r).style_;
} else {
throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, DOMException.EXPECTING_FONT_FACE_RULE);
}
} catch (final CSSException e) {
throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
} catch (final IOException e) {
throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
}
}
use of com.gargoylesoftware.css.parser.CSSOMParser in project LoboEvolution by LoboEvolution.
the class CSSMediaRuleImpl method setCssText.
/**
* {@inheritDoc}
*/
@Override
public void setCssText(final String cssText) throws DOMException {
try {
final CSSOMParser parser = new CSSOMParser();
final AbstractCSSRuleImpl r = parser.parseRule(cssText);
// The rule must be a media rule
if (r instanceof CSSMediaRuleImpl) {
mediaList_ = ((CSSMediaRuleImpl) r).mediaList_;
cssRules_ = ((CSSMediaRuleImpl) r).cssRules_;
} else {
throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, DOMException.EXPECTING_MEDIA_RULE);
}
} catch (final CSSException e) {
throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
} catch (final IOException e) {
throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
}
}
use of com.gargoylesoftware.css.parser.CSSOMParser in project LoboEvolution by LoboEvolution.
the class CSSStyleRuleImpl method setSelectorText.
/**
* Sets the selector text.
* @param selectorText the new selector text
* @throws DOMException in clase of error
*/
public void setSelectorText(final String selectorText) throws DOMException {
try {
final CSSOMParser parser = new CSSOMParser();
selectors_ = parser.parseSelectors(selectorText);
} catch (final CSSException e) {
throw new DOMException(DOMException.SYNTAX_ERR, e.getMessage());
} catch (final IOException e) {
throw new DOMException(DOMException.SYNTAX_ERR, e.getMessage());
}
}
Aggregations