List of usage examples for java.net URI getPath
public String getPath()
From source file:com.almende.eve.transport.xmpp.XmppTransport.java
/** * Instantiates a new xmpp transport.//from w w w .j a v a 2s. com * * @param config * the config * @param handle * the handle * @param service * the service */ public XmppTransport(final XmppTransportConfig config, final Handler<Receiver> handle, final TransportService service) { // TODO: support more parameter structures. super(config.getAddress(), handle, service, config); final URI address = super.getAddress(); host = address.getHost(); port = address.getPort(); if (port < 0) { port = 5222; } username = address.getUserInfo(); resource = address.getPath().substring(1); if (serviceName == null) { serviceName = host; } password = config.getPassword(); }
From source file:com.jaeksoft.searchlib.crawler.rest.RestCrawlThread.java
private void callback(HttpDownloader downloader, URI uri, String query) throws URISyntaxException, ClientProtocolException, IllegalStateException, IOException, SearchLibException { uri = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), query, uri.getFragment()); DownloadItem dlItem = downloader.request(uri, restCrawlItem.getCallbackMethod(), restCrawlItem.getCredential(), null, null, null); dlItem.checkNoErrorList(200, 201, 202, 203); }
From source file:io.cloudslang.lang.cli.utils.CompilerHelperTest.java
@Test public void testFilePathValidWithOtherPathForDependencies() throws Exception { URI flowFilePath = getClass().getResource("/flow.sl").toURI(); URI folderPath = getClass().getResource("/executables/dir1/").toURI(); URI flow2FilePath = getClass().getResource("/executables/dir1/flow2.sl").toURI(); compilerHelper.compile(flowFilePath.getPath(), Lists.newArrayList(folderPath.getPath())); Mockito.verify(slang).compile(SlangSource.fromFile(flowFilePath), Sets.newHashSet(SlangSource.fromFile(flow2FilePath))); }
From source file:io.cloudslang.lang.cli.utils.CompilerHelperTest.java
@Test public void testCompileDependencyPropPartOfFileName() throws Exception { URI flowFilePath = getClass().getResource("/flow.sl").toURI(); URI folderPath = getClass().getResource("/executables/dir2/").toURI(); URI flow2FilePath = getClass().getResource("/executables/dir2/flowprop.sl").toURI(); compilerHelper.compile(flowFilePath.getPath(), Lists.newArrayList(folderPath.getPath())); Mockito.verify(slang).compile(SlangSource.fromFile(flowFilePath), Sets.newHashSet(SlangSource.fromFile(flow2FilePath))); }
From source file:mobisocial.nfcserver.handler.HttpFileHandler.java
public int handleNdef(NdefMessage[] ndefMessages) { URI page = null; NdefRecord firstRecord = ndefMessages[0].getRecords()[0]; if (UriRecord.isUri(firstRecord)) { page = UriRecord.parse(firstRecord).getUri(); }// w w w. j a va 2 s.c o m try { if (page != null && (page.getScheme().startsWith("http"))) { System.out.println("trying to get " + page); if (page.getPath() == null || !page.toString().contains(".")) { return NDEF_PROPAGATE; } try { String extension = page.toString().substring(page.toString().lastIndexOf(".") + 1); if (!MimeTypeHandler.MIME_EXTENSIONS.containsValue(extension)) { return NDEF_PROPAGATE; } // Download content System.out.println("Downloading " + extension + " file."); HttpGet httpGet = new HttpGet(page); HttpClient httpClient = new DefaultHttpClient(); HttpResponse httpResponse = httpClient.execute(httpGet); HttpEntity entity = httpResponse.getEntity(); InputStream content = entity.getContent(); File fileOut = new File("nfcfiles/" + System.currentTimeMillis() + "." + extension); fileOut.getParentFile().mkdirs(); FileOutputStream fileOutStream = new FileOutputStream(fileOut); BufferedOutputStream buffered = new BufferedOutputStream(fileOutStream); byte[] buf = new byte[1024]; while (true) { int r = content.read(buf); if (r <= 0) break; buffered.write(buf, 0, r); } buffered.close(); fileOutStream.close(); MimeTypeHandler.openFile(fileOut); return NDEF_CONSUME; } catch (Exception e) { e.printStackTrace(); return NDEF_PROPAGATE; } } } catch (Exception e) { Log.e(TAG, "Error launching page", e); } return NDEF_PROPAGATE; }
From source file:com.microsoft.azure.storage.core.Utility.java
/** * Returns a value that indicates whether a specified URI is a path-style URI. * //from w w w . jav a 2 s. com * @param baseURI * A <code>java.net.URI</code> value that represents the URI being checked. * @return <code>true</code> if the specified URI is path-style; otherwise, <code>false</code>. */ public static boolean determinePathStyleFromUri(final URI baseURI) { String path = baseURI.getPath(); if (path != null && path.startsWith("/")) { path = path.substring(1); } // if the path is null or empty, this is not path-style if (Utility.isNullOrEmpty(path)) { return false; } // if this contains a port or has a host which is not DNS, this is path-style return pathStylePorts.contains(baseURI.getPort()) || !isHostDnsName(baseURI); }
From source file:org.n52.sos.web.JdbcUrl.java
protected final void parse(String string) throws URISyntaxException { URI uri = new URI(string); scheme = uri.getScheme();/*from ww w .ja va 2 s. c o m*/ uri = new URI(uri.getSchemeSpecificPart()); type = uri.getScheme(); host = uri.getHost(); port = uri.getPort(); String[] path = uri.getPath().split(SLASH_STRING); if (path.length == 1 && !path[0].isEmpty()) { database = path[0]; } else if (path.length == 2 && path[0].isEmpty() && !path[1].isEmpty()) { database = path[1]; } for (NameValuePair nvp : URLEncodedUtils.parse(uri, "UTF-8")) { if (nvp.getName().equals(QUERY_PARAMETER_USER)) { user = nvp.getValue(); } else if (nvp.getName().equals(QUERY_PARAMETER_PASSWORD)) { password = nvp.getValue(); } } }