Package org.jsoup.nodes

Examples of org.jsoup.nodes.Attributes


  @Test
  public void disablesAmdScriptParsingWithConfigAttrOnScriptTag() {
    MockWebPage webPage = new MockWebPage();
    webPage.isDojoScript = true;
   
    Attributes attrs = new Attributes();
    attrs.put("data-dojo-config", "async: false");   
   
    Element dojoScript = new Element(Tag.valueOf("script"), "", attrs);
    webPage.parsePreDojoScript(dojoScript);
    assertEquals(ModuleFormat.NON_AMD, webPage.moduleFormat);
  }
View Full Code Here


  @Test
  public void enablesAmdScriptParsingWithConfigAttrOnScriptTag() {
    MockWebPage webPage = new MockWebPage();
    webPage.isDojoScript = true;
   
    Attributes attrs = new Attributes();
    attrs.put("data-dojo-config", "async: true");   
   
    Element dojoScript = new Element(Tag.valueOf("script"), "", attrs);
    webPage.parsePreDojoScript(dojoScript);
    assertEquals(ModuleFormat.AMD, webPage.moduleFormat);
  }
View Full Code Here

  @Test
  public void enablesAmdScriptParsingWithOldConfigAttrOnScriptTag() {
    MockWebPage webPage = new MockWebPage();
    webPage.isDojoScript = true;
   
    Attributes attrs = new Attributes();
    attrs.put("djconfig", "async: true");   
   
    Element dojoScript = new Element(Tag.valueOf("script"), "", attrs);
    webPage.parsePreDojoScript(dojoScript);
    assertEquals(ModuleFormat.AMD, webPage.moduleFormat);
  }
View Full Code Here

  @Test
  public void enablesAmdScriptParsingWithLocalConfigInScriptTag() {
    MockWebPage webPage = new MockWebPage();
    webPage.scriptContents = "var dojoConfig = { async : true }";
   
    Attributes attrs = new Attributes();   
    Element dojoScript = new Element(Tag.valueOf("script"), "", attrs);
   
    webPage.parsePreDojoScript(dojoScript);
    assertEquals(ModuleFormat.AMD, webPage.moduleFormat);
   
View Full Code Here

  @Test
  public void enablesAmdScriptParsingWithGlobalConfigInScriptTag() {
    MockWebPage webPage = new MockWebPage();
    webPage.scriptContents = "dojoConfig = { async : true }";
   
    Attributes attrs = new Attributes();   
    Element dojoScript = new Element(Tag.valueOf("script"), "", attrs);
   
    webPage.parsePreDojoScript(dojoScript);
    assertEquals(ModuleFormat.AMD, webPage.moduleFormat);
   
View Full Code Here

    RemoteWebPage webPage = new RemoteWebPage(document, new URL("http://localhost/"), new MockHttpClient());   
   
    // Create inline script tag...
    String scriptContents = getResourceAsString("sample_module_libs/non_amd/simple_deps/app.js");
    Attributes attrs = new Attributes();
    Element inlineScript = new Element(Tag.valueOf("script"), "", attrs);       
    document.appendChild(inlineScript);   
    inlineScript.html(scriptContents);
   
    String comparison = StringEscapeUtils.unescapeHtml(webPage.retrieveScriptContents(inlineScript));   
View Full Code Here

    RemoteWebPage webPage = new RemoteWebPage(document, new URL("http://localhost/"), mockHttpClient);   
   
    // Create inline script tag...
    String scriptContents = getResourceAsString("sample_module_libs/non_amd/simple_deps/app.js");
    Attributes attrs = new Attributes();
    attrs.put("src", "app.js");   
    Element inlineScript = new Element(Tag.valueOf("script"), "http://localhost/", attrs);           
   
    // Set pre-canned response
    mockHttpClient.hostPrefix = "http://localhost/";
    mockHttpClient.appDir = "sample_module_libs/non_amd/simple_deps/";    
View Full Code Here

      tq.addFirst("<");
      parseTextNode();
      return;
    }

    Attributes attributes = new Attributes();
    while (!tq.matchesAny("<", "/>", ">") && !tq.isEmpty()) {
      Attribute attribute = parseAttribute();
      if (attribute != null)
        attributes.put(attribute);
    }

    Tag tag = Tag.valueOf(tagName);
    // TODO - option to create elements without indent
    Element child = new Element(tag, baseUri, attributes);
View Full Code Here

        }
        return false;
    }

    Attributes getEnforcedAttributes(String tagName) {
        Attributes attrs = new Attributes();
        TagName tag = TagName.valueOf(tagName);
        if (enforcedAttributes.containsKey(tag)) {
            Map<AttributeKey, AttributeValue> keyVals = enforcedAttributes.get(tag);
            for (Map.Entry<AttributeKey, AttributeValue> entry : keyVals.entrySet()) {
                attrs.put(entry.getKey().toString(), entry.getValue().toString());
            }
        }
        return attrs;
    }
View Full Code Here

    public final static void applyMessages(Element target) {
        String selector = SelectorUtil.tag(ExtNodeConstants.MSG_NODE_TAG);
        List<Element> msgElems = target.select(selector);
        for (Element msgElem : msgElems) {
            Attributes attributes = msgElem.attributes();
            if (!attributes.hasKey(ExtNodeConstants.MSG_NODE_ATTR_KEY)) {
                InvalidMessageException ex = new InvalidMessageException(ExtNodeConstants.MSG_NODE_TAG + " tag must have key attribute.");
                logger.error("", ex);
                continue;
            }
            String key = attributes.get(ExtNodeConstants.MSG_NODE_ATTR_KEY);
            List<String> externalizeParamKeys = getExternalizeParamKeys(attributes);

            // TODO cache localed helper instance
            ParamMapResourceBundleHelper helper = null;
            if (attributes.hasKey(ExtNodeConstants.MSG_NODE_ATTR_LOCALE)) {
                helper = new ParamMapResourceBundleHelper(LocalizeUtil.getLocale(attributes.get(ExtNodeConstants.MSG_NODE_ATTR_LOCALE)));
            } else {
                helper = new ParamMapResourceBundleHelper();
            }

            Map<String, Object> paramMap = getMessageParams(attributes, helper, key, externalizeParamKeys);
View Full Code Here

TOP

Related Classes of org.jsoup.nodes.Attributes

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.