Package org.w3c.css.sac

Examples of org.w3c.css.sac.Parser


      throw new NullPointerException();
    }

    try
    {
      final Parser parser = getParser();
      synchronized(parser)
      {
        final StyleSheetHandler handler = new StyleSheetHandler();
        setupNamespaces(namespaces, handler);

        handler.init
            (resourceManager, baseURL, -1, registry, null);

        final InputSource source = new InputSource();
        source.setCharacterStream(new StringReader(value));

        handler.initParseContext(source);
        handler.setStyleRule(new CSSStyleRule(null, 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();
    }
    try
    {
      final Parser parser = getParser();
      synchronized(parser)
      {
        final Object cached = lexicalValueCache.get(value);
        if (cached != null)
        {
          return (LexicalUnit) cached;
        }
        final StyleSheetHandler handler = new StyleSheetHandler();
        handler.init (null, null, -1, registry, null);
        final InputSource source = new InputSource();
        source.setCharacterStream(new StringReader(value));
        handler.initParseContext(source);
        parser.setDocumentHandler(handler);
        final LexicalUnit result = parser.parsePropertyValue(source);
        lexicalValueCache.put (value, result);
        return result;
      }
    }
    catch (Exception e)
View Full Code Here

      throw new NullPointerException("Name is null");
    }

    try
    {
      final Parser parser = getParser();
      synchronized(parser)
      {
        final StyleSheetHandler handler = new StyleSheetHandler();
        setupNamespaces(namespaces, handler);
        handler.init (resourceManager, baseURL, -1, registry, null);

        final InputSource source = new InputSource();
        source.setCharacterStream(new StringReader(styleText));

        handler.initParseContext(source);
        handler.setStyleRule(baseRule);
        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
            (resourceManager, baseURL, -1, StyleKeyRegistry.getRegistry(), 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

                          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 (manager, key, version, StyleKeyRegistry.getRegistry(), 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 = LibLayoutBoot.getInstance().getGlobalConfig();
    final String parserClass =
            config.getConfigProperty("org.jfree.layouting.css.Parser");
    if (parserClass != null)
    {
      final 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
    {
      final 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();
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
              (manager, key, version, StyleKeyRegistry.getRegistry(), 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

  {

    final ResourceManager resourceManager= new ResourceManager();
    resourceManager.registerDefaults();

    final Parser parser = CSSParserFactory.getInstance().createCSSParser();
    final StyleSheetHandler handler = new StyleSheetHandler();
    handler.init (resourceManager, null, 0, StyleKeyRegistry.getRegistry(), null);
    parser.setDocumentHandler(handler);
    final String selector = ".bordered";
    final SelectorList sl =
            parser.parseSelectors(new StringInputSource (selector, new URL("http://localhost")));
    System.exit(0);
  }
View Full Code Here

      throw new NullPointerException();
    }

    try
    {
      final Parser parser = getParser();
      synchronized(parser)
      {
        final StyleSheetHandler handler = new StyleSheetHandler();
        handler.init
            (resourceManager, baseURL, -1, StyleKeyRegistry.getRegistry(), null);

        setupNamespaces(namespaces, handler);

        final InputSource source = new InputSource();
        source.setCharacterStream(new StringReader(selector));

        handler.initParseContext(source);
        handler.setStyleRule(new CSSStyleRule(null, null));
        parser.setDocumentHandler(handler);

        final SelectorList selectorList = parser.parseSelectors(source);
        CSSParserContext.getContext().destroy();
        return selectorList;
      }
    }
    catch (Exception e)
View Full Code Here

      throw new NullPointerException();
    }

    try
    {
      final Parser parser = getParser();
      synchronized(parser)
      {
        final StyleSheetHandler handler = new StyleSheetHandler();
        setupNamespaces(namespaces, handler);

        handler.init
            (resourceManager, baseURL, -1, registry, null);

        final InputSource source = new InputSource();
        source.setCharacterStream(new StringReader(value));

        handler.initParseContext(source);
        handler.setStyleRule(new CSSStyleRule(null, 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

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.