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


Java UrlEscapers.urlFormParameterEscaper方法代码示例

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


在下文中一共展示了UrlEscapers.urlFormParameterEscaper方法的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: 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

示例3: 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

示例4: 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

示例5: getPathAndQuery

import com.google.common.net.UrlEscapers; //导入方法依赖的package包/类
public String getPathAndQuery() {
  String url = this.path;
  boolean isFirst = true;
  for (Map.Entry<String, String> queryParameter : this.queryParameters.entries()) {
    if (isFirst) {
      url += "?";
      isFirst = false;
    } else {
      url += "&";
    }
    Escaper escaper = UrlEscapers.urlFormParameterEscaper();
    url += escaper.escape(queryParameter.getKey()) + "=" + escaper.escape(queryParameter.getValue());
  }

  return url;
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:17,代码来源:HttpRequest.java

示例6: getPathAndQuery

import com.google.common.net.UrlEscapers; //导入方法依赖的package包/类
public String getPathAndQuery() {

    String url = this.path;
    boolean isFirst = true;
    for (Map.Entry<String, String> queryParameter : this.queryParameters.entries()) {
      if (isFirst) {
        url += "?";
        isFirst = false;
      } else {
        url += "&";
      }
      Escaper escaper = UrlEscapers.urlFormParameterEscaper();
      url += escaper.escape(queryParameter.getKey()) + "=" + escaper.escape(queryParameter.getValue());
    }

    return url;
  }
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:18,代码来源:HttpRequest.java

示例7: formatReportUrl

import com.google.common.net.UrlEscapers; //导入方法依赖的package包/类
@VisibleForTesting
static String formatReportUrl() {
  String body = MessageFormat.format(BODY_TEMPLATE, CloudToolsInfo.getToolsVersion(),
      getCloudSdkVersion(), getEclipseVersion(),
      System.getProperty("os.name"), System.getProperty("os.version"),
      System.getProperty("java.version"));

  Escaper escaper = UrlEscapers.urlFormParameterEscaper();
  return BUG_REPORT_URL + "?body=" + escaper.escape(body);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:11,代码来源:BugReportCommandHandler.java

示例8: doRequest

import com.google.common.net.UrlEscapers; //导入方法依赖的package包/类
@Override
protected void doRequest(final HttpClient client) {

    // Build query URI
    Escaper escaper = UrlEscapers.urlFormParameterEscaper();
    StringBuilder queryUri = new StringBuilder(INFLUXDB_QUERY_URI);
    queryUri.append(escaper.escape(m_query));

    m_logger.debug("Executing query: {} (host: {})",
            queryUri, getConnection().getAddress());

    HttpClientRequest request = doGet(queryUri.toString(), new HttpClientResponseAdapter() {

        @Override
        protected void handleFailure(final HttpClientResponse response) {
            if (response.statusCode() != 200) {
                m_logger.error("Failed to execute query: {} (host: {})",
                        m_query,
                        getConnection().getAddress(),
                        new IllegalStateException("HTTP get failure: "
                                + response.statusCode()
                                + "/"
                                + response.statusMessage()));
            }
        }
    });

    // HTTP basic authentication
    if (!Strings.isNullOrEmpty(m_adminUser)) {
        request.putHeader(HttpHeaders.Names.AUTHORIZATION, "Basic "
                + base64UserAndPassword(m_adminUser, m_adminPassword));
    }

    request.exceptionHandler(new DefaultConnectionExceptionHandler(
            getConnection()));
    request.end();
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:38,代码来源:InfluxDb.java

示例9: renderMultisetTable

import com.google.common.net.UrlEscapers; //导入方法依赖的package包/类
public static <T extends Appendable> T renderMultisetTable(final T out,
        final Multiset<?> multiset, final String elementHeader,
        final String occurrencesHeader, @Nullable final String linkTemplate)
        throws IOException {

    final String tableID = "table" + COUNTER.getAndIncrement();
    out.append("<table id=\"").append(tableID).append("\" class=\"display datatable\">\n");
    out.append("<thead>\n<tr><th>").append(MoreObjects.firstNonNull(elementHeader, "Value"))
            .append("</th><th>")
            .append(MoreObjects.firstNonNull(occurrencesHeader, "Occurrences"))
            .append("</th></tr>\n</thead>\n");
    out.append("<tbody>\n");
    for (final Object element : multiset.elementSet()) {
        final int occurrences = multiset.count(element);
        out.append("<tr><td>");
        RenderUtils.render(element, out);
        out.append("</td><td>");
        if (linkTemplate == null) {
            out.append(Integer.toString(occurrences));
        } else {
            final Escaper esc = UrlEscapers.urlFormParameterEscaper();
            final String e = esc.escape(Data.toString(element, Data.getNamespaceMap()));
            final String u = linkTemplate.replace("${element}", e);
            out.append("<a href=\"").append(u).append("\">")
                    .append(Integer.toString(occurrences)).append("</a>");
        }
        out.append("</td></tr>\n");
    }
    out.append("</tbody>\n</table>\n");
    out.append("<script>$(document).ready(function() { applyDataTable('").append(tableID)
            .append("', false, {}); });</script>");
    return out;
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:34,代码来源:RenderUtils.java

示例10: query

import com.google.common.net.UrlEscapers; //导入方法依赖的package包/类
private String query(final Object... queryNameValues) {
    final StringBuilder builder = new StringBuilder();
    final Escaper escaper = UrlEscapers.urlFormParameterEscaper();
    String separator = "?";
    for (int i = 0; i < queryNameValues.length; i += 2) {
        final Object name = queryNameValues[i].toString();
        final Object value = queryNameValues[i + 1];
        if (value == null) {
            continue;
        }
        final Iterable<?> iterable = value instanceof Iterable<?> ? (Iterable<?>) value
                : ImmutableSet.of(value);
        for (final Object element : iterable) {
            if (element == null) {
                continue;
            }
            String encoded;
            if (element instanceof Value && !name.equals(Protocol.PARAMETER_DEFAULT_GRAPH)
                    && !name.equals(Protocol.PARAMETER_NAMED_GRAPH)) {
                encoded = Data.toString(element, Data.getNamespaceMap());
            } else {
                encoded = element.toString();
            }
            builder.append(separator).append(name).append("=");
            builder.append(escaper.escape(encoded));
            separator = "&";
        }
    }
    return builder.toString();
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:31,代码来源:Client.java

示例11: urlEncode

import com.google.common.net.UrlEscapers; //导入方法依赖的package包/类
@Description("escape a string for use in URL query parameter names and values")
@ScalarFunction
@SqlType(StandardTypes.VARCHAR)
public static Slice urlEncode(@SqlType(StandardTypes.VARCHAR) Slice value)
{
    Escaper escaper = UrlEscapers.urlFormParameterEscaper();
    return slice(escaper.escape(value.toStringUtf8()));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:9,代码来源:UrlFunctions.java

示例12: xss

import com.google.common.net.UrlEscapers; //导入方法依赖的package包/类
private void xss(final Env env) {
  Escaper ufe = UrlEscapers.urlFragmentEscaper();
  Escaper fpe = UrlEscapers.urlFormParameterEscaper();
  Escaper pse = UrlEscapers.urlPathSegmentEscaper();
  Escaper html = HtmlEscapers.htmlEscaper();

  env.xss("urlFragment", ufe::escape)
      .xss("formParam", fpe::escape)
      .xss("pathSegment", pse::escape)
      .xss("html", html::escape);
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:12,代码来源:Jooby.java

示例13: getAsQuery

import com.google.common.net.UrlEscapers; //导入方法依赖的package包/类
public String getAsQuery() throws BinanceApiException {
    StringBuffer sb = new StringBuffer();
    Escaper esc = UrlEscapers.urlFormParameterEscaper();
    if (symbol == null) {
        throw new BinanceApiException("Order Symbol is not set");
    }
    sb.append("&symbol=").append(symbol.toString());
    if (side == null) {
        throw new BinanceApiException("Order side is not set");
    }
    sb.append("&side=").append(side.toString());
    if (type == null) {
        throw new BinanceApiException("Order type is not set");
    }
    sb.append("&type=").append(type.toString());
    if (quantity == null || quantity.compareTo(BigDecimal.ZERO) <= 0) {
        throw new BinanceApiException("Order quantity should be bigger than zero");
    }
    sb.append("&quantity=").append(quantity.toString());

    if (type == BinanceOrderType.MARKET) {
        // price should be skipped for a market order, we are accepting market price
        // so should timeInForce
    } else {
        if (timeInForce == null) {
            throw new BinanceApiException("Order timeInForce is not set");
        }
        sb.append("&timeInForce=").append(timeInForce.toString());
        if (price == null || price.compareTo(BigDecimal.ZERO) <= 0) {
            throw new BinanceApiException("Order price should be bigger than zero");
        }
        sb.append("&price=").append(price.toString());
    }

    if (!Strings.isNullOrEmpty(newClientOrderId)) {
        sb.append("&newClientOrderId=").append(esc.escape(newClientOrderId));
    }
    if (stopPrice != null) {
        sb.append("&stopPrice=").append(stopPrice.toString());
    }
    if (icebergQty != null) {
        sb.append("&icebergQty=").append(icebergQty.toString());
    }
    return sb.toString().substring(1); // skipping the first &
}
 
开发者ID:webcerebrium,项目名称:java-binance-api,代码行数:46,代码来源:BinanceOrderPlacement.java

示例14: encodeQuery

import com.google.common.net.UrlEscapers; //导入方法依赖的package包/类
public static String encodeQuery(String query) {
	Escaper escaper = UrlEscapers.urlFormParameterEscaper();
	StringBuilder sb = new StringBuilder();
	
	Iterable<String> keyValueIterable = querySplitter.split(query);
	Iterator<String> iterator = keyValueIterable.iterator();
	while(iterator.hasNext()) {
		String keyValue = iterator.next();
		if (keyValue.isEmpty()) {
			if (iterator.hasNext()) {
				sb.append("&");
			}
			continue;
		}
		
		if (keyValue.equals("=")) {
			sb.append(keyValue);
			if (iterator.hasNext()) {
				sb.append("&");
			}
			continue;
		}
		
		int index = keyValue.indexOf('=');
		if (index == -1) {
			keyValue = escaper.escape(keyValue);
			sb.append(keyValue);
			if (iterator.hasNext()) {
				sb.append("&");
			}
			continue;
		}
		
		String key = keyValue.substring(0, index);
		if (index == 0) {
			key = "";
		}
		String value = "";
		if (index + 1 < keyValue.length()) {
			value = keyValue.substring(index + 1, keyValue.length());
		}
		
		if (!key.isEmpty()) {
			key = escaper.escape(key);
			sb.append(key);
			sb.append("=");
		}
		if (!value.isEmpty()) {
			value = escaper.escape(value);
			sb.append(value);
			if (iterator.hasNext()) {
				sb.append("&");
			}
		}
	}
	
	return sb.toString();
}
 
开发者ID:code4wt,项目名称:short-url,代码行数:59,代码来源:UrlUtils.java

示例15: createsFormRequestWithParams

import com.google.common.net.UrlEscapers; //导入方法依赖的package包/类
/**
 * RqFormFake can create fake forms with parameters list.
 * @throws Exception If something goes wrong.
 */
@Test
public void createsFormRequestWithParams() throws Exception {
    final String key = "key";
    final String akey = "anotherkey";
    final String value = "value";
    final String avalue = "a&b";
    final String aavalue = "againanothervalue";
    final Escaper escaper = UrlEscapers.urlFormParameterEscaper();
    final RqForm req = new RqFormFake(
        new RqFake(
            Arrays.asList(
                "GET /form",
                "Host: www.example5.com",
                String.format(
                    RqFormFakeTest.HEADER,
                    escaper.escape(key).length() + 1
                        + escaper.escape(value).length() + 1
                        + escaper.escape(key).length() + 1
                        + escaper.escape(avalue).length() + 1
                        + escaper.escape(akey).length() + 1
                        + escaper.escape(aavalue).length()
                )
            ),
            ""
        ),
        key, value,
        key, avalue,
        akey, aavalue
    );
    MatcherAssert.assertThat(
        req.param(key),
        Matchers.hasItems(value, avalue)
    );
    MatcherAssert.assertThat(
        req.param(akey),
        Matchers.hasItems(aavalue)
    );
    MatcherAssert.assertThat(
        req.names(),
        Matchers.hasItems(key, akey)
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:47,代码来源:RqFormFakeTest.java


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