org.w3c.css.sac.Parser Java Examples
The following examples show how to use
org.w3c.css.sac.Parser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SACParserFactoryImpl.java From tm4e with Eclipse Public License 1.0 | 5 votes |
@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."); }
Example #2
Source File: CSSParser.java From tm4e with Eclipse Public License 1.0 | 5 votes |
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); }
Example #3
Source File: SACParserFactory.java From tm4e with Eclipse Public License 1.0 | 5 votes |
/** * 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) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } return super.makeParser(); }
Example #4
Source File: CSSEngine.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * 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; }
Example #5
Source File: StyleSheetParserUtil.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Parses a style value. If the style value is a compound key, the corresonding style entries will be added to the * style rule. * * @param namespaces an optional map of known namespaces (prefix -> uri) * @param name the stylekey-name to which the value should be assigned. * @param value the value text * @param baseURL an optional base url * @param baseRule an optional base-rule to which the result gets added. * @return the CSS-Style-Rule that contains all values for the given text. */ public CSSStyleRule parseStyles( final Map namespaces, final String name, final String value, final ResourceKey baseURL, final CSSDeclarationRule baseRule, final ResourceManager resourceManager, final StyleKeyRegistry styleKeyRegistry ) { if ( name == null ) { throw new NullPointerException( "Name is null" ); } if ( value == null ) { throw new NullPointerException( "Value is null" ); } try { final Parser parser = getParser(); synchronized( parser ) { final StyleSheetHandler handler = new StyleSheetHandler(); handler.init( styleKeyRegistry, resourceManager, baseURL, -1, null ); setupNamespaces( namespaces, handler ); final InputSource source = new InputSource(); source.setCharacterStream( new StringReader( value ) ); handler.initParseContext( source ); handler.setStyleRule( baseRule ); parser.setDocumentHandler( handler ); final LexicalUnit lu = parser.parsePropertyValue( source ); handler.property( name, lu, false ); final CSSStyleRule rule = (CSSStyleRule) handler.getStyleRule(); CSSParserContext.getContext().destroy(); return rule; } } catch ( Exception e ) { e.printStackTrace(); return null; } }
Example #6
Source File: StyleSheetParserUtil.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns the initialized parser. * * @return the parser's local instance. * @throws CSSParserInstantiationException if the parser cannot be instantiated. */ private synchronized Parser getParser() throws CSSParserInstantiationException { if ( parser == null ) { parser = CSSParserFactory.getInstance().createCSSParser(); } return parser; }
Example #7
Source File: CSSEngine.java From birt with Eclipse Public License 1.0 | 4 votes |
public Parser getParser() { return parser; }
Example #8
Source File: StyleSheetParserUtil.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
/** * Parses a single style value for the given key. Returns <code>null</code>, if the key denotes a compound definition, * which has no internal representation. * * @param namespaces an optional map of known namespaces (prefix -> uri) * @param key the stylekey to which the value should be assigned. * @param value the value text * @param baseURL an optional base url * @return the parsed value or null, if the value was not valid. */ public CSSValue parseStyleValue( final Map namespaces, final StyleKey key, final String value, final ResourceKey baseURL, final ResourceManager resourceManager, final StyleKeyRegistry styleKeyRegistry ) { if ( key == null ) { throw new NullPointerException(); } if ( value == null ) { throw new NullPointerException(); } try { final Parser parser = getParser(); synchronized( parser ) { final StyleSheetHandler handler = new StyleSheetHandler(); setupNamespaces( namespaces, handler ); handler.init( styleKeyRegistry, resourceManager, baseURL, -1, null ); final InputSource source = new InputSource(); source.setCharacterStream( new StringReader( value ) ); handler.initParseContext( source ); handler.setStyleRule( new CSSStyleRule( new StyleSheet(), null ) ); parser.setDocumentHandler( handler ); final LexicalUnit lu = parser.parsePropertyValue( source ); handler.property( key.getName(), lu, false ); final CSSStyleRule rule = (CSSStyleRule) handler.getStyleRule(); CSSParserContext.getContext().destroy(); return rule.getPropertyCSSValue( key ); } } catch ( Exception e ) { e.printStackTrace(); return null; } }
Example #9
Source File: StyleSheetParserUtil.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
/** * Parses a style rule. * * @param namespaces an optional map of known namespaces (prefix -> uri) * @param styleText the css text that should be parsed * @param baseURL an optional base url * @param baseRule an optional base-rule to which the result gets added. * @return the CSS-Style-Rule that contains all values for the given text. */ public CSSDeclarationRule parseStyleRule( final Map namespaces, final String styleText, final ResourceKey baseURL, final CSSDeclarationRule baseRule, final ResourceManager resourceManager, final StyleKeyRegistry styleKeyRegistry ) { if ( styleText == null ) { throw new NullPointerException( "Name is null" ); } if ( resourceManager == null ) { throw new NullPointerException( "ResourceManager must not be null" ); } if ( styleKeyRegistry == null ) { throw new NullPointerException( "Style-Key Registry must not be null" ); } try { final Parser parser = getParser(); synchronized( parser ) { final StyleSheetHandler handler = new StyleSheetHandler(); setupNamespaces( namespaces, handler ); handler.init( styleKeyRegistry, resourceManager, baseURL, -1, null ); final InputSource source = new InputSource(); source.setCharacterStream( new StringReader( styleText ) ); handler.initParseContext( source ); if ( baseRule != null ) { handler.setStyleRule( baseRule ); } else { handler.setStyleRule( new CSSStyleRule( new StyleSheet(), null ) ); } parser.setDocumentHandler( handler ); parser.parseStyleDeclaration( source ); final CSSDeclarationRule rule = handler.getStyleRule(); CSSParserContext.getContext().destroy(); return rule; } } catch ( Exception e ) { e.printStackTrace(); return null; } }
Example #10
Source File: SACParserFactory.java From tm4e with Eclipse Public License 1.0 | 2 votes |
/** * Return instance of SAC Parser registered into the factory with name * <code>name</code>. * * @param name * @return * @throws ClassNotFoundException * @throws IllegalAccessException * @throws InstantiationException * @throws NullPointerException * @throws ClassCastException */ @Override public abstract Parser makeParser(String name) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NullPointerException, ClassCastException;
Example #11
Source File: ISACParserFactory.java From tm4e with Eclipse Public License 1.0 | 2 votes |
/** * 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;
Example #12
Source File: ISACParserFactory.java From tm4e with Eclipse Public License 1.0 | 2 votes |
/** * Return instance of SAC Parser registered into the factory with name * <code>name</code>. * * @param name * @return * @throws ClassNotFoundException * @throws IllegalAccessException * @throws InstantiationException * @throws NullPointerException * @throws ClassCastException */ public abstract Parser makeParser(String name) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NullPointerException, ClassCastException;