本文整理汇总了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
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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();
}
}
示例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)));
}
示例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);
}
示例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);
}
示例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
}
示例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());
}
}
示例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));
}
示例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;
}
}
示例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();
}