當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。