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


Java URI.toASCIIString方法代码示例

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


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

示例1: getUrlWithQueryString

import java.net.URI; //导入方法依赖的package包/类
/**
 * Will encode url, if not disabled, and adds params on the end of it
 *
 * @param url             String with URL, should be valid URL without params
 * @param params          RequestParams to be appended on the end of URL
 * @param shouldEncodeUrl whether url should be encoded (replaces spaces with %20)
 * @return encoded url if requested with params appended if any available
 */
public static String getUrlWithQueryString(boolean shouldEncodeUrl, String url, RequestParams params) {
    if (url == null)
        return null;

    if (shouldEncodeUrl) {
        try {
            String decodedURL = URLDecoder.decode(url, "UTF-8");
            URL _url = new URL(decodedURL);
            URI _uri = new URI(_url.getProtocol(), _url.getUserInfo(), _url.getHost(), _url.getPort(), _url.getPath(), _url.getQuery(), _url.getRef());
            url = _uri.toASCIIString();
        } catch (Exception ex) {
            // Should not really happen, added just for sake of validity
            log.e(LOG_TAG, "getUrlWithQueryString encoding URL", ex);
        }
    }

    if (params != null) {
        // Construct the query string and trim it, in case it
        // includes any excessive white spaces.
        String paramString = params.getParamString().trim();

        // Only add the query string if it isn't empty and it
        // isn't equal to '?'.
        if (!paramString.equals("") && !paramString.equals("?")) {
            url += url.contains("?") ? "&" : "?";
            url += paramString;
        }
    }

    return url;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:40,代码来源:AsyncHttpClient.java

示例2: loadDelegateCatalog

import java.net.URI; //导入方法依赖的package包/类
/**
 * Loads a delegate catalog by the catalogId specified.
 *
 * @param parent the parent catalog of the delegate catalog
 * @param catalogURI the URI to the catalog
 */
Catalog loadDelegateCatalog(CatalogImpl parent, URI catalogURI) {
    CatalogImpl delegateCatalog = null;
    if (catalogURI != null) {
        String catalogId = catalogURI.toASCIIString();
        if (verifyCatalogFile(parent, catalogURI)) {
            delegateCatalog = getLoadedCatalog(catalogId);
            if (delegateCatalog == null) {
                delegateCatalog = new CatalogImpl(parent, features, catalogURI);
                delegateCatalog.load();
                delegateCatalogs.put(catalogId, delegateCatalog);
            }
        }
    }

    return delegateCatalog;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:GroupEntry.java

示例3: viewableDeregister

import java.net.URI; //导入方法依赖的package包/类
public Result viewableDeregister(
		String viewableURN
	) 
	    throws IOException, 
	           URISyntaxException
	{
		String scope[] = { SCOPE_DATA_READ, SCOPE_DATA_WRITE };
		ResultAuthentication authResult = authenticate( scope );
		if( authResult.isError() )
		{
			return authResult;
		}

		viewableURN = new String( Base64.encodeBase64( viewableURN.getBytes() ) );
		String params[] = { viewableURN };
		String frag = makeURN( API_VIEWING, PATT_VIEW_DEREGISTER, params );
		
		URI uri = new URI( _protocol, null, lookupHostname(), _port, frag, null, null );

		URL url = new URL( uri.toASCIIString() );
		HttpURLConnection connection = (HttpURLConnection)url.openConnection();

		connection.setRequestMethod( "DELETE" );
		authResult.setAuthHeader( connection );
//        connection.setRequestProperty( "Accept", "Application/json" );
		
		return new Result( connection );
	}
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:29,代码来源:DataRESTAPI.java

示例4: urlToString

import java.net.URI; //导入方法依赖的package包/类
public static String urlToString(URL url, boolean pathOnly) {
    URI uri;
    try {
        uri = url.toURI();
    } catch (URISyntaxException ex) {
        // fallback:
        LOGGER.log(Level.FINE, "URL '"+url+"' cannot be converted to URI.");
        String res = url.toExternalForm();
        int end = res.lastIndexOf('?');
        if (end == -1) {
            end = res.lastIndexOf('#');
        }
        if (pathOnly && end != -1) {
            res = res.substring(0, end);
        }
        return res;
    }
    // do not use URI to encode JAR url and simply return it as is:
    if ("jar".equals(uri.getScheme())) { // NOI18N
        return uri.toASCIIString();
    }
    StringBuilder sb = new StringBuilder();
    sb.append(uri.getScheme());
    sb.append("://"); // NOI18N
    if (uri.getAuthority() != null) {
        sb.append(uri.getAuthority());
    }
    sb.append(uri.getPath());
    if (!pathOnly && uri.getQuery() != null) {
        sb.append("?"); // NOI18N
        sb.append(uri.getQuery());
    }
    if (!pathOnly && uri.getFragment() != null) {
        sb.append("#"); // NOI18N
        sb.append(uri.getFragment());
    }
    return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:WebUtils.java

示例5: getThumbnailURL

import java.net.URI; //导入方法依赖的package包/类
public String getThumbnailURL(
	String urn
) 
	throws URISyntaxException 
{
	String params[] = { urn };
	String frag = makeURN( API_VIEWING, PATT_VIEW_THUMBNAIL, params );
	URI uri = new URI( "https", null, lookupHostname(), -1, frag, null, null );
	return uri.toASCIIString();
}
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:11,代码来源:APIImpl.java

示例6: bucketDelete

import java.net.URI; //导入方法依赖的package包/类
public Result bucketDelete(
   	String bucketKey
) 
	throws IOException, 
	       URISyntaxException 
   {
   	String scope[] = { SCOPE_BUCKET_DELETE };
	ResultAuthentication authResult = authenticate( scope );
	if( authResult.isError() )
	{
		return authResult;
	}
	
	String params[] = { bucketKey };
	String frag = makeURN( API_OSS, PATT_BUCKET_DELETE, params );
	
	URI uri = new URI( _protocol, null, lookupHostname(), _port, frag , null, null );

	URL url = new URL( uri.toASCIIString() );
	HttpURLConnection connection = (HttpURLConnection)url.openConnection();

	connection.setRequestMethod( "DELETE" );
	authResult.setAuthHeader( connection );
       connection.setRequestProperty( "Accept", "Application/json" );
	connection.setRequestProperty( "Content-Type", "application/json; charset=utf-8" );

	Result result = new ResultBucketList( connection );
	return result;
   	
   }
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:31,代码来源:DataRESTAPI.java

示例7: getDefaultProxyTrackingUrl

import java.net.URI; //导入方法依赖的package包/类
private String getDefaultProxyTrackingUrl() {
  try {
    final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri, applicationId);
    return result.toASCIIString();
  } catch (URISyntaxException e) {
    LOG.warn("Could not generate default proxy tracking URL for "
        + applicationId);
    return UNAVAILABLE;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:RMAppImpl.java

示例8: bucketQueryDetails

import java.net.URI; //导入方法依赖的package包/类
/**
 * This API will return bucket details in json format, if the caller is the owner or the calling 
 * service or application has access rights on the bucket. Any other request will result in 403
 *  Forbidden.
 * @param bucketKey
 * @return
 * @throws IOException
 * @throws URISyntaxException
 */
   public ResultBucketDetail bucketQueryDetails(
	String bucketKey
) 
    throws IOException, 
           URISyntaxException
{
   	String scope[] = { SCOPE_BUCKET_READ };
	ResultAuthentication authResult = authenticate( scope );
	if( authResult.isError() )
	{
		return new ResultBucketDetail( authResult );
	}
	
	String params[] = { bucketKey.toLowerCase() };
	String frag = makeURN( API_OSS, PATT_BUCKET_QUERY, params );

	URI uri = new URI( _protocol, null, lookupHostname(), _port, frag, null, null );

	URL url = new URL( uri.toASCIIString() );
	HttpURLConnection connection = (HttpURLConnection)url.openConnection();

	connection.setRequestMethod( "GET" );
	authResult.setAuthHeader( connection );
       connection.setRequestProperty( "Accept", "Application/json" );
	connection.setRequestProperty( "Content-Type", "application/json; charset=utf-8" );

	return new ResultBucketDetail( connection );
}
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:38,代码来源:DataRESTAPI.java

示例9: getRequestLine

import java.net.URI; //导入方法依赖的package包/类
public RequestLine getRequestLine() {
    String method = getMethod();
    ProtocolVersion ver = getProtocolVersion();
    URI uri = getURI();
    String uritext = null;
    if (uri != null) {
        uritext = uri.toASCIIString();
    }
    if (uritext == null || uritext.length() == 0) {
        uritext = "/";
    }
    return new BasicRequestLine(method, uritext, ver);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:HttpRequestBase.java

示例10: objectQueryDetails

import java.net.URI; //导入方法依赖的package包/类
public ResultObjectDetail objectQueryDetails(
	String bucketKey,
	String objectKey
) 
    throws IOException, 
           URISyntaxException
{
	String scope[] = { SCOPE_DATA_READ };
	ResultAuthentication authResult = authenticate( scope );
	if( authResult.isError() )
	{
		return new ResultObjectDetail( authResult );
	}
	
	String params[] = { bucketKey.toLowerCase(), objectKey };
	String frag = makeURN( API_OSS, PATT_OBJECT_QUERY, params );

	URI uri = new URI( _protocol, null, lookupHostname(), _port, frag, null, null );

	URL url = new URL( uri.toASCIIString() );
	HttpURLConnection connection = (HttpURLConnection)url.openConnection();

	connection.setRequestMethod( "GET" );
	authResult.setAuthHeader( connection );
       connection.setRequestProperty( "Accept", "Application/json" );
	connection.setRequestProperty( "Content-Type", "application/json; charset=utf-8" );

	return new ResultObjectDetail( connection );
}
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:30,代码来源:DataRESTAPI.java

示例11: ticketValidator

import java.net.URI; //导入方法依赖的package包/类
@Bean
TicketValidator ticketValidator(List<CasSecurityConfigurer> casSecurityConfigurers) {
    URI baseUrl = casSecurityProperties.getServer().getValidationBaseUrl() != null
            ? casSecurityProperties.getServer().getValidationBaseUrl()
            : casSecurityProperties.getServer().getBaseUrl();
    CasTicketValidatorBuilder builder = new CasTicketValidatorBuilder(baseUrl.toASCIIString());
    casSecurityConfigurers.forEach(c -> c.configure(builder));
    return builder.build();
}
 
开发者ID:kakawait,项目名称:cas-security-spring-boot-starter,代码行数:10,代码来源:CasTicketValidatorConfiguration.java

示例12: getRequestLine

import java.net.URI; //导入方法依赖的package包/类
public RequestLine getRequestLine() {
    final String method = getMethod();
    final ProtocolVersion ver = getProtocolVersion();
    final URI uri = getURI();
    String uritext = null;
    if (uri != null) {
        uritext = uri.toASCIIString();
    }
    if (uritext == null || uritext.length() == 0) {
        uritext = "/";
    }
    return new BasicRequestLine(method, uritext, ver);
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:14,代码来源:HttpRequestBase.java

示例13: getProxyUrl

import java.net.URI; //导入方法依赖的package包/类
private String getProxyUrl(RMAppAttempt appAttempt) {
  String url = null;
  final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
  try {
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri, appAttempt
        .getAppAttemptId().getApplicationId());
    url = result.toASCIIString();
  } catch (URISyntaxException ex) {
    Assert.fail();
  }
  return url;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TestRMAppAttemptTransitions.java

示例14: bucketCreate

import java.net.URI; //导入方法依赖的package包/类
/**
 * Use this API to create a bucket. Buckets are arbitrary spaces created and owned by services. Bucket 
 * keys are unique within the data center or region in which they were created. The service creating 
 * the bucket is the owner of the bucket, and the owning service will always have full access to a bucket. 
 * A bucket key cannot be changed once it is created.
 * <p>
 * Buckets must have a retention policy attached to them at create time. Policy options are: 
 * Transient,
 * Temporary,
 * Persistent
 * @param bucketKey		A unique name you assign to a bucket. It must be globally unique across 
 *                      all applications and regions, otherwise the call will fail. Possible 
 *                      values: -_.a-z0-9 (between 3-128 characters in length). Note that you cannot 
 *                      change a bucket key.
 * @param policy
 * @param region		The region where the bucket resides Acceptable values: US, EMEA Default: US
 * @return
 * @throws IOException
 * @throws URISyntaxException
 */
   public ResultCreateBucket bucketCreate(
	String bucketKey,
	String policy,
	String region
) 
    throws IOException, 
           URISyntaxException
{
   	String scope[] = { SCOPE_BUCKET_CREATE };
	ResultAuthentication authResult = authenticate( scope );
	if( authResult.isError() )
	{
		return new ResultCreateBucket( authResult );
	}
	
	JSONObject j_bucket = new JSONObject();
	j_bucket.put( KEY_BUCKETKEY, bucketKey.toLowerCase() );
	j_bucket.put( KEY_POLICY_KEY, policy );
	String jStr = j_bucket.toString();
	
	String frag = makeURN( API_OSS, PATT_BUCKET, null );

	URI uri = new URI( _protocol, null, lookupHostname(), _port, frag , null, null );

	URL url = new URL( uri.toASCIIString() );
	HttpURLConnection connection = (HttpURLConnection)url.openConnection();

	if( region != null && region.length() > 0 )
	{
		connection.setRequestProperty( "x-ads-region", region );
	}
	connection.setRequestMethod( "POST" );
	authResult.setAuthHeader( connection );
       connection.setRequestProperty( "Accept", "Application/json" );
	connection.setRequestProperty( "Content-Length", "" + jStr.length() );
	connection.setRequestProperty( "Content-Type", "application/json; charset=utf-8" );

	connection.setDoOutput( true );
       OutputStream os = null;
       try
       {
           os = connection.getOutputStream();
           os.write(jStr.getBytes(Charset.forName("UTF-8")));
       }
       finally
       {
       	if( os != null ) os.close();
       }
	
       ResultCreateBucket result = new ResultCreateBucket( connection );
	return result;
}
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:73,代码来源:DataRESTAPI.java

示例15: bucketGrantRightsV2

import java.net.URI; //导入方法依赖的package包/类
public Result bucketGrantRightsV2(
	String bucketKey,
	String serviceId,
	String access
) 
    throws IOException, 
           URISyntaxException
{
   	String scope[] = { SCOPE_BUCKET_UPDATE };
	ResultAuthentication authResult = authenticate( scope );
	if( authResult.isError() )
	{
		return authResult;
	}
	
	/*
	{
	  "allow":[
	       {"authId":"D6C9x7Bk0vo2HA1qC7l0VHM4MtYqZsN4","access":"full"}
	  ]
	}
	*/
	
	JSONObject j_rights = new JSONObject();
	j_rights.put( "authId", serviceId );
	j_rights.put( "access", access );
	JSONArray j_serviceList = new JSONArray();
	j_serviceList.add( j_rights );
	JSONObject j_grantRequest = new JSONObject();
	j_grantRequest.put( "allow", j_serviceList );
	
	String jStr = j_grantRequest.toString();
	
	String params[] = { bucketKey.toLowerCase() };
	String frag = makeURN( API_OSS, PATT_BUCKET_GRANT2, params );
	
	URI uri = new URI( _protocol, null, lookupHostname(), _port, frag , null, null );

	URL url = new URL( uri.toASCIIString() );
	HttpURLConnection connection = (HttpURLConnection)url.openConnection();

	connection.setRequestMethod( "POST" );
	authResult.setAuthHeader( connection );
       connection.setRequestProperty( "Accept", "Application/json" );
	connection.setRequestProperty( "Content-Length", "" + jStr.length() );
	connection.setRequestProperty( "Content-Type", "application/json; charset=utf-8" );

	connection.setDoOutput( true );
       OutputStream os = null;
       try
       {
           os = connection.getOutputStream();
           os.write(jStr.getBytes(Charset.forName("UTF-8")));
       }
       finally
       {
       	if( os != null ) os.close();
       }
	
	Result result = new Result( connection );
	return result;
}
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:63,代码来源:DataRESTAPI.java


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