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


Java URI.getPath方法代码示例

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


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

示例1: relativize

import java.net.URI; //导入方法依赖的package包/类
private static String relativize(URI cwdUri, URI srcUri, boolean isDir) {
  String uriPath = srcUri.getPath();
  String cwdPath = cwdUri.getPath();
  if (cwdPath.equals(uriPath)) {
    return Path.CUR_DIR;
  }

  // find common ancestor
  int lastSep = findLongestDirPrefix(cwdPath, uriPath, isDir);
  
  StringBuilder relPath = new StringBuilder();    
  // take the remaining path fragment after the ancestor
  if (lastSep < uriPath.length()) {
    relPath.append(uriPath.substring(lastSep+1));
  }

  // if cwd has a path fragment after the ancestor, convert them to ".."
  if (lastSep < cwdPath.length()) {
    while (lastSep != -1) {
      if (relPath.length() != 0) relPath.insert(0, Path.SEPARATOR);
      relPath.insert(0, "..");
      lastSep = cwdPath.indexOf(Path.SEPARATOR, lastSep+1);
    }
  }
  return relPath.toString();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:PathData.java

示例2: performCommand

import java.net.URI; //导入方法依赖的package包/类
@Override
public boolean performCommand(ConsoleInput ci, DownloadManager dm, List args)
{
	if (args.isEmpty()) {
		ci.out.println("> Command 'hack': Not enough parameters for subcommand parameter 'port'.");
		return false;
	}
	TRTrackerAnnouncer client = dm.getTrackerClient();
	try {
		URI uold = new URI(client.getTrackerURL().toString());
		String portStr = (String) args.get(0);
		URI unew = new URI(uold.getScheme(), uold.getUserInfo(), uold.getHost(), Integer.parseInt(portStr), uold.getPath(), uold.getQuery(), uold.getFragment());
		client.setTrackerURL(new URL(unew.toString()));
		ci.out.println("> Set Tracker URL for '"+dm.getSaveLocation()+"' to '"+unew.toString()+"'");
	} catch (Exception e) {
		ci.out.println("> Command 'hack': Assembling new tracker url failed: "+e.getMessage());
		return false;
	}
	return true;
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:21,代码来源:Hack.java

示例3: setNextPage

import java.net.URI; //导入方法依赖的package包/类
protected void setNextPage() throws Exception {
	String url = driver.getCurrentUrl();
	URI url2 = new URI(url);
	url = url2.getPath();
	AbstractPage x = mapper.get(url);
	if(x != null){
		if(!x.equals(currentPage)){
			this.completePendingAsyncTasks();
		}
	} else {
		x = PageObjectFactory.getInstance(url);
		this.addPageObject(x);
	}
	currentPage.transferControlTo(x);
	currentPage = x;
	Assert.assertNotNull(currentPage, "No Page Object found for " + url);
	currentPage.map(currentPage);
}
 
开发者ID:saiscode,项目名称:kheera,代码行数:19,代码来源:TestExecutionController.java

示例4: setServiceURL

import java.net.URI; //导入方法依赖的package包/类
/**
 * Set the service URL to make requests against.
 *
 * This can either be just the host name or can include the full path to the service.
 *
 * @param serviceUrl URL to make requests against
 */
public void setServiceURL(String serviceUrl) {
    try {
        URI fullURI = URI.create(serviceUrl);
        URI partialURI = new URI(fullURI.getScheme(), null, fullURI.getHost(),
            fullURI.getPort(), null, null, null);
        cc.setEndpoint(partialURI);
        String path = fullURI.getPath();
        if (path != null) {
            path = path.substring(path.startsWith("/") ? 1 : 0);
            path = path.substring(0, path.length() - (path.endsWith("/") ? 1 : 0));
        }
        if (path == null || path.isEmpty()) {
            this.servicePath = DEFAULT_SERVICE_PATH;
        } else {
            this.servicePath = path;
        }
    } catch (Exception e) {
        throw MwsUtl.wrap(e);
    }
}
 
开发者ID:trifonnt,项目名称:ext-lib-amazon-mws-fulfillment-inbound-shipment,代码行数:28,代码来源:FBAInboundServiceMWSConfig.java

示例5: uriToCommandArray

import java.net.URI; //导入方法依赖的package包/类
private static String[] uriToCommandArray(URI uri) {
	String command = uri.getPath();
	List<String> args = Strings.split(uri.getQuery(), '&', -1);
	String[] commandArray = new String[args.size() + 1];
	commandArray[0] = command;
	for (int i = 1; i < commandArray.length; ++i)
		commandArray[i] = args.get(i - 1);
	return commandArray;
}
 
开发者ID:Bibliome,项目名称:bibliome-java-utils,代码行数:10,代码来源:StreamFactory.java

示例6: createServiceInfo

import java.net.URI; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */

@Override
public FeatureFlagsServiceInfo createServiceInfo(Map<String, Object> serviceData) {
	String id = getId(serviceData);
	Map<String, Object> credentials = getCredentials(serviceData);
	URI url = URI.create(getUriFromCredentials(credentials));
	String username = (String) credentials.get(USERNAME);
	String password = (String) credentials.get(PASSWORD);

	return new FeatureFlagsServiceInfo(id, url.getHost(), url.getPort(), username, password, url.getPath());
}
 
开发者ID:SAP,项目名称:cloud-cf-feature-flags-sample,代码行数:15,代码来源:FeatureFlagsServiceInfoCreator.java

示例7: checkUri

import java.net.URI; //导入方法依赖的package包/类
private void checkUri(URI uri) {
    if (!uri.getScheme().equalsIgnoreCase(getScheme()))
        throw new IllegalArgumentException("URI does not match this provider");
    if (uri.getAuthority() != null)
        throw new IllegalArgumentException("Authority component present");
    if (uri.getPath() == null)
        throw new IllegalArgumentException("Path component is undefined");
    if (!uri.getPath().equals("/"))
        throw new IllegalArgumentException("Path component should be '/'");
    if (uri.getQuery() != null)
        throw new IllegalArgumentException("Query component present");
    if (uri.getFragment() != null)
        throw new IllegalArgumentException("Fragment component present");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:WindowsFileSystemProvider.java

示例8: ChRootedFileSystem

import java.net.URI; //导入方法依赖的package包/类
/**
 * Constructor
 * @param uri base file system
 * @param conf configuration
 * @throws IOException 
 */
public ChRootedFileSystem(final URI uri, Configuration conf)
    throws IOException {
  super(FileSystem.get(uri, conf));
  String pathString = uri.getPath();
  if (pathString.isEmpty()) {
    pathString = "/";
  }
  chRootPathPart = new Path(pathString);
  chRootPathPartString = chRootPathPart.toUri().getPath();
  myUri = uri;
  workingDir = getHomeDirectory();
  // We don't use the wd of the myFs
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:ChRootedFileSystem.java

示例9: get

import java.net.URI; //导入方法依赖的package包/类
@Override
public RESTResource get(URI uri, Map<String, String> parameters) throws RESTException {
  
	RESTResource resource = new RESTResource(name(uri), this);
	resource.contentType = "application/json";
	resource.content = "[";
	
	Set<String> vocabs = new HashSet<String>();
	
	// Return all TDs
	try {
		vocabs = VocabularyUtils.listVocabularies();
	} catch (Exception e) {
		throw new BadRequestException();
	}
	
	Iterator<String> it = vocabs.iterator();
	while (it.hasNext()) {
		String vocab = it.next();
		URI vocabUri = URI.create(vocab);
		resource.content += "\"" + vocabUri.getPath() + "\"";
		if (it.hasNext()) {
			resource.content += ",";
		}
	}
	
	resource.content += "]";
	return resource;
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:30,代码来源:VocabularyCollectionHandler.java

示例10: getPathAndQuery

import java.net.URI; //导入方法依赖的package包/类
private String getPathAndQuery(URI uri) {
    String path = uri.getPath();
    String query = uri.getQuery();
    if (path == null || path.equals("")) {
        path = "/";
    }
    if (query == null) {
        query = "";
    }
    if (query.equals("")) {
        return path;
    } else {
        return path + "?" + query;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:Http1Request.java

示例11: safeUri

import java.net.URI; //导入方法依赖的package包/类
/**
 * Create a safe URI from the given one by stripping out user info.
 *
 * @param uri Original URI
 * @return a new URI with no user info
 */
private static URI safeUri(URI uri) {
    try {
        return new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
    } catch (URISyntaxException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:14,代码来源:HttpBuildCache.java

示例12: getEncodeRequestSize

import java.net.URI; //导入方法依赖的package包/类
private int getEncodeRequestSize(URI requestURI, String[] names, String[] values) {
    int size = 0;

    // Encode Request line
    size += GET_BYTES.length;
    size += SPACE_BYTES.length;
    String path = requestURI.getPath();
    if (requestURI.getQuery() != null) {
        path += "?" + requestURI.getQuery();
    }
    size += path.getBytes().length;
    size += SPACE_BYTES.length;
    size += HTTP_1_1_BYTES.length;
    size += CRLF_BYTES.length;

    // Encode headers
    for (int i = 0; i < names.length; i++) {
        String headerName = names[i];
        String headerValue = values[i];
        if (headerName != null && headerValue != null) {
            size += headerName.getBytes().length;
            size += COLON_BYTES.length;
            size += SPACE_BYTES.length;
            size += headerValue.getBytes().length;
            size += CRLF_BYTES.length;
        }
    }

    size += CRLF_BYTES.length;

    LOG.fine("Returning a request size of " + size);
    return size;
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:34,代码来源:WebSocketDelegateImpl.java

示例13: getServerPath

import java.net.URI; //导入方法依赖的package包/类
private static String getServerPath(URI serverUrl) {
    String path = serverUrl.getPath();
    int endIndex = path.lastIndexOf("/");
    if (endIndex == -1 ) {
        return path;
    } else if (endIndex == 0) {
        return path.substring(1);
    } else {
        return path.substring(1, endIndex); // Also strip leading /
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SyncConfiguration.java

示例14: name

import java.net.URI; //导入方法依赖的package包/类
private String name(URI uri) {
	
	String path = uri.getPath();
	if (path.contains("/")) {
		return path.substring(uri.getPath().lastIndexOf("/") + 1);
	}
	return path;
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:9,代码来源:TDLookUpSEMHandler.java

示例15: createSocketAddr

import java.net.URI; //导入方法依赖的package包/类
/**
 * Create an InetSocketAddress from the given target string and
 * default port. If the string cannot be parsed correctly, the
 * <code>configName</code> parameter is used as part of the
 * exception message, allowing the user to better diagnose
 * the misconfiguration.
 *
 * @param target a string of either "host" or "host:port"
 * @param defaultPort the default port if <code>target</code> does not
 *                    include a port number
 * @param configName the name of the configuration from which
 *                   <code>target</code> was loaded. This is used in the
 *                   exception message in the case that parsing fails. 
 */
public static InetSocketAddress createSocketAddr(String target,
                                                 int defaultPort,
                                                 String configName) {
  String helpText = "";
  if (configName != null) {
    helpText = " (configuration property '" + configName + "')";
  }
  if (target == null) {
    throw new IllegalArgumentException("Target address cannot be null." +
        helpText);
  }
  target = target.trim();
  boolean hasScheme = target.contains("://");    
  URI uri = null;
  try {
    uri = hasScheme ? URI.create(target) : URI.create("dummyscheme://"+target);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException(
        "Does not contain a valid host:port authority: " + target + helpText
    );
  }

  String host = uri.getHost();
  int port = uri.getPort();
  if (port == -1) {
    port = defaultPort;
  }
  String path = uri.getPath();
  
  if ((host == null) || (port < 0) ||
      (!hasScheme && path != null && !path.isEmpty()))
  {
    throw new IllegalArgumentException(
        "Does not contain a valid host:port authority: " + target + helpText
    );
  }
  return createSocketAddrForHost(host, port);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:53,代码来源:NetUtils.java


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