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


Java UrlEscapers类代码示例

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


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

示例1: getAsQuery

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
public String getAsQuery() {
    StringBuffer sb = new StringBuffer();
    Escaper esc = UrlEscapers.urlFormParameterEscaper();

    if (!Strings.isNullOrEmpty(asset)) {
        sb.append("&asset=").append(esc.escape(asset));
    }
    if (startTime != null) {
        sb.append("&startTime=").append(startTime.getTime());
    }
    if (endTime != null) {
        sb.append("&endTime=").append(endTime.getTime());
    }
    String s = sb.toString();
    return s.length() > 1 ? s.substring(1) : s; // skipping the first &
}
 
开发者ID:webcerebrium,项目名称:java-binance-api,代码行数:17,代码来源:BinanceHistoryFilter.java

示例2: encode

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
@Override
public ObjectNode encode(Intent intent, CodecContext context) {
    checkNotNull(intent, "Intent cannot be null");

    final ObjectNode result = context.mapper().createObjectNode()
            .put(TYPE, intent.getClass().getSimpleName())
            .put(ID, intent.id().toString())
            .put(APP_ID, UrlEscapers.urlPathSegmentEscaper()
                    .escape(intent.appId().name()));

    final ArrayNode jsonResources = result.putArray(RESOURCES);

    for (final NetworkResource resource : intent.resources()) {
        jsonResources.add(resource.toString());
    }

    IntentService service = context.getService(IntentService.class);
    IntentState state = service.getIntentState(intent.key());
    if (state != null) {
        result.put(STATE, state.toString());
    }

    return result;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:IntentCodec.java

示例3: encodePath

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
public static String encodePath(String path) {
	if (path.isEmpty() || path.equals("/")) {
		return path;
	}
	
	StringBuilder sb = new StringBuilder();
	Escaper escaper = UrlEscapers.urlPathSegmentEscaper();
	Iterable<String> iterable = pathSplitter.split(path);
	Iterator<String> iterator = iterable.iterator();
	while (iterator.hasNext()) {
		String part = iterator.next();
		if (part.isEmpty()) {
			sb.append("/");
			continue;
		}
		
		part = escaper.escape(part);
		sb.append(part);
		if (iterator.hasNext()) {
			sb.append("/");
		}
	}
	
	return sb.toString();
}
 
开发者ID:code4wt,项目名称:short-url,代码行数:26,代码来源:UrlUtils.java

示例4: getParametersString

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
@VisibleForTesting
static String getParametersString(Map<String, String> parametersMap) {
  StringBuilder resultBuilder = new StringBuilder();
  boolean ampersandNeeded = false;
  for (Map.Entry<String, String> entry : parametersMap.entrySet()) {
    if (ampersandNeeded) {
      resultBuilder.append('&');
    } else {
      ampersandNeeded = true;
    }
    resultBuilder.append(entry.getKey());
    resultBuilder.append('=');
    resultBuilder.append(UrlEscapers.urlFormParameterEscaper().escape(entry.getValue()));
  }
  return resultBuilder.toString();
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:17,代码来源:HttpUtil.java

示例5: add

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
public Builder add ( final String label, final String targetPattern, final String... pathSegments )
{
    Objects.requireNonNull ( targetPattern );
    Objects.requireNonNull ( pathSegments );

    final Escaper esc = UrlEscapers.urlPathSegmentEscaper ();

    final Object[] encoded = new String[pathSegments.length];
    for ( int i = 0; i < pathSegments.length; i++ )
    {
        encoded[i] = esc.escape ( pathSegments[i] );
    }

    this.entries.add ( new Entry ( label, MessageFormat.format ( targetPattern, encoded ) ) );
    return this;
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:17,代码来源:Breadcrumbs.java

示例6: editPost

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
@RequestMapping ( value = "/{channelId}/edit", method = RequestMethod.POST )
public ModelAndView editPost ( @PathVariable ( "channelId" ) final String channelId, @Valid @FormData ( "command" ) final P2MetaDataInformation data, final BindingResult result) throws Exception
{
    return Channels.withChannel ( this.service, channelId, ModifiableChannel.class, channel -> {

        final Map<String, Object> model = new HashMap<> ();

        if ( result.hasErrors () )
        {
            model.put ( "channel", channel.getInformation () );
            model.put ( "command", data );
            fillBreadcrumbs ( model, channelId, "Edit" );
            return new ModelAndView ( "p2edit", model );
        }

        final Map<MetaKey, String> providedMetaData = MetaKeys.unbind ( data );

        channel.applyMetaData ( providedMetaData );

        return new ModelAndView ( "redirect:/p2.metadata/" + UrlEscapers.urlPathSegmentEscaper ().escape ( channelId ) + "/info", model );
    } );
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:23,代码来源:P2MetaDataController.java

示例7: editPost

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
@RequestMapping ( value = "/{channelId}/edit", method = RequestMethod.POST )
public ModelAndView editPost ( @PathVariable ( "channelId" ) final String channelId, @Valid @FormData ( "command" ) final P2ChannelInformation data, final BindingResult result) throws Exception
{
    return Channels.withChannel ( this.service, channelId, ModifiableChannel.class, channel -> {

        final Map<String, Object> model = new HashMap<> ();

        if ( result.hasErrors () )
        {
            model.put ( "channel", channel.getInformation () );
            model.put ( "command", data );
            fillBreadcrumbs ( model, channelId, "Edit" );
            return new ModelAndView ( "p2edit", model );
        }

        final Map<MetaKey, String> providedMetaData = MetaKeys.unbind ( data );

        channel.applyMetaData ( providedMetaData );

        return new ModelAndView ( "redirect:/p2.repo/" + UrlEscapers.urlPathSegmentEscaper ().escape ( channelId ) + "/info", model );
    } );
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:23,代码来源:P2RepoController.java

示例8: uiReportEntityMentionsAggregate

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
private void uiReportEntityMentionsAggregate(final Map<String, Object> model,
        final URI entityID) throws Throwable {

    // Do nothing in case the entity ID is missing
    if (entityID == null) {
        return;
    }

    // Render the table
    final Stream<Record> mentions = getEntityMentions(entityID, Integer.MAX_VALUE, null);
    final Predicate<URI> filter = Predicates.not(Predicates.in(ImmutableSet.<URI>of(
            NIF.BEGIN_INDEX, NIF.END_INDEX, KS.MENTION_OF)));
    final String linkTemplate = "ui?action=entity-mentions&entity="
            + UrlEscapers.urlFormParameterEscaper().escape(entityID.stringValue())
            + "&property=${property}&value=${value}";
    model.put("propertyValuesTable", RenderUtils.renderRecordsAggregateTable(
            new StringBuilder(), mentions, filter, linkTemplate, null));
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:19,代码来源:Root.java

示例9: uiReportMentionValueOccurrences

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
private void uiReportMentionValueOccurrences(final Map<String, Object> model,
        final URI entityID, @Nullable final URI property) throws Throwable {

    // Do nothing in case the entity ID is missing
    if (entityID == null || property == null) {
        return;
    }

    // Compute the # of occurrences of all the values of the given property in entity mentions
    final Multiset<Value> propertyValues = HashMultiset.create();
    for (final Record mention : getEntityMentions(entityID, Integer.MAX_VALUE, null)) {
        propertyValues.addAll(mention.get(property, Value.class));
    }

    // Render the table
    final Escaper esc = UrlEscapers.urlFormParameterEscaper();
    final String linkTemplate = "ui?action=entity-mentions&entity="
            + esc.escape(entityID.stringValue()) + "&property="
            + esc.escape(Data.toString(property, Data.getNamespaceMap()))
            + "&value=${element}";
    model.put("valueOccurrencesTable", RenderUtils.renderMultisetTable(new StringBuilder(),
            propertyValues, "Property value", "# Mentions", linkTemplate));
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:24,代码来源:Root.java

示例10: uiReportMentionPropertyOccurrences

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
private void uiReportMentionPropertyOccurrences(final Map<String, Object> model,
        final URI entityID) throws Throwable {

    // Do nothing in case the entity ID is missing
    if (entityID == null) {
        return;
    }

    // Compute the # of occurrences of each property URI in entity mentions
    final Multiset<URI> propertyURIs = HashMultiset.create();
    for (final Record mention : getEntityMentions(entityID, Integer.MAX_VALUE, null)) {
        propertyURIs.addAll(mention.getProperties());
    }

    // Render the table
    final Escaper esc = UrlEscapers.urlFormParameterEscaper();
    final String linkTemplate = "ui?action=entity-mentions&entity="
            + esc.escape(entityID.stringValue()) + "&property=${element}";
    model.put("propertyOccurrencesTable", RenderUtils.renderMultisetTable(new StringBuilder(),
            propertyURIs, "Property", "# Mentions", linkTemplate));
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:22,代码来源:Root.java

示例11: projectExists

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
public boolean projectExists(String projectId) throws IOException
{
    ListenableFuture<String> jsonChangeInfoHolder = HttpHelper.getAsyncFromHttp(new URL(gerritURL + "projects/" + UrlEscapers.urlPathSegmentEscaper().escape(projectId)));
    try
    {
        String json = jsonChangeInfoHolder.get(20000, TimeUnit.MILLISECONDS);
        if ("NOT FOUND".equalsIgnoreCase(json.trim()))
        {
            return false;
        }
        json = json.substring(4);
        JsonParser parser = new JsonParser();
        JsonObject jsonObj = parser.parse(json).getAsJsonObject();
        JsonElement stateElement = jsonObj.get("state");
        String state = stateElement != null ? stateElement.getAsString() : null;
        return "ACTIVE".equals(state);
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:Ullink,项目名称:slack4gerrit,代码行数:24,代码来源:GerritChangeInfoService.java

示例12: userExists

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
public boolean userExists(String userId) throws IOException
{
    ListenableFuture<String> jsonChangeInfoHolder = HttpHelper.getAsyncFromHttp(new URL(gerritURL + "accounts/" + UrlEscapers.urlPathSegmentEscaper().escape(userId)));
    try
    {
        String json = jsonChangeInfoHolder.get(20000, TimeUnit.MILLISECONDS);
        if ("NOT FOUND".equalsIgnoreCase(json.trim()))
        {
            return false;
        }

        return true;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:Ullink,项目名称:slack4gerrit,代码行数:20,代码来源:GerritChangeInfoService.java

示例13: buildRawPathString

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
public StringBuilder buildRawPathString(boolean absolute, boolean slashAtEnd, String[] segments) {
    StringBuilder result = new StringBuilder();
    if (absolute) {
        result.append('/');
    }
    boolean addedOne = false;
    for (String s : segments) {
        result.append(UrlEscapers.urlPathSegmentEscaper()
                .escape(s));
        result.append('/');
        addedOne = true;
    }
    if (addedOne && !slashAtEnd) {
        result.deleteCharAt(result.length() - 1);
    }
    return result;
}
 
开发者ID:pidoco,项目名称:juri,代码行数:18,代码来源:JURI.java

示例14: buildQueryParametersString

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
public static CharSequence buildQueryParametersString(Multimap<String, String> currentQueryParameters) {
    StringBuilder paramsString = new StringBuilder();
    boolean first = true;
    for (Map.Entry<String, String> entry : currentQueryParameters.entries()) {
        if (!first) {
            paramsString.append('&');
        }
        String keyEnc = UrlEscapers.urlFormParameterEscaper()
                .escape(entry.getKey());
        if (entry.getValue() != null) {
            String valueEnc = UrlEscapers.urlFormParameterEscaper()
                    .escape(entry.getValue());
            paramsString.append(keyEnc)
                    .append('=')
                    .append(valueEnc);
        } else {
            paramsString.append(keyEnc);
        }
        first = false;
    }

    return paramsString;
}
 
开发者ID:pidoco,项目名称:juri,代码行数:24,代码来源:JURI.java

示例15: transform

import com.google.common.net.UrlEscapers; //导入依赖的package包/类
@Override
public String[] transform(final InputRow inputRow) {
    final String value = inputRow.getValue(column);
    if (value == null) {
        return new String[1];
    }
    final Escaper escaper;
    switch (targetFormat) {
    case FORM_PARAMETER:
        escaper = UrlEscapers.urlFormParameterEscaper();
        break;
    case FRAGMENT:
        escaper = UrlEscapers.urlFragmentEscaper();
        break;
    case PATH_SEGMENT:
        escaper = UrlEscapers.urlPathSegmentEscaper();
        break;
    default:
        throw new UnsupportedOperationException();
    }
    final String escaped = escaper.escape(value);
    return new String[] { escaped };
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:24,代码来源:UrlEncoderTransformer.java


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