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


Java URI.toString方法代码示例

本文整理汇总了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");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:JarFileSystemProvider.java

示例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;
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:25,代码来源:ThingDescriptionHandler.java

示例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);
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:29,代码来源:URIUtils.java

示例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);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:14,代码来源:ExportTest.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:Test.java

示例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);
    }
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:10,代码来源:URIUtils.java

示例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;
}
 
开发者ID:jakemanning,项目名称:boomer-tuner,代码行数:8,代码来源:Video.java

示例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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Test.java

示例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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:12,代码来源:GitRepositoryAwareWorkingSetManager.java

示例10: print

import java.net.URI; //导入方法依赖的package包/类
public String print(URI v) {
    return v.toString();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:RuntimeBuiltinLeafInfoImpl.java

示例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;
}
 
开发者ID:level11data,项目名称:databricks-client-java,代码行数:7,代码来源:InteractiveJobBuilder.java

示例12: createBlobClient

import java.net.URI; //导入方法依赖的package包/类
@Override
public void createBlobClient(URI baseUri, StorageCredentials credentials) {
  this.baseUriString = baseUri.toString();
  backingStore = new InMemoryBlockBlobStore();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:6,代码来源:MockStorageInterface.java

示例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();
}
 
开发者ID:equella,项目名称:Equella,代码行数:65,代码来源:QtiPlayViewerSection.java

示例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);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:46,代码来源:Require.java

示例15: FileSystemConfig

import java.net.URI; //导入方法依赖的package包/类
public FileSystemConfig(URI uri, SchemaMutability schemaMutability) {
  this(uri.toString(), uri.getPath(), null, null, false, schemaMutability);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:4,代码来源:FileSystemConfig.java


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