本文整理汇总了Java中java.net.URI.getScheme方法的典型用法代码示例。如果您正苦于以下问题:Java URI.getScheme方法的具体用法?Java URI.getScheme怎么用?Java URI.getScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.URI
的用法示例。
在下文中一共展示了URI.getScheme方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newInstance
import java.net.URI; //导入方法依赖的package包/类
/** Returns the FileSystem for this URI's scheme and authority. The scheme
* of the URI determines a configuration property name,
* <tt>fs.<i>scheme</i>.class</tt> whose value names the FileSystem class.
* The entire URI is passed to the FileSystem instance's initialize method.
* This always returns a new FileSystem object.
*/
public static FileSystem newInstance(URI uri, Configuration conf) throws IOException {
String scheme = uri.getScheme();
String authority = uri.getAuthority();
if (scheme == null) { // no scheme: use default FS
return newInstance(conf);
}
if (authority == null) { // no authority
URI defaultUri = getDefaultUri(conf);
if (scheme.equals(defaultUri.getScheme()) // if scheme matches default
&& defaultUri.getAuthority() != null) { // & default has authority
return newInstance(defaultUri, conf); // return default
}
}
return CACHE.getUnique(uri, conf);
}
示例2: uriToPath
import java.net.URI; //导入方法依赖的package包/类
protected Path uriToPath(URI uri) {
String scheme = uri.getScheme();
if ((scheme == null) || !scheme.equalsIgnoreCase(getScheme())) {
throw new IllegalArgumentException("URI scheme is not '" + getScheme() + "'");
}
try {
// only support legacy JAR URL syntax jar:{uri}!/{entry} for now
String spec = uri.getRawSchemeSpecificPart();
int sep = spec.indexOf("!/");
if (sep != -1)
spec = spec.substring(0, sep);
return Paths.get(new URI(spec)).toAbsolutePath();
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
示例3: wrapReaders
import java.net.URI; //导入方法依赖的package包/类
private void wrapReaders()
{
Map/*<ModuleReference, ModuleReader>*/ moduleToReader = (Map)ReflectUtil.field( _loader, "moduleToReader" ).get();
for( Object mr: moduleToReader.keySet() )
{
//noinspection unchecked
Optional<URI> location = (Optional<URI>)ReflectUtil.method( mr, "location" ).invoke();
URI uri = location.orElse( null );
if( uri == null )
{
continue;
}
//## note: "jmod" files are not supported here because they are currently (2018) supported exclusively at compiler/linker time
String scheme = uri.getScheme();
if( scheme.equalsIgnoreCase( "file" ) || scheme.equalsIgnoreCase( "jar" ) )
{
Object reader = moduleToReader.get( mr );
Class<?> moduleReaderClass = ReflectUtil.type( "java.lang.module.ModuleReader" );
ManModuleReader wrapper = new ManModuleReader( reader, ReflectUtil.field( _loader, "ucp" ).get() );
Object/*ModuleReader*/ proxy = Proxy.newProxyInstance( moduleReaderClass.getClassLoader(), new Class<?>[]{moduleReaderClass},
new ManModuleReaderInvocationHandler( wrapper ) );
//noinspection unchecked
moduleToReader.put( mr, proxy );
}
}
}
示例4: expandAsGlob
import java.net.URI; //导入方法依赖的package包/类
/**
* Expand the given path as a glob pattern. Non-existent paths do not
* throw an exception because creation commands like touch and mkdir need
* to create them. The "stat" field will be null if the path does not
* exist.
* @param pattern the pattern to expand as a glob
* @param conf the hadoop configuration
* @return list of {@link PathData} objects. if the pattern is not a glob,
* and does not exist, the list will contain a single PathData with a null
* stat
* @throws IOException anything else goes wrong...
*/
public static PathData[] expandAsGlob(String pattern, Configuration conf)
throws IOException {
Path globPath = new Path(pattern);
FileSystem fs = globPath.getFileSystem(conf);
FileStatus[] stats = fs.globStatus(globPath);
PathData[] items = null;
if (stats == null) {
// remove any quoting in the glob pattern
pattern = pattern.replaceAll("\\\\(.)", "$1");
// not a glob & file not found, so add the path with a null stat
items = new PathData[]{ new PathData(fs, pattern, null) };
} else {
// figure out what type of glob path was given, will convert globbed
// paths to match the type to preserve relativity
PathType globType;
URI globUri = globPath.toUri();
if (globUri.getScheme() != null) {
globType = PathType.HAS_SCHEME;
} else if (!globUri.getPath().isEmpty() &&
new Path(globUri.getPath()).isAbsolute()) {
globType = PathType.SCHEMELESS_ABSOLUTE;
} else {
globType = PathType.RELATIVE;
}
// convert stats to PathData
items = new PathData[stats.length];
int i=0;
for (FileStatus stat : stats) {
URI matchUri = stat.getPath().toUri();
String globMatch = null;
switch (globType) {
case HAS_SCHEME: // use as-is, but remove authority if necessary
if (globUri.getAuthority() == null) {
matchUri = removeAuthority(matchUri);
}
globMatch = uriToString(matchUri, false);
break;
case SCHEMELESS_ABSOLUTE: // take just the uri's path
globMatch = matchUri.getPath();
break;
case RELATIVE: // make it relative to the current working dir
URI cwdUri = fs.getWorkingDirectory().toUri();
globMatch = relativize(cwdUri, matchUri, stat.isDirectory());
break;
}
items[i++] = new PathData(fs, globMatch, stat);
}
}
Arrays.sort(items);
return items;
}
示例5: getDownloadSdkButtonForManager
import java.net.URI; //导入方法依赖的package包/类
private Button getDownloadSdkButtonForManager() throws URISyntaxException, MalformedURLException {
SdkUtil sdkUtil = new SdkUtil();
Button downloadSdk = new Button(VmidcMessages.getString(VmidcMessages_.MAINTENANCE_MANAGERPLUGIN_DOWNLOAD_SDK));
URI currentLocation = UI.getCurrent().getPage().getLocation();
URI downloadLocation = new URI(currentLocation.getScheme(), null, currentLocation.getHost(),
currentLocation.getPort(), sdkUtil.getSdk(SdkUtil.sdkType.MANAGER), null, null);
FileDownloader downloader = new FileDownloader(new ExternalResource(downloadLocation.toURL().toString()));
downloader.extend(downloadSdk);
return downloadSdk;
}
示例6: createBaseUri
import java.net.URI; //导入方法依赖的package包/类
private URI createBaseUri(String serviceInfoUri) {
try {
URI basicAuthEncodedUri = URI.create(serviceInfoUri);
return new URI(basicAuthEncodedUri.getScheme(), basicAuthEncodedUri.getHost(),
basicAuthEncodedUri.getPath(), basicAuthEncodedUri.getFragment());
} catch (URISyntaxException x) {
throw new IllegalArgumentException(x.getMessage(), x);
}
}
示例7: Key
import java.net.URI; //导入方法依赖的package包/类
Key(URI uri, Configuration conf, long unique) throws IOException {
scheme = uri.getScheme()==null ?
"" : StringUtils.toLowerCase(uri.getScheme());
authority = uri.getAuthority()==null ?
"" : StringUtils.toLowerCase(uri.getAuthority());
this.unique = unique;
this.ugi = UserGroupInformation.getCurrentUser();
}
示例8: removeDotSegments
import java.net.URI; //导入方法依赖的package包/类
/**
* Removes dot segments according to RFC 3986, section 5.2.4
*
* @param uri the original URI
* @return the URI without dot segments
*/
private static URI removeDotSegments(URI uri) {
String path = uri.getPath();
if ((path == null) || (path.indexOf("/.") == -1)) {
// No dot segments to remove
return uri;
}
String[] inputSegments = path.split("/");
Stack<String> outputSegments = new Stack<String>();
for (int i = 0; i < inputSegments.length; i++) {
if ((inputSegments[i].length() == 0)
|| (".".equals(inputSegments[i]))) {
// Do nothing
} else if ("..".equals(inputSegments[i])) {
if (!outputSegments.isEmpty()) {
outputSegments.pop();
}
} else {
outputSegments.push(inputSegments[i]);
}
}
StringBuilder outputBuffer = new StringBuilder();
for (String outputSegment : outputSegments) {
outputBuffer.append('/').append(outputSegment);
}
try {
return new URI(uri.getScheme(), uri.getAuthority(),
outputBuffer.toString(), uri.getQuery(), uri.getFragment());
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e);
}
}
示例9: execute
import java.net.URI; //导入方法依赖的package包/类
public HttpResponse execute(final HttpUriRequest request, final HttpContext context)
throws IOException {
final URI uri = request.getURI();
final HttpHost httpHost = new HttpHost(uri.getHost(), uri.getPort(),
uri.getScheme());
return execute(httpHost, request, context);
}
示例10: getRequestString
import java.net.URI; //导入方法依赖的package包/类
/**
* Generate an HMAC request string.
* <p>
* This method trusts its inputs to be valid as per the MAC Authentication spec.
*
* @param request HTTP request.
* @param timestamp to use.
* @param nonce to use.
* @param extra to use.
* @return request string.
*/
protected static String getRequestString(HttpUriRequest request, long timestamp, String nonce, String extra) {
String method = request.getMethod().toUpperCase();
URI uri = request.getURI();
String host = uri.getHost();
String path = uri.getRawPath();
if (uri.getRawQuery() != null) {
path += "?";
path += uri.getRawQuery();
}
if (uri.getRawFragment() != null) {
path += "#";
path += uri.getRawFragment();
}
int port = uri.getPort();
String scheme = uri.getScheme();
if (port != -1) {
} else if ("http".equalsIgnoreCase(scheme)) {
port = 80;
} else if ("https".equalsIgnoreCase(scheme)) {
port = 443;
} else {
throw new IllegalArgumentException("Unsupported URI scheme: " + scheme + ".");
}
String requestString = timestamp + "\n" +
nonce + "\n" +
method + "\n" +
path + "\n" +
host + "\n" +
port + "\n" +
extra + "\n";
return requestString;
}
示例11: getPort
import java.net.URI; //导入方法依赖的package包/类
private static int getPort(URI uri){
switch(uri.getScheme()){
case "wss":
return 443;
case "ws":
return 80;
default:
throw new IllegalArgumentException();
}
}
示例12: urlFromSocket
import java.net.URI; //导入方法依赖的package包/类
private URI urlFromSocket(URI uri, ServerSocket serverSocket) throws Exception {
int listenPort = serverSocket.getLocalPort();
return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), listenPort, uri.getPath(), uri.getQuery(),
uri.getFragment());
}
示例13: joinURI
import java.net.URI; //导入方法依赖的package包/类
private static String joinURI(String baseURI, String relativeURI) throws URISyntaxException {
String bscheme = null;
String bauthority = null;
String bpath = "";
String bquery = null;
// pre-parse the baseURI
if (baseURI != null) {
if (baseURI.endsWith("..")) {
baseURI = baseURI + "/";
}
URI base = new URI(baseURI);
bscheme = base.getScheme();
bauthority = base.getAuthority();
bpath = base.getPath();
bquery = base.getQuery();
}
URI r = new URI(relativeURI);
String rscheme = r.getScheme();
String rauthority = r.getAuthority();
String rpath = r.getPath();
String rquery = r.getQuery();
String tscheme, tauthority, tpath, tquery;
if (rscheme != null && rscheme.equals(bscheme)) {
rscheme = null;
}
if (rscheme != null) {
tscheme = rscheme;
tauthority = rauthority;
tpath = removeDotSegments(rpath);
tquery = rquery;
} else {
if (rauthority != null) {
tauthority = rauthority;
tpath = removeDotSegments(rpath);
tquery = rquery;
} else {
if (rpath.length() == 0) {
tpath = bpath;
if (rquery != null) {
tquery = rquery;
} else {
tquery = bquery;
}
} else {
if (rpath.startsWith("/")) {
tpath = removeDotSegments(rpath);
} else {
if (bauthority != null && bpath.length() == 0) {
tpath = "/" + rpath;
} else {
int last = bpath.lastIndexOf('/');
if (last == -1) {
tpath = rpath;
} else {
tpath = bpath.substring(0, last+1) + rpath;
}
}
tpath = removeDotSegments(tpath);
}
tquery = rquery;
}
tauthority = bauthority;
}
tscheme = bscheme;
}
return new URI(tscheme, tauthority, tpath, tquery, null).toString();
}
示例14: isPhysicalFile
import java.net.URI; //导入方法依赖的package包/类
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean isPhysicalFile( JavaFileObject inputFile )
{
URI uri = inputFile.toUri();
return uri != null && uri.getScheme() != null && uri.getScheme().equalsIgnoreCase( "file" );
}
示例15: doExecute
import java.net.URI; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
final OIDCClientMetadata metadata = request.getOIDCClientMetadata();
if (metadata == null) {
log.warn("{} No client metadata found in the request", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
return;
}
final Set<URI> redirectURIs = metadata.getRedirectionURIs();
if (redirectURIs == null || redirectURIs.isEmpty()) {
log.warn("{} No redirection URIs found in the request", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OidcEventIds.MISSING_REDIRECT_URIS);
return;
}
final URI sectorIdUri = metadata.getSectorIDURI();
if (sectorIdUri != null) {
log.debug("{} Found sector_identifier_uri {}", getLogPrefix(), sectorIdUri);
if (!sectorIdUri.getScheme().equals("https")) {
log.warn("{} Invalid sector_identifier_uri scheme {}", getLogPrefix(), sectorIdUri.getScheme());
ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
return;
}
if (!verifySectorIdUri(sectorIdUri, redirectURIs)) {
log.warn("{} All redirect URIs are not found from sector_identifier_uri", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OidcEventIds.INVALID_REDIRECT_URIS);
return;
}
}
final ApplicationType applicationType = metadata.getApplicationType();
if (applicationType == null || applicationType.equals(ApplicationType.WEB)) {
final Set<GrantType> grantTypes = metadata.getGrantTypes();
// if implicit, only https
if (grantTypes != null && grantTypes.contains(GrantType.IMPLICIT)
&& !checkScheme(redirectURIs, "https")) {
log.warn("{} Only https-scheme is allowed for implicit flow", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OidcEventIds.INVALID_REDIRECT_URIS);
return;
}
// no localhost as the hostname
if (checkForbiddenHostname(redirectURIs, "localhost")) {
log.warn("{} localhost as the hostname in the redirect URI for a Web app", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OidcEventIds.INVALID_REDIRECT_URIS);
return;
}
} else {
// native application
// http://localhost or custom scheme
if (checkForbiddenScheme(redirectURIs, "https")) {
log.warn("{} https-scheme is not allowed for a native application", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OidcEventIds.INVALID_REDIRECT_URIS);
return;
}
for (final URI redirectUri : redirectURIs) {
final String scheme = redirectUri.getScheme();
if (scheme.equalsIgnoreCase("http") && !redirectUri.getHost().equalsIgnoreCase("localhost")) {
log.warn("{} http-scheme is only allowed to localhost for a native application", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OidcEventIds.INVALID_REDIRECT_URIS);
return;
}
log.debug("{} Accepting a redirect URI {} for a native application", getLogPrefix(), redirectUri);
}
}
//TODO: should the URIs be checked against black/white-lists?
log.debug("{} Redirect URIs ({}) checked", getLogPrefix(), redirectURIs.size());
}