本文整理汇总了Java中cz.vutbr.web.css.CSSFactory.parse方法的典型用法代码示例。如果您正苦于以下问题:Java CSSFactory.parse方法的具体用法?Java CSSFactory.parse怎么用?Java CSSFactory.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cz.vutbr.web.css.CSSFactory
的用法示例。
在下文中一共展示了CSSFactory.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@BeforeClass
public static void init() throws IOException, CSSException, SAXException {
log.info("\n\n\n == AnalyzerTest test at {} == \n\n\n", new Date());
DOMSource ds = new DOMSource(AnalyzerTest.class.getResourceAsStream("/simple/data.html"));
doc = ds.parse();
sheet = CSSFactory.parse(AnalyzerTest.class.getResource("/simple/data.css"), null);
analyzer = new Analyzer(sheet);
NodeList list = doc.getElementsByTagName("body");
assertEquals("There is one <body> element", 1, list.getLength());
//walker = new TidyTreeWalker(list.item(0), NodeFilter.SHOW_ELEMENT);
DocumentTraversal traversal = (DocumentTraversal) doc;
walker = traversal.createTreeWalker(list.item(0), NodeFilter.SHOW_ELEMENT, null, false);
elements = new ElementMap(doc);
}
示例2: parse
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
static StyleSheet parse(final String css) {
try {
return CSSFactory.parse(css);
} catch (IOException | CSSException e) {
throw new DOMException(DOMException.SYNTAX_ERR, "");
}
}
示例3: testMediaImport
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@Test
public void testMediaImport() throws CSSException, IOException {
CSSFactory.setAutoImportMedia(new MediaSpecAll()); //reset to default
StyleSheet ss = CSSFactory.parse(getClass().getResource("/simple/impmedia.css"), null);
assertEquals("All rules have been imported", 8, ss.size());
}
示例4: testMediaImportLimit1
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@Test
public void testMediaImportLimit1() throws CSSException, IOException {
CSSFactory.setAutoImportMedia(new MediaSpec("projection"));
StyleSheet ss = CSSFactory.parse(getClass().getResource("/simple/impmedia.css"), null);
assertEquals("All rules have been imported", 8, ss.size());
}
示例5: testMediaImportLimit2
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@Test
public void testMediaImportLimit2() throws CSSException, IOException {
CSSFactory.setAutoImportMedia(new MediaSpec("screen"));
StyleSheet ss = CSSFactory.parse(getClass().getResource("/simple/impmedia.css"), null);
assertEquals("No rules have been imported", 0, ss.size());
}
示例6: testMediaImportLimit3
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@Test
public void testMediaImportLimit3() throws CSSException, IOException {
CSSFactory.setAutoImportMedia(new MediaSpecNone());
StyleSheet ss = CSSFactory.parse(getClass().getResource("/simple/impmedia.css"), null);
assertEquals("No rules have been imported", 0, ss.size());
}
示例7: testRealAndNested
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@Test
public void testRealAndNested() throws CSSException, IOException {
CSSFactory.parse(getClass().getResource("/abclinuxu/styles.css"), null);
}
示例8: testExternAndNested
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@Test
public void testExternAndNested() throws CSSException, IOException {
CSSFactory.parse(new URL("http://www.abclinuxu.cz/styles.css"), null);
}
示例9: testImportEscaped
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@Test
public void testImportEscaped() throws CSSException,IOException{
StyleSheet ss = CSSFactory.parse(getClass().getResource("/simple/imp_escaped.css"), null);
this.checkDataCSS(ss);
}
示例10: testString1
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@Test
public void testString1() throws IOException, CSSException {
URL url = getClass().getResource("/simple/charset1.css");
StyleSheet ss = CSSFactory.parse(url, "utf-8");
assertEquals("One rule is set", 1, ss.size());
RuleSet rule = (RuleSet) ss.get(0);
assertArrayEquals("Rule contains one selector BODY ",
SelectorsUtil.createSelectors("tést"),
rule.getSelectors());
assertEquals("Rule contains one declaration", rule.size(), 1);
}
示例11: init
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@BeforeClass
public static void init() throws IOException, CSSException, SAXException {
log.info("\n\n\n == AdvancedTest test at {} == \n\n\n", new Date());
DOMSource ds = new DOMSource(AdvancedCSSTest.class.getResourceAsStream("/advanced/style.html"));
doc = ds.parse();
sheet = CSSFactory.parse(AdvancedCSSTest.class.getResource("/advanced/style.css"), null);
analyzer = new Analyzer(sheet);
decl = analyzer.evaluateDOM(doc, "all", true);
elements = new ElementMap(doc);
}
示例12: testSimpleImport
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@Test
public void testSimpleImport() throws CSSException, IOException {
StyleSheet ss = CSSFactory.parse(getClass().getResource("/simple/imp.css"), null);
this.checkDataCSS(ss);
}
示例13: init
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@BeforeClass
public static void init() throws CSSException, IOException, SAXException {
log.info("\n\n\n == UAConformancy test at {} == \n\n\n", new Date());
DOMSource ds = new DOMSource(UAConformancyTest.class.getResourceAsStream("/invalid/style.html"));
Document doc = ds.parse();
em = new ElementMap(doc);
StyleSheet sheet = CSSFactory.parse(UAConformancyTest.class.getResource("/invalid/style.css"), null);
Analyzer analyzer = new Analyzer(sheet);
decl = analyzer.evaluateDOM(doc, "screen", true);
}
示例14: init
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@BeforeClass
public static void init() throws CSSException, IOException, SAXException {
log.info("\n\n\n == NodeDataVariant test at {} == \n\n\n", new Date());
DOMSource ds = new DOMSource(new FileInputStream("data/simple/data.html"));
doc = ds.parse();
StyleSheet style = CSSFactory.parse("data/simple/data.css", null);
analyzer = new Analyzer(style);
}
示例15: main
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Date start = new Date();
StyleSheet sheet = CSSFactory.parse("src/test/resources/profiling/slate.css", "UTF-8");
System.out.println("Total rules: " + sheet.size());
Date end = new Date();
System.out.println("Parsing time: " + (end.getTime() - start.getTime()) + " ms");
}