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


Java URI.getFragment方法代码示例

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


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

示例1: ServletURI

import java.net.URI; //导入方法依赖的package包/类
public ServletURI(String rawPath) throws URISyntaxException {
    if (rawPath == null || rawPath.isEmpty() || "/".equals(rawPath)) {
        path = "/";
    } else {
        URI uri = new URI(rawPath);
        path = uri.getPath();
        if (path == null || path.isEmpty()) {
            path = "/";
        } else if (path.charAt(0) != '/') {
            path += "/" + path;
        }

        fragement = uri.getFragment();
        query = uri.getQuery();
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:17,代码来源:ServletURI.java

示例2: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:JrtFileSystemProvider.java

示例3: AuthenticatedSseEventSourceImpl

import java.net.URI; //导入方法依赖的package包/类
public AuthenticatedSseEventSourceImpl(URI location, ParticleCloud cloud) {
    super(location);
    this.cloud = cloud;

    URI loc = location;

    // Map "sse" to "http".
    if (location.getScheme().equalsIgnoreCase("sse")) {
        String fragment = location.getFragment();
        String schemeSpecificPart = location.getSchemeSpecificPart();

        if (fragment == null) {
            fragment = "";
        }
        loc = URI.create("http:" + schemeSpecificPart + fragment);
    }

    _location = loc;
    _readyState = ReadyState.CLOSED;

    // Used by the producer(i.e. the eventSourceListener) and the
    // consumer(i.e. the SseEventReader).
    _sharedQueue = new BlockingQueueImpl<>();
    _eventReader = new SseEventReaderImpl(this, _sharedQueue);
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:26,代码来源:AuthenticatedSseEventSourceImpl.java

示例4: reconstructAuthorityIfNeeded

import java.net.URI; //导入方法依赖的package包/类
/**
 * Puts in the authority of the default file system if it is a WASB file
 * system and the given URI's authority is null.
 * 
 * @return The URI with reconstructed authority if necessary and possible.
 */
private static URI reconstructAuthorityIfNeeded(URI uri, Configuration conf) {
  if (null == uri.getAuthority()) {
    // If WASB is the default file system, get the authority from there
    URI defaultUri = FileSystem.getDefaultUri(conf);
    if (defaultUri != null && isWasbScheme(defaultUri.getScheme())) {
      try {
        // Reconstruct the URI with the authority from the default URI.
        return new URI(uri.getScheme(), defaultUri.getAuthority(),
            uri.getPath(), uri.getQuery(), uri.getFragment());
      } catch (URISyntaxException e) {
        // This should never happen.
        throw new Error("Bad URI construction", e);
      }
    }
  }
  return uri;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:NativeAzureFileSystem.java

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

示例6: SseEventSourceImpl

import java.net.URI; //导入方法依赖的package包/类
public SseEventSourceImpl(URI location) {
    URI    loc = location;
    
    // Map "sse" to "http".
    if (location.getScheme().equalsIgnoreCase("sse")) {
        String fragment = location.getFragment();
        String schemeSpecificPart = location.getSchemeSpecificPart();
        
        if (fragment == null) {
            fragment = "";
        }
        loc = URI.create("http:" + schemeSpecificPart + fragment);
    }
    
    _location = loc;
    _readyState = ReadyState.CLOSED;
    
    // Used by the producer(i.e. the eventSourceListener) and the 
    // consumer(i.e. the SseEventReader).
    _sharedQueue = new BlockingQueueImpl<Object>();

}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:23,代码来源:SseEventSourceImpl.java

示例7: toAmazonS3URI

import java.net.URI; //导入方法依赖的package包/类
public static AmazonS3URI toAmazonS3URI(URI uri) {
  if (FS_PROTOCOL_S3.equalsIgnoreCase(uri.getScheme())) {
    return new AmazonS3URI(uri);
  } else if (S3Schemes.isS3Scheme(uri.getScheme())) {
    try {
      return new AmazonS3URI(new URI(FS_PROTOCOL_S3, uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(),
          uri.getQuery(), uri.getFragment()));
    } catch (URISyntaxException e) {
      // ignore it, it will fail on the return
    }
  }
  // Build it anyway we'll get AmazonS3URI exception back.
  return new AmazonS3URI(uri);
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:15,代码来源:AmazonS3URIs.java

示例8: 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,代码来源:UnixFileSystemProvider.java

示例9: parseDistributedCacheArtifacts

import java.net.URI; //导入方法依赖的package包/类
private static void parseDistributedCacheArtifacts(Configuration conf,
    Map<String, LocalResource> localResources, LocalResourceType type, URI[] uris,
    long[] timestamps, long[] sizes, boolean visibilities[]) throws IOException {

  if (uris != null) {
    // Sanity check
    if ((uris.length != timestamps.length) || (uris.length != sizes.length)
        || (uris.length != visibilities.length)) {
      throw new IllegalArgumentException("Invalid specification for "
          + "distributed-cache artifacts of type " + type + " :" + " #uris=" + uris.length
          + " #timestamps=" + timestamps.length + " #visibilities=" + visibilities.length);
    }

    for (int i = 0; i < uris.length; ++i) {
      URI u = uris[i];
      Path p = new Path(u);
      FileSystem remoteFS = p.getFileSystem(conf);
      p =
          remoteFS
              .resolvePath(p.makeQualified(remoteFS.getUri(), remoteFS.getWorkingDirectory()));
      // Add URI fragment or just the filename
      Path name = new Path((null == u.getFragment()) ? p.getName() : u.getFragment());
      if (name.isAbsolute()) {
        throw new IllegalArgumentException("Resource name must be relative");
      }
      String linkName = name.toUri().getPath();
      LocalResource orig = localResources.get(linkName);
      org.apache.hadoop.yarn.api.records.URL url = ConverterUtils.getYarnUrlFromURI(p.toUri());
      if (orig != null && !orig.getResource().equals(url)) {
        LOG.warn(getResourceDescription(orig.getType()) + toString(orig.getResource())
            + " conflicts with " + getResourceDescription(type) + toString(url)
            + " This will be an error in Hadoop 2.0");
        continue;
      }
      localResources.put(linkName, LocalResource.newInstance(ConverterUtils.getYarnUrlFromURI(p
          .toUri()), type, visibilities[i] ? LocalResourceVisibility.PUBLIC
          : LocalResourceVisibility.PRIVATE, sizes[i], timestamps[i]));
    }
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:41,代码来源:AngelApps.java

示例10: fromServer

import java.net.URI; //导入方法依赖的package包/类
/**
 * Convert given server URL into project's file.
 * @param projectContext see {@link #CONTEXT_PROJECT_SOURCES} and {@link #CONTEXT_PROJECT_TESTS};
 *   it is very unlikely that server URL could be translated into two different sources
 *   but for API parity with toServer the context param is available here as well
 * @return returns null if nothing is known about this server URL
 */
public static FileObject fromServer(Project p, int projectContext, URL serverURL) {
    Parameters.notNull("project", p); //NOI18N
    Parameters.notNull("serverURL", serverURL); //NOI18N
    ServerURLMappingImplementation impl = p.getLookup().lookup(ServerURLMappingImplementation.class);
    if (impl != null) {
        FileObject fo = impl.fromServer(projectContext, serverURL);
        if (fo != null) {
            return fo;
        }
    }
    if ("file".equals(serverURL.getProtocol())) { //NOI18N
        try {
            URI serverURI = serverURL.toURI();
            if (serverURI.getQuery() != null || serverURI.getFragment() != null) {
                // #236532 - strip down query part from the URL:
                serverURI = WebUtils.stringToUrl(WebUtils.urlToString(serverURL, true)).toURI();
            }
            File f = FileUtil.normalizeFile(BaseUtilities.toFile(serverURI));
            return FileUtil.toFileObject(f);
            //FileObject fo = URLMapper.findFileObject(serverURL);
        } catch (URISyntaxException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:ServerURLMapping.java

示例11: nestURIForLocalJavaKeyStoreProvider

import java.net.URI; //导入方法依赖的package包/类
/**
 * Mangle given local java keystore file URI to allow use as a
 * LocalJavaKeyStoreProvider.
 * @param localFile absolute URI with file scheme and no authority component.
 *                  i.e. return of File.toURI,
 *                  e.g. file:///home/larry/creds.jceks
 * @return URI of the form localjceks://file/home/larry/creds.jceks
 * @throws IllegalArgumentException if localFile isn't not a file uri or if it
 *                                  has an authority component.
 * @throws URISyntaxException if the wrapping process violates RFC 2396
 */
public static URI nestURIForLocalJavaKeyStoreProvider(final URI localFile)
    throws URISyntaxException {
  if (!("file".equals(localFile.getScheme()))) {
    throw new IllegalArgumentException("passed URI had a scheme other than " +
        "file.");
  }
  if (localFile.getAuthority() != null) {
    throw new IllegalArgumentException("passed URI must not have an " +
        "authority component. For non-local keystores, please use " +
        JavaKeyStoreProvider.class.getName());
  }
  return new URI(LocalJavaKeyStoreProvider.SCHEME_NAME,
      "//file" + localFile.getSchemeSpecificPart(), localFile.getFragment());
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:26,代码来源:ProviderUtils.java

示例12: request

import java.net.URI; //导入方法依赖的package包/类
/**
 * The request to send.
 * @param req Original request
 * @param uri Destination URI
 * @return Request
 */
private static Request request(final Request req, final URI uri) {
    final StringBuilder path = new StringBuilder(0);
    path.append(uri.getRawPath());
    if (path.length() == 0) {
        path.append('/');
    }
    if (uri.getQuery() != null) {
        path.append('?').append(uri.getRawQuery());
    }
    if (uri.getFragment() != null) {
        path.append('#').append(uri.getRawFragment());
    }
    return new Request() {
        @Override
        public Iterable<String> head() throws IOException {
            return new Concat<>(
                Collections.singleton(
                    String.format(
                        "%s %s HTTP/1.1",
                        new RqMethod.Base(req).method(),
                        path
                    )
                ),
                new Skipped<>(req.head(), 1)
            );
        }
        @Override
        public InputStream body() throws IOException {
            return req.body();
        }
    };
}
 
开发者ID:yegor256,项目名称:rehttp,代码行数:39,代码来源:DyTake.java

示例13: replacePath

import java.net.URI; //导入方法依赖的package包/类
public static URI replacePath(URI uri, String path) {
    try {
        return new URI(uri.getScheme(), uri.getAuthority(), path, uri.getQuery(), uri.getFragment());
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("Invalid URI/Scheme: replacing path with '"+path+"' for "+uri);
    }
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:8,代码来源:URIUtils.java

示例14: getUrl

import java.net.URI; //导入方法依赖的package包/类
public String getUrl() {
    try {
        URI o = new URI(this.url);
        URI injected = new URI("http", null, o.getHost(), reverseProxy.getPortForUrl(this.url),
                o.getPath(), o.getQuery(), o.getFragment());
        return injected.toString();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:Kroger-Technology,项目名称:Snow-Globe,代码行数:11,代码来源:TestRequest.java

示例15: removePort

import java.net.URI; //导入方法依赖的package包/类
private URI removePort(URI uri) throws StatusException {
    try {
        return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), -1 /* port */,
                uri.getPath(), uri.getQuery(), uri.getFragment());
    } catch (URISyntaxException e) {
        throw Status.UNAUTHENTICATED
                .withDescription("Unable to construct service URI after removing port")
                .withCause(e).asException();
    }
}
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:11,代码来源:GoogleCredentialsInterceptor.java


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