Package com.google.caja.lexer

Examples of com.google.caja.lexer.InputSource


    }
    return fromBytes(
        readStream(connection.getInputStream()),
        connection.getContentType(),
        getCharSet(connection),
        new InputSource(uri));
  }
View Full Code Here


  private final FilePosition pos;
  private List<Token<HtmlTokenType>> tokens;

  private static InputSource makeInputSource(String name) {
    try {
      return new InputSource(new URI("message", null, "/" + name, null, null));
    } catch (URISyntaxException ex) {
      // Authority can't be bad since there isn't one, and the path is not
      // relative, so should not throw.
      throw new SomethingWidgyHappenedError(ex);
    }
View Full Code Here

              return a.source().getUri().compareTo(b.source().getUri());
            }
          });
      if (!positions.get(0).source().equals(
              positions.get(positions.size() - 1).source())) {
        InputSource last = null;
        int bestStart = -1;
        int runStart = 0;
        int bestRun = 0;
        int n = positions.size();
        for (int i = 0; i < n; ++i) {
          InputSource is = positions.get(i).source();
          if (!is.equals(last)) {
            if (i - runStart > bestRun) {
              bestStart = runStart;
              bestRun = i - runStart;
            }
            last = is;
View Full Code Here

    return new File(file.getParentFile(),
                    fileName.substring(0, lastDot) + extension);
  }

  private static WhiteList whitelist(URI uri, MessageQueue mq) {
    InputSource src = new InputSource(uri);
    try {
      return ConfigUtil.loadWhiteListFromJson(
          uri, ConfigUtil.RESOURCE_RESOLVER, mq);
    } catch (IOException ex) {
      mq.addMessage(MessageType.IO_ERROR, src);
View Full Code Here

  }

  private void match(String pattern, String source)
      throws Exception {
    QuasiNode qn = QuasiBuilder.parseQuasiNode(
        new InputSource(URI.create("built-in:///js-quasi-literals")),
        pattern);
    System.out.println(qn.render());
    m = null;
    findMatch(qn, quasi(fromString(source)));
    if (m != null) { System.out.println(m); }
View Full Code Here

      assertTrue(e instanceof IllegalStateException);
    }
  }

  public final void testContentCache() throws Exception {
    InputSource is = new InputSource(URI.create("test:///foo.js"));
    Map<InputSource, CharSequence> sourceMap = Maps.newHashMap();
    @SuppressWarnings("unused")
    ParseTreeNode node = new ParserContext(DevNullMessageQueue.singleton())
      .withSourceMap(sourceMap)
      .withInput(is)
View Full Code Here

        htmlFragment(fromString("<img src='blank.gif' width='20'/>")),
        new Block());
  }

  public final void testStyleRewriting() throws Exception {
    InputSource is = new InputSource(URI.create("http://example.org/"));
    assertSafeHtml(
        htmlFragment(fromString(
            "<div style=\"position: absolute; background: "
            + "url('bg-image')\">\n"
            + "Hello\n"
View Full Code Here

    Map<InputSource, String> originalSrcs = Maps.newHashMap();
    for (String originalSourceFile : originalSourceFiles) {
      URI resourceUri = TestUtil.getResource(getClass(), originalSourceFile);
      if (resourceUri == null) { throw new IOException(originalSourceFile); }
      InputSource is = new InputSource(resourceUri);
      originalSrcs.put(
          is, TestUtil.readResource(getClass(), originalSourceFile));
    }
    for (InputSource is : originalSrcs.keySet()) { mc.addInputSource(is); }
View Full Code Here

    int slc = Integer.parseInt(m.group(3));
    String g4 = m.group(4);
    int eln = g4 != null ? Integer.parseInt(g4) : sln;
    int elc = Integer.parseInt(m.group(5));

    InputSource src = null;
    for (InputSource candidate : originalSrcs.keySet()) {
      if (candidate.getUri().getPath().endsWith(basename)) {
        src = candidate;
      }
    }
View Full Code Here

        dumpedSeed = true;
        // Make sure it shows up in the junit test runner trace.
        System.err.println("junit.seed=" + SEED);
      }
    }
    this.is = new InputSource(URI.create("http://example.org/" + getName()));
    this.mc = new MessageContext();
    mc.addInputSource(is);
    this.mq = TestUtil.createTestMessageQueue(this.mc);
  }
View Full Code Here

TOP

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

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.