本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.getCssErrorHandler()
方法的一些代码示例,展示了WebClient.getCssErrorHandler()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.getCssErrorHandler()
方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:getCssErrorHandler
[英]Returns the CSS error handler used by this web client when CSS problems are encountered.
[中]返回遇到CSS问题时此web客户端使用的CSS错误处理程序。
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Verifies if the provided node is a link node pointing to an active stylesheet.
*
* @param domNode the mode to check
* @return true if the provided node is a stylesheet link
*/
public boolean isActiveStyleSheetLink(final DomNode domNode) {
if (domNode instanceof HtmlLink) {
final HtmlLink link = (HtmlLink) domNode;
String rel = link.getRelAttribute();
if (rel != null) {
rel = rel.trim();
}
if ("stylesheet".equalsIgnoreCase(rel)) {
final String media = link.getMediaAttribute();
if (StringUtils.isBlank(media)) {
return true;
}
final WebClient webClient = getWindow().getWebWindow().getWebClient();
final MediaList mediaList = CSSStyleSheet.parseMedia(webClient.getCssErrorHandler(), media);
return CSSStyleSheet.isActive(this, mediaList);
}
}
return false;
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Verifies if the provided node is a link node pointing to an active stylesheet.
*
* @param domNode the mode to check
* @return true if the provided node is a stylesheet link
*/
public boolean isActiveStyleSheetLink(final DomNode domNode) {
if (domNode instanceof HtmlLink) {
final HtmlLink link = (HtmlLink) domNode;
String rel = link.getRelAttribute();
if (rel != null) {
rel = rel.trim();
}
if ("stylesheet".equalsIgnoreCase(rel)) {
final String media = link.getMediaAttribute();
if (StringUtils.isBlank(media)) {
return true;
}
final WebClient webClient = getWindow().getWebWindow().getWebClient();
final MediaListImpl mediaList = CSSStyleSheet.parseMedia(webClient.getCssErrorHandler(), media);
return CSSStyleSheet.isActive(this, mediaList);
}
}
return false;
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Returns whether the specified media is supported by the object that displays the document object.
* @param media the media query
* @return whether the specified media is supported or not
*/
@JsxFunction
public boolean matchMedium(final String media) {
final CSSErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final MediaList mediaList = CSSStyleSheet.parseMedia(errorHandler, media);
return CSSStyleSheet.isActive(this, mediaList);
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Returns whether the document currently matches the media query list or not.
* @return whether the document currently matches the media query list or not
*/
@JsxGetter
public boolean isMatches() {
final CSSErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final MediaList mediaList = CSSStyleSheet.parseMedia(errorHandler, media_);
return CSSStyleSheet.isActive(this, mediaList);
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Returns whether the document currently matches the media query list or not.
* @return whether the document currently matches the media query list or not
*/
@JsxGetter
public boolean isMatches() {
final CSSErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final MediaListImpl mediaList = CSSStyleSheet.parseMedia(errorHandler, media_);
return CSSStyleSheet.isActive(this, mediaList);
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Returns whether the specified media is supported by the object that displays the document object.
* @param media the media query
* @return whether the specified media is supported or not
*/
@JsxFunction
public boolean matchMedium(final String media) {
final CSSErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final MediaListImpl mediaList = CSSStyleSheet.parseMedia(errorHandler, media);
return CSSStyleSheet.isActive(this, mediaList);
}
代码示例来源:origin: org.jenkins-ci/htmlunit
/**
* Parses the selectors at the specified input source. If anything at all goes wrong, this
* method returns an empty selector list.
*
* @param source the source from which to retrieve the selectors to be parsed
* @return the selectors parsed from the specified input source
*/
SelectorList parseSelectors(final InputSource source) {
SelectorList selectors;
try {
final ErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final CSSOMParser parser = new CSSOMParser(new SACParserCSS21());
parser.setErrorHandler(errorHandler);
selectors = parser.parseSelectors(source);
}
catch (final Exception e) {
LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + e.getMessage(), e);
selectors = new SelectorListImpl();
}
catch (final Error e) {
// SACParser sometimes throws Error: "Missing return statement in function"
LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + e.getMessage(), e);
selectors = new SelectorListImpl();
}
return selectors;
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Parses the selectors at the specified input source. If anything at all goes wrong, this
* method returns an empty selector list.
*
* @param source the source from which to retrieve the selectors to be parsed
* @return the selectors parsed from the specified input source
*/
SelectorList parseSelectors(final InputSource source) {
SelectorList selectors;
try {
final ErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final CSSOMParser parser = new CSSOMParser(new SACParserCSS21());
parser.setErrorHandler(errorHandler);
selectors = parser.parseSelectors(source);
}
catch (final Exception e) {
LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + e.getMessage(), e);
selectors = new SelectorListImpl();
}
catch (final Error e) {
// SACParser sometimes throws Error: "Missing return statement in function"
LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + e.getMessage(), e);
selectors = new SelectorListImpl();
}
return selectors;
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Parses the CSS at the specified input source. If anything at all goes wrong, this method
* returns an empty stylesheet.
*
* @param source the source from which to retrieve the CSS to be parsed
* @return the stylesheet parsed from the specified input source
*/
private CSSStyleSheetImpl parseCSS(final InputSource source) {
CSSStyleSheetImpl ss;
try {
final CSSErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final CSSOMParser parser = new CSSOMParser(new CSS3Parser());
parser.setErrorHandler(errorHandler);
ss = parser.parseStyleSheet(source, null);
}
catch (final Throwable t) {
if (LOG.isErrorEnabled()) {
LOG.error("Error parsing CSS from '" + toString(source) + "': " + t.getMessage(), t);
}
ss = new CSSStyleSheetImpl();
}
return ss;
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Parses the CSS at the specified input source. If anything at all goes wrong, this method
* returns an empty stylesheet.
*
* @param source the source from which to retrieve the CSS to be parsed
* @return the stylesheet parsed from the specified input source
*/
private org.w3c.dom.css.CSSStyleSheet parseCSS(final InputSource source) {
org.w3c.dom.css.CSSStyleSheet ss;
try {
final CSSErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final CSSOMParser parser = new CSSOMParser(new CSS3Parser());
parser.setErrorHandler(errorHandler);
ss = parser.parseStyleSheet(source, null);
}
catch (final Throwable t) {
LOG.error("Error parsing CSS from '" + toString(source) + "': " + t.getMessage(), t);
ss = new CSSStyleSheetImpl();
}
return ss;
}
代码示例来源:origin: org.jvnet.hudson/htmlunit
/**
* Parses the CSS at the specified input source. If anything at all goes wrong, this method
* returns an empty stylesheet.
*
* @param source the source from which to retrieve the CSS to be parsed
* @return the stylesheet parsed from the specified input source
*/
private CSSStyleSheet parseCSS(final InputSource source) {
CSSStyleSheet ss;
try {
final ErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final CSSOMParser parser = new CSSOMParser(new SACParserCSS21());
parser.setErrorHandler(errorHandler);
ss = parser.parseStyleSheet(source, null, null);
}
catch (final Exception e) {
LOG.error("Error parsing CSS from '" + toString(source) + "': " + e.getMessage(), e);
ss = new CSSStyleSheetImpl();
}
catch (final Error e) {
// SACParser sometimes throws Error: "Missing return statement in function"
LOG.error("Error parsing CSS from '" + toString(source) + "': " + e.getMessage(), e);
ss = new CSSStyleSheetImpl();
}
return ss;
}
代码示例来源:origin: org.jvnet.hudson/htmlunit
/**
* Parses the selectors at the specified input source. If anything at all goes wrong, this
* method returns an empty selector list.
*
* @param source the source from which to retrieve the selectors to be parsed
* @return the selectors parsed from the specified input source
*/
SelectorList parseSelectors(final InputSource source) {
SelectorList selectors;
try {
final ErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final CSSOMParser parser = new CSSOMParser(new SACParserCSS21());
parser.setErrorHandler(errorHandler);
selectors = parser.parseSelectors(source);
}
catch (final Exception e) {
LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + e.getMessage(), e);
selectors = new SelectorListImpl();
}
catch (final Error e) {
// SACParser sometimes throws Error: "Missing return statement in function"
LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + e.getMessage(), e);
selectors = new SelectorListImpl();
}
return selectors;
}
代码示例来源:origin: org.jenkins-ci/htmlunit
/**
* Parses the CSS at the specified input source. If anything at all goes wrong, this method
* returns an empty stylesheet.
*
* @param source the source from which to retrieve the CSS to be parsed
* @return the stylesheet parsed from the specified input source
*/
private CSSStyleSheet parseCSS(final InputSource source) {
CSSStyleSheet ss;
try {
final ErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final CSSOMParser parser = new CSSOMParser(new SACParserCSS21());
parser.setErrorHandler(errorHandler);
ss = parser.parseStyleSheet(source, null, null);
}
catch (final Exception e) {
LOG.error("Error parsing CSS from '" + toString(source) + "': " + e.getMessage(), e);
ss = new CSSStyleSheetImpl();
}
catch (final Error e) {
// SACParser sometimes throws Error: "Missing return statement in function"
LOG.error("Error parsing CSS from '" + toString(source) + "': " + e.getMessage(), e);
ss = new CSSStyleSheetImpl();
}
return ss;
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Parses the CSS at the specified input source. If anything at all goes wrong, this method
* returns an empty stylesheet.
*
* @param source the source from which to retrieve the CSS to be parsed
* @return the stylesheet parsed from the specified input source
*/
private CSSStyleSheet parseCSS(final InputSource source) {
CSSStyleSheet ss;
try {
final ErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final CSSOMParser parser = new CSSOMParser(new SACParserCSS21());
parser.setErrorHandler(errorHandler);
ss = parser.parseStyleSheet(source, null, null);
}
catch (final Exception e) {
LOG.error("Error parsing CSS from '" + toString(source) + "': " + e.getMessage(), e);
ss = new CSSStyleSheetImpl();
}
catch (final Error e) {
// SACParser sometimes throws Error: "Missing return statement in function"
LOG.error("Error parsing CSS from '" + toString(source) + "': " + e.getMessage(), e);
ss = new CSSStyleSheetImpl();
}
return ss;
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Parses the selectors at the specified input source. If anything at all goes wrong, this
* method returns an empty selector list.
*
* @param source the source from which to retrieve the selectors to be parsed
* @return the selectors parsed from the specified input source
*/
public SelectorList parseSelectors(final InputSource source) {
SelectorList selectors;
try {
final CSSErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final CSSOMParser parser = new CSSOMParser(new CSS3Parser());
parser.setErrorHandler(errorHandler);
selectors = parser.parseSelectors(source);
// in case of error parseSelectors returns null
if (null == selectors) {
selectors = new SelectorListImpl();
}
}
catch (final Throwable t) {
if (LOG.isErrorEnabled()) {
LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + t.getMessage(), t);
}
selectors = new SelectorListImpl();
}
return selectors;
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Returns {@code true} if this stylesheet is active, based on the media types it is associated with (if any).
* @return {@code true} if this stylesheet is active, based on the media types it is associated with (if any)
*/
public boolean isActive() {
final String media;
final HtmlElement e = ownerNode_.getDomNodeOrNull();
if (e instanceof HtmlStyle) {
final HtmlStyle style = (HtmlStyle) e;
media = style.getMediaAttribute();
}
else if (e instanceof HtmlLink) {
final HtmlLink link = (HtmlLink) e;
media = link.getMediaAttribute();
}
else {
return true;
}
if (StringUtils.isBlank(media)) {
return true;
}
final WebClient webClient = getWindow().getWebWindow().getWebClient();
final MediaList mediaList = parseMedia(webClient.getCssErrorHandler(), media);
return isActive(this, mediaList);
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Returns {@code true} if this stylesheet is active, based on the media types it is associated with (if any).
* @return {@code true} if this stylesheet is active, based on the media types it is associated with (if any)
*/
public boolean isActive() {
final String media;
final HtmlElement e = ownerNode_.getDomNodeOrNull();
if (e instanceof HtmlStyle) {
final HtmlStyle style = (HtmlStyle) e;
media = style.getMediaAttribute();
}
else if (e instanceof HtmlLink) {
final HtmlLink link = (HtmlLink) e;
media = link.getMediaAttribute();
}
else {
return true;
}
if (StringUtils.isBlank(media)) {
return true;
}
final WebClient webClient = getWindow().getWebWindow().getWebClient();
final MediaListImpl mediaList = parseMedia(webClient.getCssErrorHandler(), media);
return isActive(this, mediaList);
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Parses the selectors at the specified input source. If anything at all goes wrong, this
* method returns an empty selector list.
*
* @param source the source from which to retrieve the selectors to be parsed
* @return the selectors parsed from the specified input source
*/
public SelectorList parseSelectors(final InputSource source) {
SelectorList selectors;
try {
final CSSErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final CSSOMParser parser = new CSSOMParser(new CSS3Parser());
parser.setErrorHandler(errorHandler);
selectors = parser.parseSelectors(source);
// in case of error parseSelectors returns null
if (null == selectors) {
selectors = new SelectorListImpl();
}
}
catch (final Throwable t) {
LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + t.getMessage(), t);
selectors = new SelectorListImpl();
}
return selectors;
}
代码示例来源:origin: org.jenkins-ci/htmlunit
final InputSource source = new InputSource(new StringReader(styleAttribute));
source.setURI(uri);
final ErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final CSSOMParser parser = new CSSOMParser(new SACParserCSS21());
parser.setErrorHandler(errorHandler);
代码示例来源:origin: org.jvnet.hudson/htmlunit
final InputSource source = new InputSource(new StringReader(styleAttribute));
source.setURI(uri);
final ErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
final CSSOMParser parser = new CSSOMParser(new SACParserCSS21());
parser.setErrorHandler(errorHandler);
内容来源于网络,如有侵权,请联系作者删除!