gpt4 book ai didi

com.github.bordertech.wcomponents.WebUtilities类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 17:25:05 26 4
gpt4 key购买 nike

本文整理了Java中com.github.bordertech.wcomponents.WebUtilities类的一些代码示例,展示了WebUtilities类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebUtilities类的具体详情如下:
包路径:com.github.bordertech.wcomponents.WebUtilities
类名称:WebUtilities

WebUtilities介绍

[英]WComponent and HTML related utility methods.
[中]WComponent和HTML相关的实用程序方法。

代码示例

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
   * @param uic the current user context
   * @return the xml declaration with the theme processing instruction
   */
  public static String getXMLDeclarationWithThemeXslt(final UIContext uic) {
    String theme = WebUtilities.encode(ThemeUtil.getThemeXslt(uic));
    String dec = XML_DECLARATION + "\n<?xml-stylesheet type=\"text/xsl\" href=\"" + theme + "\"?>";
    return dec;
  }
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
 * Indicates whether this is a top-level menu (ie. attached to a menu bar).
 *
 * @return {@code true} if this is a top-level menu.
 */
public boolean isTopLevelMenu() {
  MenuContainer container = WebUtilities.getAncestorOfClass(MenuContainer.class, this);
  if (container instanceof WMenuItemGroup) {
    container = WebUtilities.getAncestorOfClass(MenuContainer.class, container);
  }
  return container instanceof WMenu;
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
 * This is a slightly different version of appendGetParam that doesn't encode the ampersand seperator. It is
 * intended to be used in urls that are generated for javascript functions.
 *
 * @param key the key to append
 * @param value the value to append
 * @param vars the existing query string
 * @param existingVars true if there are already existing query string key/value pairs
 */
public static void appendGetParamForJavascript(final String key, final String value,
    final StringBuffer vars, final boolean existingVars) {
  vars.append(existingVars ? '&' : '?');
  vars.append(key).append('=').append(WebUtilities.escapeForUrl(value));
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
 * Get this component's parent naming context.
 *
 * @param component the component to process
 * @return true the parent naming context or null
 */
public static NamingContextable getParentNamingContext(final WComponent component) {
  if (component == null) {
    return null;
  }
  WComponent child = component;
  NamingContextable parent = null;
  while (true) {
    NamingContextable naming = WebUtilities.getAncestorOfClass(NamingContextable.class,
        child);
    if (naming == null) {
      break;
    }
    if (WebUtilities.isActiveNamingContext(naming)) {
      parent = naming;
      break;
    }
    child = naming;
  }
  return parent;
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
 * Encode URL for XML.
 *
 * @param urlStr the URL to escape
 * @return the URL percent encoded
 */
public static String encodeUrl(final String urlStr) {
  if (Util.empty(urlStr)) {
    return urlStr;
  }
  // Percent Encode
  String percentEncode = percentEncodeUrl(urlStr);
  // XML Enocde
  return encode(percentEncode);
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
   * Unescape HTML entities to safe XML.
   *
   * <p>
   * Example</p>
   * <pre>
   * {@code StringEscapeHTMLToXMLUtil.unescapeToXML("&bull;&Dagger}"); // returns "•‡"}
   * {@code StringEscapeHTMLToXMLUtil.unescapeToXML("&lt;p&gt;"); // returns "&lt;p&gt;" not "<p>"}
   * </pre>
   *
   * @param input The String to unescape.
   * @return the input with all HTML4 character entities unescaped except those which are also XML entities.
   */
  public static String unescapeToXML(final String input) {
    if (Util.empty(input)) {
      return input;
    }
    // Check if input has encoded brackets
    String encoded = WebUtilities.doubleEncodeBrackets(input);
    String unescaped = UNESCAPE_HTML_TO_XML.translate(encoded);
    String decoded = WebUtilities.doubleDecodeBrackets(unescaped);
    return decoded;
  }
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

String random = WebUtilities.generateRandom();
  parameters.put(Environment.UNIQUE_RANDOM_PARAM, random);
} else {
return WebUtilities.getPath(url, parameters, true);

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-examples

@Override
  public void execute(final ActionEvent event) {
    WebUtilities.updateBeanValue(layout);
  }
});

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testDecode() {
  Assert.assertEquals("Incorrectly decoded null string", null, WebUtilities.decode(null));
  Assert.assertEquals("Incorrectly decoded empty string", "", WebUtilities.decode(""));
  Assert.assertEquals("Incorrectly decoded 1 char string", "x", WebUtilities.decode("x"));
  Assert.assertEquals("Incorrectly decoded 1 special char string", "&", WebUtilities.decode(
      "&amp;"));
  Assert.assertEquals("Incorrectly decoded open bracket", "{", WebUtilities.decode("&#123;"));
  Assert.assertEquals("Incorrectly decoded close bracket", "}", WebUtilities.decode("&#125;"));
  String in = "Hello world greater&gt; less&lt; amper&amp; quote&quot;";
  String expected = "Hello world greater> less< amper& quote\"";
  Assert.assertEquals("Incorrectly decoded value", expected, WebUtilities.decode(in));
  // Finally, check a encode/decode pair
  String encoded = WebUtilities.encode(expected);
  Assert.assertEquals("Incorrectly encoded/decoded value", expected, WebUtilities.decode(
      encoded));
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

resp.setContentType(WebUtilities.getContentType(fileName));
resp.setHeader("Cache-Control", CacheType.THEME_CACHE.getSettings());
resp.setHeader("ETag", "\"" + WebUtilities.getProjectVersion() + "\"");

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-examples

/**
   * Override preparePaint in order to set up the resources on first access by a user.
   *
   * @param request the request being responded to.
   */
  @Override
  protected void preparePaintComponent(final Request request) {
    super.preparePaintComponent(request);

    if (!isInitialised()) {
      // Check project versions for Wcomponents-examples and WComponents match
      String egVersion = Config.getInstance().getString("wcomponents-examples.version");
      String wcVersion = WebUtilities.getProjectVersion();

      if (egVersion != null && !egVersion.equals(wcVersion)) {
        String msg = "WComponents-Examples version (" + egVersion + ") does not match WComponents version ("
            + wcVersion + ").";

        LOG.error(msg);

        messages.addMessage(new Message(Message.ERROR_MESSAGE, msg));
      }
      setInitialised(true);
    }

  }
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testDoubleEncodeBracketsWithMultipleMatches() {
  String in = "&#123;&#125;<> &#123;&#125;&#125;";
  String out = "&amp;#123;&amp;#125;<> &amp;#123;&amp;#125;&amp;#125;";
  Assert.assertEquals("Double encode brackets not correct", out, WebUtilities.doubleEncodeBrackets(in));
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testEncodeBrackets() {
  String in = "{}<{}>";
  String out = "&#123;&#125;<&#123;&#125;>";
  Assert.assertEquals("Encode brackets not correct", out, WebUtilities.encodeBrackets(in));
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testDoubleDecodeBrackets() {
  String in = "&amp;#123;&amp;#125;<>";
  String out = "&#123;&#125;<>";
  Assert.assertEquals("Double decode brackets not correct", out, WebUtilities.doubleDecodeBrackets(in));
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testGenerateRandom() {
  String random1 = WebUtilities.generateRandom();
  String random2 = WebUtilities.generateRandom();
  Assert.assertNotSame("Generated strings should be different", random1, random2);
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
 * Returns the closest WApplication instance (ancestor component) from the given base component.
 *
 * @param base the component from which we start scanning up the tree for a WApplication instance
 * @return the closest WApplication instance from the given base component
 */
public static WApplication instance(final WComponent base) {
  WApplication appl = WebUtilities.getClosestOfClass(WApplication.class, base);
  return appl;
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

String random = WebUtilities.generateRandom();
  parameters.put(Environment.UNIQUE_RANDOM_PARAM, random);
} else {
  urls[i] = WebUtilities.getPath(url, parameters, true);

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
 * Updates the bean value with the current value of the component and all its bean-bound children. By default this
 * method will only process visible components.
 *
 * @param component the component whose contents need to be copied to the bean.
 */
public static void updateBeanValue(final WComponent component) {
  updateBeanValue(component, true);
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

xml = WebUtilities.doubleEncodeBrackets(xml);
tempResp = WebUtilities.doubleDecodeBrackets(tempResp);

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testGetProjectVersion() {
  String testVersion = "TEST VERSION";
  Config.getInstance().setProperty(ConfigurationProperties.PROJECT_VERSION, testVersion);
  Assert.assertEquals("Wrong project version returned", testVersion, WebUtilities.
      getProjectVersion());
  try {
    Config.getInstance().clearProperty(ConfigurationProperties.PROJECT_VERSION);
    WebUtilities.getProjectVersion();
    Assert.fail("An exception should have been thrown for a null project version");
  } catch (SystemException e) {
    Assert.assertNotNull("No error message included for null project version", e.
        getMessage());
  }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com