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


Java URI.getSchemeSpecificPart方法代码示例

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


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

示例1: execute

import java.net.URI; //导入方法依赖的package包/类
/**
 * Executes the task.
 */
public void execute() throws BuildException {
    try {
        final URI uri = new URI(uriString);
        
        String path = uri.getSchemeSpecificPart();
        while (path.startsWith("/")) { // NOI18N
            path = path.substring(1);
        }
        
        if (uri.getScheme().equals("file")) {
            path = "local/" + path;
        }
        path = path.replace(":", "_").replace("*", "_");
        getProject().setProperty(property, path);
    } catch (URISyntaxException e) {
        throw new BuildException("Cannot parse URI.",e); // NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:UriToPath.java

示例2: uriToString

import java.net.URI; //导入方法依赖的package包/类
private static String uriToString(URI uri, boolean inferredSchemeFromPath) {
  String scheme = uri.getScheme();
  // No interpretation of symbols. Just decode % escaped chars.
  String decodedRemainder = uri.getSchemeSpecificPart();

  // Drop the scheme if it was inferred to ensure fidelity between
  // the input and output path strings.
  if ((scheme == null) || (inferredSchemeFromPath)) {
    if (Path.isWindowsAbsolutePath(decodedRemainder, true)) {
      // Strip the leading '/' added in stringToUri so users see a valid
      // Windows path.
      decodedRemainder = decodedRemainder.substring(1);
    }
    return decodedRemainder;
  } else {
    StringBuilder buffer = new StringBuilder();
    buffer.append(scheme);
    buffer.append(":");
    buffer.append(decodedRemainder);
    return buffer.toString();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:23,代码来源:PathData.java

示例3: getLocalName

import java.net.URI; //导入方法依赖的package包/类
private String getLocalName(String uri) {
    String localName = null;
    try {
        URI u = new URI(uri);
        localName = u.getSchemeSpecificPart();
    } catch (URISyntaxException ex) {
    }
    return localName;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:KeyRefImpl.java

示例4: contains

import java.net.URI; //导入方法依赖的package包/类
private boolean contains(Collection<Path> searchPath, Path file) throws IOException {

        if (searchPath == null) {
            return false;
        }

        Path enclosingJar = null;
        if (file.getFileSystem().provider() == fsInfo.getJarFSProvider()) {
            URI uri = file.toUri();
            if (uri.getScheme().equals("jar")) {
                String ssp = uri.getSchemeSpecificPart();
                int sep = ssp.lastIndexOf("!");
                if (ssp.startsWith("file:") && sep > 0) {
                    enclosingJar = Paths.get(URI.create(ssp.substring(0, sep)));
                }
            }
        }

        Path nf = normalize(file);
        for (Path p : searchPath) {
            Path np = normalize(p);
            if (np.getFileSystem() == nf.getFileSystem()
                    && Files.isDirectory(np)
                    && nf.startsWith(np)) {
                return true;
            }
            if (enclosingJar != null
                    && Files.isSameFile(enclosingJar, np)) {
                return true;
            }
        }

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

示例5: getPath

import java.net.URI; //导入方法依赖的package包/类
@Override
public Path getPath(URI uri) {
    String spec = uri.getSchemeSpecificPart();
    int sep = spec.indexOf("!/");
    if (sep == -1)
        throw new IllegalArgumentException("URI: "
            + uri
            + " does not contain path info ex. jar:file:/c:/foo.zip!/BAR");
    return getFileSystem(uri).getPath(spec.substring(sep + 1));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ZipFileSystemProvider.java

示例6: fix

import java.net.URI; //导入方法依赖的package包/类
/**
 * Eventually recreates the given URI to work around
 * <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7198297">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7198297</a>:
 * <pre>
 * {@code assert null == new URI("x/").resolve("..").getSchemeSpecificPart();}
 * </pre>
 *
 * @param  uri the URI to fix.
 * @return A fixed URI or {@code uri} if it doesn't need fixing.
 */
static URI fix(final URI uri) {
    final String ssp = uri.getSchemeSpecificPart();
    final String a = uri.getAuthority();
    // Workaround for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7198297 :
    // assert null == new URI("foo/").resolve(new URI("..")).getRawSchemeSpecificPart();
    if (null == ssp
            || null == a && ssp.startsWith(SEPARATOR + SEPARATOR)) // empty authority
        return new UriBuilder(uri).toUri();
    return uri;
}
 
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:21,代码来源:TUriHelper.java

示例7: normalizePercentEncoding

import java.net.URI; //导入方法依赖的package包/类
public void normalizePercentEncoding() {
    try {
        uri = new URI(uri.getScheme(), 
                      uri.getSchemeSpecificPart(), 
                      uri.getFragment());
    } catch (URISyntaxException e) {
        // This should never be reached
        e.printStackTrace();
    }
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:11,代码来源:NormalizedURL.java

示例8: getPath

import java.net.URI; //导入方法依赖的package包/类
@Override
public Path getPath(URI uri) {
    checkScheme(uri);
    if (delegate == null)
        throw new FileSystemNotFoundException();

    // only allow absolute path
    String path = uri.getSchemeSpecificPart();
    if (! path.startsWith("///")) {
        throw new IllegalArgumentException();
    }
    return new PassThroughFileSystem.PassThroughPath(delegate, delegate.root.resolve(path.substring(3)));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:FaultyFileSystem.java

示例9: loadFile

import java.net.URI; //导入方法依赖的package包/类
/** Obtiene el flujo de entrada de un fichero (para su lectura) a partir de su URI.
 * @param uri URI del fichero a leer
 * @return Flujo de entrada hacia el contenido del fichero
 * @throws IOException Cuando no se ha podido abrir el fichero de datos. */
public static InputStream loadFile(final URI uri) throws IOException {

    if (uri == null) {
        throw new IllegalArgumentException("Se ha pedido el contenido de una URI nula"); //$NON-NLS-1$
    }

    if (uri.getScheme().equals("file")) { //$NON-NLS-1$
        // Es un fichero en disco. Las URL de Java no soportan file://, con
        // lo que hay que diferenciarlo a mano

        // Retiramos el "file://" de la uri
        String path = uri.getSchemeSpecificPart();
        if (path.startsWith("//")) { //$NON-NLS-1$
            path = path.substring(2);
        }
        return new FileInputStream(new File(path));
    }

    // Es una URL
    final InputStream tmpStream = new BufferedInputStream(uri.toURL().openStream());

    // Las firmas via URL fallan en la descarga por temas de Sun, asi que
    // descargamos primero
    // y devolvemos un Stream contra un array de bytes
    final byte[] tmpBuffer = getDataFromInputStream(tmpStream);

    return new java.io.ByteArrayInputStream(tmpBuffer);
}
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:33,代码来源:AOUtil.java

示例10: _getSpecURI

import java.net.URI; //导入方法依赖的package包/类
private URI _getSpecURI(String spec) {
    URI specURI = URI.create(spec);

    if (_scheme.indexOf(':') == -1) {
        return specURI;
    }
    
    String schemeSpecificPart = specURI.getSchemeSpecificPart();
    return URI.create(schemeSpecificPart);
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:11,代码来源:SseURLStreamHandlerImpl.java

示例11: getSimpleName

import java.net.URI; //导入方法依赖的package包/类
/** Return the last component of a presumed hierarchical URI.
 *  From the scheme specific part of the URI, it returns the substring
 *  after the last "/" if any, or everything if no "/" is found.
 */
public static String getSimpleName(FileObject fo) {
    URI uri = fo.toUri();
    String s = uri.getSchemeSpecificPart();
    return s.substring(s.lastIndexOf("/") + 1); // safe when / not found

}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:11,代码来源:BaseFileObject.java

示例12: FontResource

import java.net.URI; //导入方法依赖的package包/类
/**
 * Do not use directly.
 *
 * @param resourceLocator The {@code URI} used when loading this
 *     resource.
 * @exception IOException if unable to read the font.
 */
public FontResource(URI resourceLocator) throws IOException {
    super(resourceLocator);
    font = null;
    try {
        if (resourceLocator.getPath() != null
            && resourceLocator.getPath().endsWith(".ttf")) {
            URL url = resourceLocator.toURL();
            font = Font.createFont(Font.TRUETYPE_FONT, url.openStream());
        } else {
            String name = resourceLocator.getSchemeSpecificPart();
            font = Font.decode(name.substring(SCHEME.length()));
        }

        if (font != null) {
            GraphicsEnvironment.getLocalGraphicsEnvironment()
                .registerFont(font);
        }

        logger.info("Loaded font: " + font.getFontName()
            + " from: " + resourceLocator);
    } catch (FontFormatException|IOException ex) {
        logger.log(Level.WARNING,
            "Failed loading font from: " + resourceLocator, ex);
        throw new IOException(ex.getMessage());
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:34,代码来源:FontResource.java

示例13: getPath

import java.net.URI; //导入方法依赖的package包/类
@Override
public Path getPath(URI uri) {

    String spec = uri.getSchemeSpecificPart();
    int sep = spec.indexOf("!/");
    if (sep == -1)
        throw new IllegalArgumentException("URI: "
            + uri
            + " does not contain path info ex. jar:file:/c:/foo.zip!/BAR");
    return getFileSystem(uri).getPath(spec.substring(sep + 1));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:ZipFileSystemProvider.java

示例14: getResolvedEntity

import java.net.URI; //导入方法依赖的package包/类
@Override
public String getResolvedEntity(String publicId, String systemId) {
	getLog().debug(
			MessageFormat.format(
					"Resolving publicId [{0}], systemId [{1}].", publicId,
					systemId));
	final String superResolvedEntity = super.getResolvedEntity(publicId,
			systemId);
	getLog().debug(
			MessageFormat
					.format("Parent resolver has resolved publicId [{0}], systemId [{1}] to [{2}].",
							publicId, systemId, superResolvedEntity));
	if (superResolvedEntity != null) {
		systemId = superResolvedEntity;
	}

	if (systemId == null) {
		return null;
	}

	try {
		final URI uri = new URI(systemId);
		if (URI_SCHEME_MAVEN.equals(uri.getScheme())) {
			getLog().debug(
					MessageFormat
							.format("Resolving systemId [{1}] as Maven dependency resource.",
									publicId, systemId));
			final String schemeSpecificPart = uri.getSchemeSpecificPart();
			try {
				final DependencyResource dependencyResource = DependencyResource
						.valueOf(schemeSpecificPart);
				try {
					final URL url = dependencyResourceResolver
							.resolveDependencyResource(dependencyResource);
					String resolved = url.toString();
					getLog().debug(
							MessageFormat.format(
									"Resolved systemId [{1}] to [{2}].",
									publicId, systemId, resolved));
					return resolved;
				} catch (Exception ex) {
					getLog().error(
							MessageFormat
									.format("Error resolving dependency resource [{0}].",
											dependencyResource));
				}
			} catch (IllegalArgumentException iaex) {
				getLog().error(
						MessageFormat
								.format("Error parsing dependency descriptor [{0}].",
										schemeSpecificPart));

			}
			getLog().error(
					MessageFormat
							.format("Failed to resolve systemId [{1}] as dependency resource. "
											+ "Returning parent resolver result [{2}].",
									publicId, systemId, superResolvedEntity));
			return superResolvedEntity;
		} else {
			getLog().debug(
					MessageFormat
							.format("SystemId [{1}] is not a Maven dependency resource URI. "
											+ "Returning parent resolver result [{2}].",
									publicId, systemId, superResolvedEntity));
			return superResolvedEntity;
		}
	} catch (URISyntaxException urisex) {
		getLog().debug(
				MessageFormat
						.format("Coul not parse the systemId [{1}] as URI. "
										+ "Returning parent resolver result [{2}].",
								publicId, systemId, superResolvedEntity));
		return superResolvedEntity;
	}
}
 
开发者ID:CodeFX-org,项目名称:java-9-wtf,代码行数:77,代码来源:MavenCatalogResolver.java

示例15: getOsAppropriatePath

import java.net.URI; //导入方法依赖的package包/类
private String getOsAppropriatePath(String fileName) throws Exception {
  URI uriToFile = getClass().getClassLoader().getResource(fileName).toURI();
  return IS_WINDOWS
      ? uriToFile.getSchemeSpecificPart().substring(1)
      : uriToFile.getSchemeSpecificPart();
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:7,代码来源:CsvPlotReaderTest.java


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