Package com.google.caja.lexer

Examples of com.google.caja.lexer.CharProducer


  }

  private CssTree.StyleSheet parseImpl(String css, Uri source)
      throws ParseException {
    InputSource inputSource = new InputSource(source.toJavaUri());
    CharProducer producer = CharProducer.Factory.create(new StringReader(css),
        inputSource);
    TokenStream<CssTokenType> lexer = new CssLexer(producer);
    TokenQueue<CssTokenType> queue = new TokenQueue<CssTokenType>(lexer, inputSource,
        new Criterion<Token<CssTokenType>>() {
          public boolean accept(Token<CssTokenType> t) {
View Full Code Here


      UriFetcher fetcher = makeFetcher(uri, container);
      ExternalReference extRef = new ExternalReference(javaUri,
          FilePosition.instance(is, /*lineNo*/ 1, /*charInFile*/ 1, /*charInLine*/ 1));
      // If the fetch fails, a UriFetchException is thrown and serialized as part of the
      // message queue.
      CharProducer cp = fetcher.fetch(extRef, mime).getTextualContent();
      ParseTreeNode ptn = parse(is, cp, mime, mq);
      return rewrite(uri, container, ptn, es53, debug);
    } catch (UnsupportedEncodingException e) {
      LOG.severe("Unexpected inability to recognize mime type: " + mime);
      mq.addMessage(ServiceMessageType.UNEXPECTED_INPUT_MIME_TYPE,
View Full Code Here

  private CajoledResult cajole(Uri uri, String mime, String content) throws ParseException {
    CajaContentRewriter rw = new CajaContentRewriter(null, null, null, proxyUriManager);
    InputSource is = new InputSource(uri.toJavaUri());
    MessageQueue mq = new SimpleMessageQueue();
    CharProducer cp = CharProducer.Factory.create(new StringReader(content), is);
    return rw.rewrite(uri, CONTAINER, CajaContentRewriter.parse(is, cp, mime, mq), false, false);
  }
View Full Code Here

  private CajoledResult cajole(Uri uri, String mime, String content) throws ParseException {
    CajaContentRewriter rw = new CajaContentRewriter(null, null, null, proxyUriManager);
    InputSource is = new InputSource(uri.toJavaUri());
    MessageQueue mq = new SimpleMessageQueue();
    CharProducer cp = CharProducer.Factory.create(new StringReader(content), is);
    return rw.rewrite(uri, CONTAINER, CajaContentRewriter.parse(is, cp, mime, mq), false, false);
  }
View Full Code Here

      UriFetcher fetcher = makeFetcher(uri, container);
      ExternalReference extRef = new ExternalReference(javaUri,
          FilePosition.instance(is, /*lineNo*/ 1, /*charInFile*/ 1, /*charInLine*/ 1));
      // If the fetch fails, a UriFetchException is thrown and serialized as part of the
      // message queue.
      CharProducer cp = fetcher.fetch(extRef, mime).getTextualContent();
      ParseTreeNode ptn = parse(is, cp, mime, mq);
      return rewrite(uri, container, ptn, es53, debug);
    } catch (UnsupportedEncodingException e) {
      LOG.severe("Unexpected inability to recognize mime type: " + mime);
      mq.addMessage(ServiceMessageType.UNEXPECTED_INPUT_MIME_TYPE,
View Full Code Here

    return parsedCss;
  }

  List<Object> parseImpl(String content) throws GadgetException {
    List<Object> parsedCss = Lists.newArrayList();
    CharProducer producer = CharProducer.Factory.create(new StringReader(content),
        new InputSource(DUMMY_SOURCE));
    CssLexer lexer = new CssLexer(producer);
    try {
      StringBuilder builder = new StringBuilder();
      boolean inImport = false;
View Full Code Here

    compiler.setMessageContext(mc);

    // Parse the javascript
    try {
      StringReader strReader = new StringReader(resp.getContent());
      CharProducer cp = CharProducer.Factory.create(strReader, is);
      JsTokenQueue tq = new JsTokenQueue(new JsLexer(cp), is);
      ParseTreeNode input = new Parser(tq, mq).parse();
      tq.expectEmpty();

      compiler.addInput(AncestorChain.instance(input).node, contextUri.toJavaUri());
View Full Code Here

  }

  private CssTree.StyleSheet parseImpl(String css, Uri source)
      throws ParseException {
    InputSource inputSource = new InputSource(source.toJavaUri());
    CharProducer producer = CharProducer.Factory.create(new StringReader(css),
        inputSource);
    TokenStream<CssTokenType> lexer = new CssLexer(producer);
    TokenQueue<CssTokenType> queue = new TokenQueue<CssTokenType>(lexer, inputSource,
        new Criterion<Token<CssTokenType>>() {
          public boolean accept(Token<CssTokenType> t) {
View Full Code Here

  private CajoledResult cajole(Uri uri, String mime, String content) throws ParseException {
    CajaContentRewriter rw = new CajaContentRewriter(null, null, null, proxyUriManager);
    InputSource is = new InputSource(uri.toJavaUri());
    MessageQueue mq = new SimpleMessageQueue();
    CharProducer cp = CharProducer.Factory.create(new StringReader(content), is);
    return rw.rewrite(uri, CONTAINER, CajaContentRewriter.parse(is, cp, mime, mq), false, false);
  }
View Full Code Here

        }
      };

      MessageQueue mq = new SimpleMessageQueue();
      DefaultGadgetRewriter rw = new DefaultGadgetRewriter(mq);
      CharProducer input = CharProducer.Factory.create(
          new StringReader(content.getContent()),
          FilePosition.instance(new InputSource(retrievedUri), 2, 1, 1));
      StringBuilder output = new StringBuilder();

      try {
View Full Code Here

TOP

Related Classes of com.google.caja.lexer.CharProducer

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.