当前位置: 首页>>代码示例>>Java>>正文


Java EscapeUtils类代码示例

本文整理汇总了Java中org.waveprotocol.wave.client.common.safehtml.EscapeUtils的典型用法代码示例。如果您正苦于以下问题:Java EscapeUtils类的具体用法?Java EscapeUtils怎么用?Java EscapeUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EscapeUtils类属于org.waveprotocol.wave.client.common.safehtml包,在下文中一共展示了EscapeUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scrub

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
/**
 * Scrub a url if scrubbing is turned on
 *
 * Does not scrub urls with leading hashes
 *
 * @param url
 * @return The scrubbed version of the url, if it's not already scrubbed
 */
public static String scrub(String url) {
  if (enableScrubbing) {
    if (url.startsWith("#") || url.startsWith(REFERRER_SCRUBBING_URL)) {
      // NOTE(user): The caller should be responsible for url encoding if
      // neccessary. There is no XSS risk here as it is a fragment.
      return url;
    } else {
      String x = REFERRER_SCRUBBING_URL + URL.encodeComponent(url);
      return x;
    }
  } else {
    // If we are not scrubbing the url, then we still need to sanitize it,
    // to protect against e.g. javascript.
    String sanitizedUri = EscapeUtils.sanitizeUri(url);
    return sanitizedUri;
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:26,代码来源:Scrub.java

示例2: outputHtml

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
@Override
public void outputHtml(SafeHtmlBuilder output) {
  String className = css.participant() + " ";
  switch(state) {
    case NORMAL:  className += css.normal();  break;
    case ADDED:   className += css.added();   break;
    case REMOVED: className += css.removed(); break;
  }    
  
  String name = extractName(participantId);
  String title = composeTitle(name, hint);
  OutputHelper.image(output, id, className,
      EscapeUtils.fromString(avatarUrl),
      EscapeUtils.fromString(title),
      TypeCodes.kind(Type.PARTICIPANT),
      " " + PARTICIPANT_ID_ATTRIBUTE + "='" + participantId + "'");
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:18,代码来源:ParticipantAvatarViewBuilder.java

示例3: handleParticipantClicked

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
/**
 * Shows a participation profileUi for the clicked participant.
 */
private void handleParticipantClicked(Element context) {
  ParticipantView participantView = views.asParticipant(context);
  Pair<Conversation, ParticipantId> participation = models.getParticipant(participantView);
  Profile profile = profiles.getProfile(participation.second);

  // Summon a popup view from a participant, and attach profile-popup logic to
  // it.
  ProfilePopupView profileView = participantView.showParticipation();
  final Conversation conversation = participation.getFirst();
  final ParticipantId participantId = participation.getSecond();
  boolean isRemoved = ParticipantState.REMOVED.equals(participantView.getState());
  SafeHtml buttonText = EscapeUtils.fromSafeConstant(isRemoved ? messages.close()
      : messages.remove());
  Command buttonCommand = isRemoved ? null : new Command() {
    
    @Override
    public void execute() {
      conversation.removeParticipant(participantId);
      markAsRead();
    }
  };
  ProfilePopupPresenter profileUi = ProfilePopupPresenter.create(profile, profileView, profiles,
      (ObservableConversation) conversation, buttonText, buttonCommand);
  profileUi.show();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:29,代码来源:ParticipantController.java

示例4: gwtSetUp

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
@Override
protected void gwtSetUp() {
  SafeHtml dom = EscapeUtils.fromSafeConstant("" + // \u2620
      "<div id='base' kind='base'>" + // \u2620
      "  <div>" + // \u2620
      "    <div kind='foo' id='foo'>" + // \u2620
      "      <div kind='unused'>" + // \u2620
      "        <div kind='bar' id='bar'>" + // \u2620
      "          <div id='source'></div>" + // \u2620
      "        </div>" + // \u2620
      "      </div>" + // \u2620
      "    </div>" + // \u2620
      "  </div>" + // \u2620
      "</div>");

  top = load(dom);
  foo = Document.get().getElementById("foo");
  bar = Document.get().getElementById("bar");

  // Register some handlers.
  handlers = new MockHandlers(top);
  fooHandler = new MyHandler();
  barHandler = new MyHandler();
  handlers.register("foo", fooHandler);
  handlers.register("bar", barHandler);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:27,代码来源:EventDispatcherPanelGwtTest.java

示例5: menuBuilder

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
/**
 * Creates a builder for a blip menu.
 */
public static UiBuilder menuBuilder(final Set<MenuOption> options, final Set<MenuOption> selected,
    final BlipViewBuilder.Css css) {
  return new UiBuilder() {
    @Override
    public void outputHtml(SafeHtmlBuilder out) {
      for (MenuOption option : options) {
        out.append(EscapeUtils.fromSafeConstant("|"));
        String style = selected.contains(option) //
            ? css.menuOption() + css.menuOptionSelected() : css.menuOption();
        String extra = OPTION_ID_ATTRIBUTE + "='" + MENU_CODES.get(option).asString() + "'"
            + (selected.contains(option) ? " " + OPTION_SELECTED_ATTRIBUTE + "='s'" : "");
        openSpanWith(out, null, style, TypeCodes.kind(Type.MENU_ITEM), extra);
        out.append(MENU_LABELS.get(option));
        closeSpan(out);
      }
    }
  };
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:22,代码来源:BlipMetaViewBuilder.java

示例6: handleParticipantClicked

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
/**
 * Shows a participation popup for the clicked participant.
 */
private void handleParticipantClicked(Element context) {
  ParticipantView participantView = views.asParticipant(context);
  final Pair<Conversation, ParticipantId> participation = models.getParticipant(participantView);
  Profile profile = profiles.getProfile(participation.second);

  // Summon a popup view from a participant, and attach profile-popup logic to
  // it.
  final ProfilePopupView profileView = participantView.showParticipation();
  ProfilePopupPresenter profileUi = ProfilePopupPresenter.create(profile, profileView, profiles);
  profileUi.addControl(EscapeUtils.fromSafeConstant(messages.remove()), new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      participation.first.removeParticipant(participation.second);
      // The presenter is configured to destroy itself on view hide.
      profileView.hide();
    }
  });
  profileUi.show();
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:23,代码来源:ParticipantController.java

示例7: image

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
/**
 * Appends an image.
 *
 * @param builder
 * @param id
 * @param style
 * @param url attribute-value safe URL
 * @param info attribute-value safe image information
 * @param kind
 * @param extra additional HTML
 */
public static void image(
    SafeHtmlBuilder builder, String id, String style, SafeHtml url, SafeHtml info, String kind,
    String extra) {
  String safeUrl = url != null ? EscapeUtils.sanitizeUri(url.asString()) : null;
  StringBuilder s = new StringBuilder();
  s.append("<img ");
  if (id != null) {
    s.append("id='").append(id).append("' ");
  }
  if (style != null) {
    s.append("class='").append(style).append("' ");
  }
  if (safeUrl != null) {
    s.append("src='").append(safeUrl).append("' ");
  }
  if (info != null) {
    s.append("alt='").append(info.asString()).append("' title='")
        .append(info.asString()).append("' ");
  }
  if (kind != null) {
    s.append(KIND_ATTRIBUTE).append("='").append(kind).append("'");
  }
  if (extra != null) {
    s.append(extra);
  }
  s.append("></img>");
  builder.appendHtmlConstant(s.toString());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:40,代码来源:OutputHelper.java

示例8: splitUri

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
/**
 * Splits a URI string into its scheme and suffix components, if it matches.
 *
 * @return [scheme, suffix] for scheme://suffix, or null if it doesn't match.
 */
private static String[] splitUri(String uri) {
  int sepLength = "://".length();
  String scheme = EscapeUtils.extractScheme(uri);
  if (scheme == null || uri.length() <= scheme.length() + sepLength) {
    return null;
  }
  return new String[] {scheme, uri.substring(scheme.length() + sepLength)};
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:14,代码来源:Link.java

示例9: render

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
@Override
public UiBuilder render(final ConversationBlip blip, IdentityMap<ConversationThread,
    UiBuilder> replies) {
  return new UiBuilder() {
    @Override
      public void outputHtml(SafeHtmlBuilder out) {
        // Documents are rendered blank, and filled in later when they get paged in.
        out.append(EscapeUtils.fromSafeConstant("<div></div>"));
    }
  };
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:12,代码来源:FullDomRenderer.java

示例10: setUp

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
@Override
protected void setUp() {
  blipCss = UiBuilderTestHelper.mockCss(BlipViewBuilder.Css.class);
  String blipId = "askljfalikwh4rlkhs";
  String metaDomId = blipId + "M";
  blipDomId = blipId + "B";

  UiBuilder fakeContent = UiBuilder.Constant.of(
      EscapeUtils.fromSafeConstant(content));
  metaUi = new BlipMetaViewBuilder(metaDomId, fakeContent, blipCss);
  blipUi = new BlipViewBuilder(blipDomId, metaUi, UiBuilder.EMPTY, blipCss);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:13,代码来源:BlipViewBuilderTest.java

示例11: testAllComponentsPresent

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
public void testAllComponentsPresent() throws Exception {
  String id = "askljfalikwh4rlkhs";
  UiBuilder rootThread = UiBuilder.Constant.of(EscapeUtils.fromSafeConstant("<root></root>"));
  UiBuilder participants =
      UiBuilder.Constant.of(EscapeUtils.fromSafeConstant("<participants></participants>"));
  UiBuilder tags =
      UiBuilder.Constant.of(EscapeUtils.fromSafeConstant("<tags></tags>"));
  FixedConversationViewBuilder builder =
      new FixedConversationViewBuilder(id, rootThread, participants, tags, css);

  UiBuilderTestHelper.verifyHtml(builder, id, Components.values());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:13,代码来源:FixedConversationViewBuilderTest.java

示例12: testAllComponentsPresent

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
public void testAllComponentsPresent() throws Exception {
  String id = "askljfalikwh4rlkhs";
  UiBuilder rootThread = UiBuilder.Constant.of(EscapeUtils.fromSafeConstant("<root></root>"));
  UiBuilder participants =
      UiBuilder.Constant.of(EscapeUtils.fromSafeConstant("<participants></participants>"));
  UiBuilder tags =
      UiBuilder.Constant.of(EscapeUtils.fromSafeConstant("<tags></tags>"));
  FlowConversationViewBuilder builder =
      new FlowConversationViewBuilder(id, rootThread, participants, tags, css);

  UiBuilderTestHelper.verifyHtml(builder, id, Components.values());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:13,代码来源:FlowConversationViewBuilderTest.java

示例13: image

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
/**
 * Appends an image.
 *
 * @param url attribute-value safe URL
 * @param info attribute-value safe image information
 * @param style
 */
public static void image(
    SafeHtmlBuilder builder, String id, String style, SafeHtml url, SafeHtml info, String kind) {
  String safeUrl = url != null ? EscapeUtils.sanitizeUri(url.asString()) : null;
  SafeHtml img = EscapeUtils.fromSafeConstant("<img " //
      + "id='" + id + "' " //
      + "class='" + style + "' " //
      + (safeUrl != null ? "src='" + safeUrl + "' " : "") //
      + (info != null ? " alt='" + info.asString() + "' title='" + info.asString() + "' " : "") //
      + (kind != null ? " " + KIND_ATTRIBUTE + "='" + kind + "'" : "") //
      + "></img>");
  builder.append(img);
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:20,代码来源:OutputHelper.java

示例14: outputHtml

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
@Override
public void outputHtml(SafeHtmlBuilder output) {
  image(output,
      id,
      css.participant(),
      EscapeUtils.fromString(avatarUrl),
      EscapeUtils.fromString(name),
      TypeCodes.kind(Type.PARTICIPANT));
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:10,代码来源:ParticipantAvatarViewBuilder.java

示例15: outputHtml

import org.waveprotocol.wave.client.common.safehtml.EscapeUtils; //导入依赖的package包/类
@Override
public void outputHtml(SafeHtmlBuilder output) {
  openWith(output, id, css.replyBox(), TypeCodes.kind(Type.REPLY_BOX),
      enabled ? "" : "style='display:none'");
  {
    // Author avatar.
    image(output, Components.AVATAR.getDomId(id), css.avatar(),
        EscapeUtils.fromString(avatarUrl), EscapeUtils.fromPlainText("author"), null);
    output.appendEscaped(messages.clickHereToReply());
  }
  close(output);
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:13,代码来源:ReplyBoxViewBuilder.java


注:本文中的org.waveprotocol.wave.client.common.safehtml.EscapeUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。