本文整理汇总了Java中java.net.URI.create方法的典型用法代码示例。如果您正苦于以下问题:Java URI.create方法的具体用法?Java URI.create怎么用?Java URI.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.URI
的用法示例。
在下文中一共展示了URI.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateControllerConnections
import java.net.URI; //导入方法依赖的package包/类
@Override
public void updateControllerConnections(OFBsnControllerConnectionsReply controllerCxnsReply) {
// Instantiate clean map, can't use a builder here since we need to call temp.get()
Map<URI,Map<OFAuxId, OFBsnControllerConnection>> temp = new ConcurrentHashMap<URI,Map<OFAuxId, OFBsnControllerConnection>>();
List<OFBsnControllerConnection> controllerCxnUpdates = controllerCxnsReply.getConnections();
for(OFBsnControllerConnection update : controllerCxnUpdates) {
URI uri = URI.create(update.getUri());
Map<OFAuxId, OFBsnControllerConnection> cxns = temp.get(uri);
// Add to nested map
if(cxns != null){
cxns.put(update.getAuxiliaryId(), update);
} else{
cxns = new ConcurrentHashMap<OFAuxId, OFBsnControllerConnection>();
cxns.put(update.getAuxiliaryId(), update);
temp.put(uri, cxns);
}
}
this.controllerConnections = ImmutableMap.<URI,Map<OFAuxId, OFBsnControllerConnection>>copyOf(temp);
}
示例2: build
import java.net.URI; //导入方法依赖的package包/类
public MetadataDocumentMessage build() {
// todo - here, we make link with DUMMY_BASE_URI and then take it out again so clients can fill in domain - must be a better way of doing this!
RepositoryLinkBuilder rlb = new RepositoryLinkBuilder(mappings.getMetadataFor(documentType),
new BaseUri(URI.create(DUMMY_BASE_URI)));
Link link = rlb
.slash(metadataDocId)
.withRel(mappings.getMetadataFor(documentType).getItemResourceRel());
String callbackLink = link.withSelfRel().getHref().replace(DUMMY_BASE_URI, "");
return new MetadataDocumentMessage(documentType.getSimpleName().toLowerCase(), metadataDocId, metadataDocUuid, callbackLink);
}
示例3: BinaryJedis
import java.net.URI; //导入方法依赖的package包/类
public BinaryJedis(final String host) {
URI uri = URI.create(host);
if (uri.getScheme() != null && uri.getScheme().equals("redis")) {
initializeClientFromURI(uri);
} else {
client = new Client(host);
}
}
示例4: search
import java.net.URI; //导入方法依赖的package包/类
@RequestMapping(path = "/search", method = RequestMethod.POST)
public String search(HttpServletRequest request, @RequestParam("access_token") String accessToken) throws IOException {
UserDirectorySearchRequest searchQuery = parser.parse(request, UserDirectorySearchRequest.class);
URI target = URI.create(request.getRequestURL().toString());
UserDirectorySearchResult result = mgr.search(target, accessToken, searchQuery.getSearchTerm());
return gson.toJson(result);
}
示例5: testGetRequest
import java.net.URI; //导入方法依赖的package包/类
@Test(expected = UnsupportedOperationException.class)
public void testGetRequest() throws IOException {
final MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", URI.create("/"));
try (final MinijaxRequestContext context = new MinijaxRequestContext(null, mockRequest, null)) {
context.getRequest();
}
}
示例6: test2
import java.net.URI; //导入方法依赖的package包/类
public void test2() {
Context context = new Context();
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
context.put(DiagnosticListener.class, diagnostics);
Options.instance(context).put("allowStringFolding", "false");
JCTree.JCCompilationUnit unit;
JavacFileManager fileManager = new JavacFileManager(context, true, UTF_8);
try {
fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, ImmutableList.<File>of());
} catch (IOException e) {
// impossible
throw new IOError(e);
}
SimpleJavaFileObject source =
new SimpleJavaFileObject(URI.create("source"), JavaFileObject.Kind.SOURCE) {
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
return src;
}
};
Log.instance(context).useSource(source);
ParserFactory parserFactory = ParserFactory.instance(context);
Parser parser =
parserFactory.newParser(
src,
/*keepDocComments=*/ true,
/*keepEndPos=*/ true,
/*keepLineMap=*/ true);
unit = parser.parseCompilationUnit();
unit.sourcefile = source;
}
示例7: testHsftpCustomUriPortWithDefaultPorts
import java.net.URI; //导入方法依赖的package包/类
@Test
public void testHsftpCustomUriPortWithDefaultPorts() throws IOException {
Configuration conf = new Configuration();
URI uri = URI.create("hsftp://localhost:123");
HsftpFileSystem fs = (HsftpFileSystem) FileSystem.get(uri, conf);
assertEquals(DFSConfigKeys.DFS_NAMENODE_HTTPS_PORT_DEFAULT,
fs.getDefaultPort());
assertEquals(uri, fs.getUri());
assertEquals("127.0.0.1:123", fs.getCanonicalServiceName());
}
示例8: _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);
}
示例9: sendUnsignedJsonAuthnResponseFromHub_shouldRespondWithNextLocation
import java.net.URI; //导入方法依赖的package包/类
@Test
public void sendUnsignedJsonAuthnResponseFromHub_shouldRespondWithNextLocation() throws Exception {
SessionId sessionId = SessionId.createNewSessionId();
URI nextLocationUri = URI.create("http://blah");
String requestId = UUID.randomUUID().toString();
Function<OutboundResponseFromHub, String> outboundResponseFromHubToStringTransformer =
new HubTransformersFactory().getOutboundResponseFromHubToStringTransformer(
new HardCodedKeyStore(HUB_ENTITY_ID),
getKeyStore(),
new IdpHardCodedEntityToEncryptForLocator(),
SIGNATURE_ALGORITHM,
DIGEST_ALGORITHM);
OutboundResponseFromHub authnResponseFromHub = anAuthnResponse()
.withInResponseTo(requestId)
.withIssuerId(HUB_ENTITY_ID)
.withTransactionIdaStatus(TransactionIdaStatus.Success)
.buildOutboundResponseFromHub();
String samlString = outboundResponseFromHubToStringTransformer.apply(authnResponseFromHub);
AuthnResponseFromHubContainerDto authnResponseFromHubContainerDto = new AuthnResponseFromHubContainerDto(
samlString,
nextLocationUri,
com.google.common.base.Optional.absent(),
authnResponseFromHub.getId());
policyStubRule.anAuthnResponseFromHubToRp(sessionId, authnResponseFromHubContainerDto);
javax.ws.rs.core.Response response = getResponseFromSamlProxy(Urls.SamlProxyUrls.SEND_RESPONSE_FROM_HUB_API_RESOURCE, sessionId);
assertThat(response.readEntity(SamlMessageSenderHandler.SamlMessage.class).getPostEndpoint()).isEqualTo(nextLocationUri.toASCIIString());
}
示例10: testMiniClusterStore
import java.net.URI; //导入方法依赖的package包/类
@Test
public void testMiniClusterStore() throws EventDeliveryException, IOException {
// setup a minicluster
MiniDFSCluster cluster = new MiniDFSCluster
.Builder(new Configuration())
.build();
FileSystem dfs = cluster.getFileSystem();
Configuration conf = dfs.getConf();
URI hdfsUri = URI.create(
"dataset:" + conf.get("fs.defaultFS") + "/tmp/repo" + DATASET_NAME);
try {
// create a repository and dataset in HDFS
Datasets.create(hdfsUri, DESCRIPTOR);
// update the config to use the HDFS repository
config.put(DatasetSinkConstants.CONFIG_KITE_DATASET_URI, hdfsUri.toString());
DatasetSink sink = sink(in, config);
// run the sink
sink.start();
sink.process();
sink.stop();
Assert.assertEquals(
Sets.newHashSet(expected),
read(Datasets.load(hdfsUri)));
Assert.assertEquals("Should have committed", 0, remaining(in));
} finally {
if (Datasets.exists(hdfsUri)) {
Datasets.delete(hdfsUri);
}
cluster.shutdown();
}
}
示例11: toMvnRepositoryURI
import java.net.URI; //导入方法依赖的package包/类
URI toMvnRepositoryURI() {
var base = "https://mvnrepository.com/artifact/";
return URI.create(base + String.join("/", group, artifact));
}
示例12: browseMeta
import java.net.URI; //导入方法依赖的package包/类
@Override
public DIDLObject browseMeta(YaaccContentDirectory contentDirectory,
String myId) {
Item result = null;
String[] projection = {MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.DISPLAY_NAME,
MediaStore.Audio.Media.MIME_TYPE, MediaStore.Audio.Media.SIZE,
MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.ALBUM_ID,
MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.DURATION};
String selection = MediaStore.Audio.Media._ID + "=?";
String[] selectionArgs = new String[]{myId
.substring(ContentDirectoryIDs.MUSIC_ALL_TITLES_ITEM_PREFIX
.getId().length())};
Cursor mediaCursor = contentDirectory
.getContext()
.getContentResolver()
.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection,
selection, selectionArgs, null);
if (mediaCursor != null) {
mediaCursor.moveToFirst();
String id = mediaCursor.getString(mediaCursor
.getColumnIndex(MediaStore.Audio.Media._ID));
String name = mediaCursor.getString(mediaCursor
.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
Long size = Long.valueOf(mediaCursor.getString(mediaCursor
.getColumnIndex(MediaStore.Audio.Media.SIZE)));
String album = mediaCursor.getString(mediaCursor
.getColumnIndex(MediaStore.Audio.Media.ALBUM));
String albumId = mediaCursor.getString(mediaCursor
.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));
String title = mediaCursor.getString(mediaCursor
.getColumnIndex(MediaStore.Audio.Media.TITLE));
String artist = mediaCursor.getString(mediaCursor
.getColumnIndex(MediaStore.Audio.Media.ARTIST));
String duration = mediaCursor.getString(mediaCursor
.getColumnIndex(MediaStore.Audio.Media.DURATION));
duration = contentDirectory.formatDuration(duration);
Log.d(getClass().getName(),
"Mimetype: "
+ mediaCursor.getString(mediaCursor
.getColumnIndex(MediaStore.Audio.Media.MIME_TYPE)));
MimeType mimeType = MimeType.valueOf(mediaCursor
.getString(mediaCursor
.getColumnIndex(MediaStore.Audio.Media.MIME_TYPE)));
// file parameter only needed for media players which decide
// the
// ability of playing a file by the file extension
String uri = getUriString(contentDirectory, id, mimeType);
URI albumArtUri = URI.create("http://"
+ contentDirectory.getIpAddress() + ":"
+ YaaccUpnpServerService.PORT + "/?album=" + albumId);
Res resource = new Res(mimeType, size, uri);
resource.setDuration(duration);
MusicTrack musicTrack = new MusicTrack(
ContentDirectoryIDs.MUSIC_ALL_TITLES_ITEM_PREFIX.getId()
+ id,
ContentDirectoryIDs.MUSIC_ALL_TITLES_FOLDER.getId(), title
+ "-(" + name + ")", "", album, artist, resource);
musicTrack
.replaceFirstProperty(new UPNP.ALBUM_ART_URI(albumArtUri));
result = musicTrack;
Log.d(getClass().getName(), "MusicTrack: " + id + " Name: " + name
+ " uri: " + uri);
mediaCursor.close();
} else {
Log.d(getClass().getName(), "Item " + myId + " not found.");
}
return result;
}
示例13: JavaSource
import java.net.URI; //导入方法依赖的package包/类
public JavaSource() {
super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
source = bodyTemplate.replace("#A1", a1.typeStr)
.replace("#A2", a2.typeStr).replace("#A3", a3.typeStr)
.replace("#MC", mck.invokeString);
}
示例14: HttpPropFind
import java.net.URI; //导入方法依赖的package包/类
public HttpPropFind(final String uri)
{
this(URI.create(uri));
}
示例15: resolve
import java.net.URI; //导入方法依赖的package包/类
@Override
public DDO resolve(String identifier) throws ResolutionException {
// prepare HTTP request
String uriString = this.getResolverUri().toString();
if (! uriString.endsWith("/")) uriString += "/";
uriString += identifier;
HttpGet httpGet = new HttpGet(URI.create(uriString));
// retrieve DDO
DDO ddo;
try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) this.getHttpClient().execute(httpGet)) {
if (httpResponse.getStatusLine().getStatusCode() == 404) return null;
if (httpResponse.getStatusLine().getStatusCode() > 200) throw new ResolutionException("Cannot retrieve DDO for " + identifier + " from " + uriString + ": " + httpResponse.getStatusLine());
HttpEntity httpEntity = httpResponse.getEntity();
ddo = DDO.fromString(EntityUtils.toString(httpEntity));
EntityUtils.consume(httpEntity);
} catch (IOException ex) {
throw new ResolutionException("Cannot retrieve DDO for " + identifier + " from " + uriString + ": " + ex.getMessage(), ex);
}
if (log.isDebugEnabled()) log.debug("Retrieved DDO for " + identifier + " (" + uriString + "): " + ddo);
// done
return ddo;
}