Package org.w3c.css.sac

Examples of org.w3c.css.sac.Parser


                         final ResourceKey context)
      throws ResourceCreationException, ResourceLoadingException
  {
    try
    {
      final Parser parser = CSSParserFactory.getInstance().createCSSParser();
      final ResourceKey key;
      final long version;
      if (context == null)
      {
        key = data.getKey();
        version = data.getVersion(manager);
      }
      else
      {
        key = context;
        version = -1;
      }

      final DocumentContext documentContext;

      final StyleSheetHandler handler = new StyleSheetHandler();
      handler.init(StyleKeyRegistry.getRegistry(), manager, key, version, null);
      parser.setDocumentHandler(handler);

      final InputSource inputSource = new InputSource();
      inputSource.setByteStream(data.getResourceAsStream(manager));

      handler.initParseContext(inputSource);
      handler.setStyleRule(new CSSStyleRule(null, null));
      parser.parseStyleDeclaration(inputSource);

      final DependencyCollector dependencies = handler.getDependencies();
      if (context != null)
      {
        dependencies.add(data.getKey(), data.getVersion(manager));
View Full Code Here


  {
    final Configuration config = LibCssBoot.getInstance().getGlobalConfig();
    final String parserClass = config.getConfigProperty("org.pentaho.reporting.libraries.css.Parser");
    if (parserClass != null)
    {
      Parser p = (Parser) ObjectUtilities.loadAndInstantiate
          (parserClass, CSSParserFactory.class, Parser.class);
      if (p != null)
      {
        p.setConditionFactory(new FixNamespaceConditionFactory(new CSSConditionFactory()));
        p.setSelectorFactory(new FixNamespaceSelectorFactory(new CSSSelectorFactory()));
        return p;
      }
    }
    try
    {
      Parser p = new ParserFactory().makeParser();
      if (p == null)
      {
        return null;
      }
      p.setConditionFactory(new FixNamespaceConditionFactory(new CSSConditionFactory()));
      p.setSelectorFactory(new FixNamespaceSelectorFactory(new CSSSelectorFactory()));
      return p;
    }
    catch (Exception e)
    {
      throw new CSSParserInstantiationException(e.getMessage(), e);
View Full Code Here

                         final ResourceKey context)
      throws ResourceCreationException, ResourceLoadingException
  {
    try
    {
      final Parser parser = CSSParserFactory.getInstance().createCSSParser();

      final ResourceKey key;
      final long version;
      if (context == null)
      {
        key = data.getKey();
        version = data.getVersion(manager);
      }
      else
      {
        key = context;
        version = -1;
      }


      final StyleSheetHandler handler = new StyleSheetHandler();
      handler.init(StyleKeyRegistry.getRegistry(), manager, key, version, null);
      parser.setDocumentHandler(handler);
      parser.setErrorHandler(handler);

      final InputStream stream = data.getResourceAsStream(manager);
      final InputSource inputSource = new InputSource();
      inputSource.setByteStream(stream);
      parser.parseStyleSheet(inputSource);

      final DependencyCollector dependencies = handler.getDependencies();
      if (context != null)
      {
        dependencies.add(data.getKey(), data.getVersion(manager));
View Full Code Here

      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();
View Full Code Here

      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;
      }
    }
View Full Code Here

      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;
View Full Code Here

        if (customValueManagers == null && customShorthandManagers == null) {
            return super.createCSSEngine(doc, ctx);
        }

        String pn = XMLResourceDescriptor.getCSSParserClassName();
        Parser p;
        try {
            p = (Parser)Class.forName(pn).newInstance();
        } catch (ClassNotFoundException e) {
            throw new DOMException(DOMException.INVALID_ACCESS_ERR,
                                   formatMessage("css.parser.class",
View Full Code Here

    /**
     * Creates new CSSEngine and attach it to the document.
     */
    public CSSEngine createCSSEngine(SVGOMDocument doc, CSSContext ctx) {
        String pn = XMLResourceDescriptor.getCSSParserClassName();
        Parser p;
        try {
            p = (Parser)Class.forName(pn).newInstance();
        } catch (ClassNotFoundException e) {
            throw new DOMException(DOMException.INVALID_ACCESS_ERR,
                                   formatMessage("css.parser.class",
View Full Code Here

    /**
     * Creates new CSSEngine and attach it to the document.
     */
    public CSSEngine createCSSEngine(SVGOMDocument doc, CSSContext ctx) {
        String pn = XMLResourceDescriptor.getCSSParserClassName();
        Parser p;
        try {
            p = (Parser)Class.forName(pn).newInstance();
        } catch (ClassNotFoundException e) {
            throw new DOMException(DOMException.INVALID_ACCESS_ERR,
                                   formatMessage("css.parser.class",
View Full Code Here

        if (customValueManagers == null && customShorthandManagers == null) {
            return super.createCSSEngine(doc, ctx);
        }

        String pn = XMLResourceDescriptor.getCSSParserClassName();
        Parser p;
        try {
            p = (Parser)Class.forName(pn).newInstance();
        } catch (ClassNotFoundException e) {
            throw new DOMException(DOMException.INVALID_ACCESS_ERR,
                                   formatMessage("css.parser.class",
View Full Code Here

TOP

Related Classes of org.w3c.css.sac.Parser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.