本文整理汇总了Java中java.net.URI.toString方法的典型用法代码示例。如果您正苦于以下问题:Java URI.toString方法的具体用法?Java URI.toString怎么用?Java URI.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.URI
的用法示例。
在下文中一共展示了URI.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPath
import java.net.URI; //导入方法依赖的package包/类
@Override
public Path getPath(URI uri) {
FileSystem fs = getFileSystem(uri);
String path = uri.getFragment();
if (path == null) {
String uristr = uri.toString();
int off = uristr.indexOf("!/");
if (off != -1)
path = uristr.substring(off + 2);
}
if (path != null)
return fs.getPath(path);
throw new IllegalArgumentException("URI: "
+ uri
+ " does not contain path fragment ex. jar:///c:/foo.zip!/BAR");
}
示例2: get
import java.net.URI; //导入方法依赖的package包/类
@Override
public RESTResource get(URI uri, Map<String, String> parameters) throws RESTException {
RESTResource resource = new RESTResource(uri.toString(),this);
Dataset dataset = ThingDirectory.get().dataset;
dataset.begin(ReadWrite.READ);
try {
String q = "SELECT ?str WHERE { <" + uri + "> <" + DC.source + "> ?str }";
QueryExecution qexec = QueryExecutionFactory.create(q, dataset);
ResultSet result = qexec.execSelect();
if (result.hasNext()) {
resource.contentType = "application/ld+json";
resource.content = result.next().get("str").asLiteral().getLexicalForm();
} else {
throw new RESTException();
}
} finally {
dataset.end();
}
return resource;
}
示例3: resolve
import java.net.URI; //导入方法依赖的package包/类
/**
* Resolves a URI reference against a base URI. Work-around for bugs in
* java.net.URI (e.g. <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4708535>)
*
* @param baseURI the base URI
* @param reference the URI reference
* @return the resulting URI
*/
public static URI resolve(final URI baseURI, final URI reference){
Args.notNull(baseURI, "Base URI");
Args.notNull(reference, "Reference URI");
URI ref = reference;
final String s = ref.toString();
if (s.startsWith("?")) {
return resolveReferenceStartingWithQueryString(baseURI, ref);
}
final boolean emptyReference = s.length() == 0;
if (emptyReference) {
ref = URI.create("#");
}
URI resolved = baseURI.resolve(ref);
if (emptyReference) {
final String resolvedString = resolved.toString();
resolved = URI.create(resolvedString.substring(0,
resolvedString.indexOf('#')));
}
return normalizeSyntax(resolved);
}
示例4: exportFilesCreated
import java.net.URI; //导入方法依赖的package包/类
/** */
@Test
public void exportFilesCreated() throws IOException {
Metadata snapshot1 = createSnapshotInCompute("1");
writeKV("a", "1", firstCache, snapshot1);
Metadata snapshot2 = createSnapshotInCompute("2");
writeKV("a", "2", firstCache, snapshot2);
URI backupDir = folder.newFolder().toURI();
String destination = backupDir.toString();
backupInCompute(destination);
assertNotEquals(new File(backupDir).listFiles().length, 0);
}
示例5: Test
import java.net.URI; //导入方法依赖的package包/类
private Test(String s, String u, String h, int n,
String p, String q, String f)
{
testCount++;
try {
uri = new URI(s, u, h, n, p, q, f);
} catch (URISyntaxException x) {
exc = x;
input = x.getInput();
}
if (uri != null)
input = uri.toString();
originalURI = uri;
}
示例6: replaceScheme
import java.net.URI; //导入方法依赖的package包/类
public static URI replaceScheme(URI uri, String scheme) {
try {
String location = uri.toString();
int index = location.indexOf("://");
return new URI(scheme + location.substring(index));
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Invalid URI/Scheme: replacing scheme with "+scheme+" for "+uri);
}
}
示例7: from
import java.net.URI; //导入方法依赖的package包/类
public static Video from(final URI path) {
Media media = new Media(path.toString());
MediaPlayer mediaPlayer = new MediaPlayer(media);
Video video = new Video(Paths.get(path).getFileName().toString(), path);
mediaPlayer.setOnReady(() -> video.duration.set(Playable.format(media.getDuration())));
return video;
}
示例8: Test
import java.net.URI; //导入方法依赖的package包/类
private Test(String s, String ssp, String f) {
testCount++;
try {
uri = new URI(s, ssp, f);
} catch (URISyntaxException x) {
exc = x;
input = x.getInput();
}
if (uri != null)
input = uri.toString();
originalURI = uri;
}
示例9: toUriString
import java.net.URI; //导入方法依赖的package包/类
/**
* Returns with the {@link URI#toString()} of the argument. Trims the trailing forward slash if any.
*/
private static String toUriString(final URI uri) {
final String uriString = uri.toString();
final int length = uriString.length();
if (uriString.charAt(length - 1) == '/') {
return uriString.substring(0, length - 1);
}
return uriString;
}
示例10: print
import java.net.URI; //导入方法依赖的package包/类
public String print(URI v) {
return v.toString();
}
示例11: withEggLibrary
import java.net.URI; //导入方法依赖的package包/类
protected InteractiveJobBuilder withEggLibrary(URI uri) {
LibraryDTO libraryDTO = new LibraryDTO();
libraryDTO.Egg = uri.toString();
_libraries.add(libraryDTO);
return this;
}
示例12: createBlobClient
import java.net.URI; //导入方法依赖的package包/类
@Override
public void createBlobClient(URI baseUri, StorageCredentials credentials) {
this.baseUriString = baseUri.toString();
backingStore = new InMemoryBlockBlobStore();
}
示例13: viewResource
import java.net.URI; //导入方法依赖的package包/类
/**
* Serve up the image (or whatever) relative to the current question (if
* any)
*
* @param info
* @param href
*/
@EventHandlerMethod(preventXsrf = false)
public void viewResource(SectionInfo info, String href)
{
final ViewItemResource resource = rootFileSection.getViewItemResource(info);
final TestSessionState testSessionState = qtiWebService.getTestSessionState(info, resource);
final TestPlan testPlan = testSessionState.getTestPlan();
final CustomAttachment qti = getAttachment(resource);
final String testXmlPath = (String) qti.getData(QtiConstants.KEY_XML_PATH);
final String path;
final TestPlanNodeKey currentItemKey = testSessionState.getCurrentItemKey();
if( currentItemKey != null )
{
final TestPlanNode questionNode = testPlan.getNode(currentItemKey);
final URI itemSystemId = questionNode.getItemSystemId();
final String questionXmlPath = itemSystemId.toString();
// relative to question XML file
path = PathUtils.filePath(PathUtils.getParentFolderFromFilepath(questionXmlPath), href);
}
else
{
// relative to test XML file
path = PathUtils.filePath(PathUtils.getParentFolderFromFilepath(testXmlPath), href);
}
// normalize the path, i.e. remove any ".."
String finalPath = PathUtils.normalizePath(path);
if( finalPath.charAt(0) == '/' && finalPath.length() > 1 )
{
finalPath = finalPath.substring(1);
}
final FileHandle fileHandle = resource.getViewableItem().getFileHandle();
if( !fileSystemService.fileExists(fileHandle, finalPath) )
{
throw new NotFoundException(href);
}
// TODO: this is sub-optimal. You can use Path.isParent(Path p2) or
// similar, but Paths uses the default file system, which may not be
// appropriate...
if( !finalPath.toUpperCase()
.startsWith(PathUtils.filePath(FileSystemService.SECURE_FOLDER, QtiConstants.QTI_FOLDER_NAME)) )
{
throw new AccessDeniedException(CurrentLocale.get(KEY_ERROR_OUTSIDE_PACKAGE));
}
if( matchesProtectedFile(testPlan, fileHandle, testXmlPath, finalPath) )
{
throw new AccessDeniedException(CurrentLocale.get(KEY_ERROR_PROTECTED_RESOURCE));
}
final FileContentStream stream = fileSystemService.getInsecureContentStream(fileHandle, finalPath,
mimeService.getMimeTypeForFilename(finalPath));
stream.setCacheControl("max-age=86400, s-maxage=0, must-revalidate");
contentStreamWriter.outputStream(info.getRequest(), info.getResponse(), stream);
info.setRendered();
}
示例14: call
import java.net.URI; //导入方法依赖的package包/类
@Override
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
Object[] args)
{
if(args == null || args.length < 1) {
throw ScriptRuntime.throwError(cx, scope,
"require() needs one argument");
}
String id = (String)Context.jsToJava(args[0], String.class);
URI uri = null;
URI base = null;
if (id.startsWith("./") || id.startsWith("../")) {
if (!(thisObj instanceof ModuleScope)) {
throw ScriptRuntime.throwError(cx, scope,
"Can't resolve relative module ID \"" + id +
"\" when require() is used outside of a module");
}
ModuleScope moduleScope = (ModuleScope) thisObj;
base = moduleScope.getBase();
URI current = moduleScope.getUri();
uri = current.resolve(id);
if (base == null) {
// calling module is absolute, resolve to absolute URI
// (but without file extension)
id = uri.toString();
} else {
// try to convert to a relative URI rooted on base
id = base.relativize(current).resolve(id).toString();
if (id.charAt(0) == '.') {
// resulting URI is not contained in base,
// throw error or make absolute depending on sandbox flag.
if (sandboxed) {
throw ScriptRuntime.throwError(cx, scope,
"Module \"" + id + "\" is not contained in sandbox.");
} else {
id = uri.toString();
}
}
}
}
return getExportedModuleInterface(cx, id, uri, base, false);
}
示例15: FileSystemConfig
import java.net.URI; //导入方法依赖的package包/类
public FileSystemConfig(URI uri, SchemaMutability schemaMutability) {
this(uri.toString(), uri.getPath(), null, null, false, schemaMutability);
}