本文整理汇总了Java中org.w3c.css.sac.Parser类的典型用法代码示例。如果您正苦于以下问题:Java Parser类的具体用法?Java Parser怎么用?Java Parser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Parser类属于org.w3c.css.sac包,在下文中一共展示了Parser类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeParser
import org.w3c.css.sac.Parser; //导入依赖的package包/类
@Override
public Parser makeParser(String name) throws ClassNotFoundException, IllegalAccessException, InstantiationException,
NullPointerException, ClassCastException {
String classNameParser = parsers.get(name);
if (classNameParser != null) {
Class<?> classParser = super.getClass().getClassLoader().loadClass(classNameParser);
return (Parser) classParser.newInstance();
}
throw new IllegalAccessException("SAC parser with name=" + name
+ " was not registered into SAC parser factory.");
}
示例2: CSSParser
import org.w3c.css.sac.Parser; //导入依赖的package包/类
public CSSParser(InputSource source, Parser parser) throws CSSException, IOException {
this.handler = new CSSDocumentHandler();
parser.setDocumentHandler(handler);
parser.setConditionFactory(CSSConditionFactory.INSTANCE);
parser.setSelectorFactory(CSSSelectorFactory.INSTANCE);
parser.parseStyleSheet(source);
}
示例3: makeParser
import org.w3c.css.sac.Parser; //导入依赖的package包/类
/**
* Return default instance of SAC Parser. If preferredParserName is filled,
* it return the instance of SAC Parser registered with this name, otherwise
* this method search the SAC Parser class name to instanciate into System
* property with key org.w3c.css.sac.parser.
*/
@Override
public Parser makeParser() throws ClassNotFoundException, IllegalAccessException, InstantiationException,
NullPointerException, ClassCastException {
try {
if (preferredParserName != null)
return makeParser(preferredParserName);
} catch (Throwable e) {
e.printStackTrace();
}
return super.makeParser();
}
示例4: CSSOMParser
import org.w3c.css.sac.Parser; //导入依赖的package包/类
/**
* Creates new CSSOMParser.
*
* @param parser
* the SAC Parser
*/
public CSSOMParser(final Parser parser) {
synchronized (LOCK) {
if (null != parser) {
System.setProperty("org.w3c.css.sac.parser", parser.getClass().getCanonicalName());
parser_ = parser;
return;
}
// no parser provided, determine the correct one
String currentParser = System.getProperty("org.w3c.css.sac.parser");
try {
// use the direct method if we already failed once before
if (null != LastFailed_ && LastFailed_.equals(currentParser)) {
parser_ = new SACParserCSS21();
} else {
if (null == currentParser) {
System.setProperty("org.w3c.css.sac.parser", DEFAULT_PARSER);
currentParser = DEFAULT_PARSER;
}
final ParserFactory factory = new ParserFactory();
parser_ = factory.makeParser();
}
} catch (final Exception e) {
logger.warn(e.toString());
logger.warn("using the default 'SACParserCSS21' instead");
logger.warn("CSSOMParser", "consturctor", e);
LastFailed_ = currentParser;
parser_ = new SACParserCSS21();
}
}
}
示例5: CSSEngine
import org.w3c.css.sac.Parser; //导入依赖的package包/类
/**
* Creates a new CSSEngine.
* @param p The css parser.
* @param pm The property value managers.
* @param ctx The CSS context.
*/
protected CSSEngine( Parser p, PropertyManagerFactory pm, CSSContext ctx )
{
this.parser = p;
this.cssContext = ctx;
this.pm = pm;
}
示例6: ExtendedParserWrapper
import org.w3c.css.sac.Parser; //导入依赖的package包/类
public ExtendedParserWrapper(Parser parser) {
this.parser = parser;
}
示例7: getParser
import org.w3c.css.sac.Parser; //导入依赖的package包/类
public Parser getParser()
{
return parser;
}
示例8: wrap
import org.w3c.css.sac.Parser; //导入依赖的package包/类
/**
* This converts a standard @link org.w3c.css.sac.Parser into
* an Extended Parser. If it is already an ExtendedParser
* it will simply cast it and return, otherwise it will wrap it
* and return the result.
* @param p Parser to wrap.
* @return p as an ExtendedParser.
*/
public static ExtendedParser wrap(Parser p) {
if (p instanceof ExtendedParser)
return (ExtendedParser)p;
return new ExtendedParserWrapper(p);
}
示例9: makeParser
import org.w3c.css.sac.Parser; //导入依赖的package包/类
/**
* Create a parser with given selectors factory and conditions factory.
*
* @return the parser
* @throws ClassNotFoundException
* the class not found exception
* @throws IllegalAccessException
* the illegal access exception
* @throws InstantiationException
* the instantiation exception
* @throws NullPointerException
* the null pointer exception
* @throws ClassCastException
* the class cast exception
*/
public Parser makeParser() throws ClassNotFoundException, IllegalAccessException, InstantiationException,
NullPointerException, ClassCastException {
String className = System.getProperty("org.w3c.css.sac.parser");
if (className == null) {
throw new NullPointerException("No value for sac.parser property");
} else {
return (Parser) Class.forName(className).newInstance();
}
}
示例10: makeParser
import org.w3c.css.sac.Parser; //导入依赖的package包/类
/**
* Return default instance of SAC Parser. If preferredParserName is filled,
* it return the instance of SAC Parser registered with this name, otherwise
* this method search teh SAC Parser class name to instanciate into System
* property with key org.w3c.css.sac.parser.
*/
public Parser makeParser() throws ClassNotFoundException,
IllegalAccessException, InstantiationException,
NullPointerException, ClassCastException;