List of usage examples for java.net URI getSchemeSpecificPart
public String getSchemeSpecificPart()
From source file:Main.java
public static void main(String[] args) throws NullPointerException, URISyntaxException { URI uri = new URI("http://www.java2s.com:8080/yourpath/fileName.htm"); System.out.println("URI : " + uri); System.out.println(uri.getSchemeSpecificPart()); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { URI u = new URI("http://www.java2s.com"); System.out.println("The URI is " + u); if (u.isOpaque()) { System.out.println("This is an opaque URI."); System.out.println("The scheme is " + u.getScheme()); System.out.println("The scheme specific part is " + u.getSchemeSpecificPart()); System.out.println("The fragment ID is " + u.getFragment()); } else {// w w w .j a va 2 s . c o m System.out.println("This is a hierarchical URI."); System.out.println("The scheme is " + u.getScheme()); u = u.parseServerAuthority(); System.out.println("The host is " + u.getUserInfo()); System.out.println("The user info is " + u.getUserInfo()); System.out.println("The port is " + u.getPort()); System.out.println("The path is " + u.getPath()); System.out.println("The query string is " + u.getQuery()); System.out.println("The fragment ID is " + u.getFragment()); } }
From source file:org.pepstock.jem.util.migrate.DBMaint.java
/** * Main program which accept an argument with the file where JEM-ENV configuration * file is stored./*from w ww . j ava 2 s. c om*/ * <br> * It uses to read the database information and to initialize the database managers. * * @param args list of arguments: it accepts a argument with the file of JEM-ENV configuration file, by tag * @throws ConfigurationException if there is any error reading the JEM configuration * @throws SQLException if there is any error updating the JEM tables on the database * @throws ParseException if there is an error on the arguments list */ public static void main(String[] args) throws ConfigurationException, SQLException { // reads arguments // -configuration mandatory @SuppressWarnings("static-access") Option propFile = OptionBuilder.withArgName(CONFIGURATION).hasArg() .withDescription("The file of JEM environment configuration.").create(CONFIGURATION); // the argument is mandatory propFile.setRequired(true); // parses all arguments ArgumentsParser parser = new ArgumentsParser(DBMaint.class.getName()); // adds to the map of all args parser.getOptions().add(propFile); // gets the properties with all // arguments Properties properties; try { properties = parser.parseArg(args); } catch (ParseException e) { LogAppl.getInstance().ignore(e.getMessage(), e); return; } // gets the configuration file String configFile = properties.getProperty(CONFIGURATION); File fileConfig = new File(configFile); // reads the JEM ENV configuration file String xmlConfig = null; try { xmlConfig = FileUtils.readFileToString(fileConfig, CharSet.DEFAULT_CHARSET_NAME); } catch (IOException e) { LogAppl.getInstance().emit(NodeMessage.JEMC006E); throw new ConfigurationException(NodeMessage.JEMC006E.toMessage().getMessage(), e); } // parses the configuration object Configuration config = Configuration.unmarshall(xmlConfig); LogAppl.getInstance().emit(NodeMessage.JEMC008I, configFile); // gets ONLY the database config Database database = config.getDatabase(); // if database is null, EXCEPTION if (database == null) { LogAppl.getInstance().emit(NodeMessage.JEMC009E, ConfigKeys.DATABASE_ELEMENT); throw new ConfigurationException( NodeMessage.JEMC009E.toMessage().getFormattedMessage(ConfigKeys.DATABASE_ELEMENT)); } // gets URL String url = database.getUrl(); // shows which database is used LogAppl.getInstance().emit(NodeMessage.JEMC193I, url); // parses the URL to get which database has been used String dbType = null; try { // parses URL URI url1 = new URI(database.getUrl()); // gets Scheme Specific part URI myURL = new URI(url1.getSchemeSpecificPart()); // and gets database type dbType = myURL.getScheme(); } catch (URISyntaxException e2) { LogAppl.getInstance().emit(NodeMessage.JEMC166E, e2, database.getUrl()); throw new ConfigurationException( NodeMessage.JEMC166E.toMessage().getFormattedMessage(database.getUrl())); } // defines the SQL container // using the database type SQLContainerFactory engine = null; if (dbType.equals(MySqlSQLContainerFactory.DATABASE_TYPE)) { engine = new MySqlSQLContainerFactory(); } else if (dbType.equals(OracleSQLContainerFactory.DATABASE_TYPE)) { engine = new OracleSQLContainerFactory(); } else if (dbType.equals(DB2SQLContainerFactory.DATABASE_TYPE)) { engine = new DB2SQLContainerFactory(); } else { engine = new DefaultSQLContainerFactory(); } try { // creates database pool // using the database configuration DBPoolManager.getInstance().setDriver(database.getDriver()); DBPoolManager.getInstance().setUrl(database.getUrl()); DBPoolManager.getInstance().setUser(database.getUser()); DBPoolManager.getInstance().setPassword(database.getPassword()); DBPoolManager.getInstance().setProperties(database.getProperties()); DBPoolManager.getInstance().setKeepAliveConnectionSQL(engine.getKeepAliveConnectionSQL()); // init the db pool DBPoolManager.getInstance().init(); // initialize jobs DB managers // necessary to migrate the database InputDBManager.getInstance().setSqlContainer(engine.getSQLContainerForInputQueue()); RunningDBManager.getInstance().setSqlContainer(engine.getSQLContainerForRunningQueue()); OutputDBManager.getInstance().setSqlContainer(engine.getSQLContainerForOutputQueue()); RoutingDBManager.getInstance().setSqlContainer(engine.getSQLContainerForRoutingQueue()); // initialize common resources DB manager // necessary to migrate the database CommonResourcesDBManager.getInstance().setSqlContainer(engine.getSQLContainerForCommonResourcesMap()); } catch (SQLException e) { throw new ConfigurationException( NodeMessage.JEMC165E.toMessage().getFormattedMessage(JobDBManager.class.getName()), e); } // creates DB migration utility for jobs JobDBUpdate job = new JobDBUpdate(); // start migration job.start(); // creates DB migration utility for resources ResourceDBUpdate resource = new ResourceDBUpdate(); // start migration resource.start(); }
From source file:Main.java
public static final String dereference(String idRef) { URI uri = URI.create(idRef); String part = uri.getSchemeSpecificPart(); if (part != null && part.length() > 0) { throw new UnsupportedOperationException( "modlur does not support external sources (" + uri.toString() + ")"); }/*ww w .j av a 2 s .co m*/ return uri.getFragment(); }
From source file:Main.java
public static Intent createImplicitIntentFromURI(URI messageSource) { Intent bindingIntent;//from www .j av a 2 s. c o m //action:com.nosolojava.Service String action = messageSource.getSchemeSpecificPart(); bindingIntent = new Intent(action); return bindingIntent; }
From source file:com.marklogic.mapreduce.utilities.URIUtil.java
public static String getPathFromURI(DocumentURI uri) { String uriStr = uri.getUri(); try {// w w w . jav a 2s. c om URI child = new URI(uriStr); String childPath; if (child.isOpaque()) { childPath = child.getSchemeSpecificPart(); } else { childPath = child.getPath(); } return childPath; } catch (Exception ex) { LOG.warn("Error parsing URI " + uriStr + "."); return uriStr; } }
From source file:org.eclipse.wb.internal.core.editor.errors.report2.ProjectReportEntry.java
/** * Return the size of the supplied file. *///from w w w . j av a2 s . c o m private static long getResourceSize(IResource resource) { if (resource.getType() != IResource.FILE) { return 0; } IFile file = (IFile) resource; URI location = file.getLocationURI(); if (location == null) { return 0; } return new File(location.getSchemeSpecificPart()).length(); }
From source file:org.springframework.ws.transport.mail.support.MailTransportUtils.java
public static String getSubject(URI uri) { Matcher matcher = SUBJECT_PATTERN.matcher(uri.getSchemeSpecificPart()); if (matcher.find()) { return matcher.group(1); }/*from w w w . j a v a2 s . c o m*/ return null; }
From source file:org.springframework.ws.transport.mail.support.MailTransportUtils.java
public static InternetAddress getTo(URI uri) { Matcher matcher = TO_PATTERN.matcher(uri.getSchemeSpecificPart()); if (matcher.find()) { for (int i = 1; i <= matcher.groupCount(); i++) { String group = matcher.group(i); if (group != null) { try { return new InternetAddress(group); } catch (AddressException e) { // try next group }/*ww w.j a va 2s . co m*/ } } } return null; }
From source file:com.google.mr4c.content.ContentFactories.java
/** * Turns a URI that is just a file path or a "rel" URI into a real file URI. *//*from w ww .j av a 2s . c om*/ public static URI scrubURI(URI uri) { String scheme = uri.getScheme(); String path = uri.getSchemeSpecificPart(); if (StringUtils.isEmpty(scheme)) { // its a file path if (path.startsWith("/")) { // its absolute return new File(path).toURI(); } else { // its relative return new File(RelativeContentFactory.getWorkingDirectory(), path).toURI(); } } else if (scheme.equals("rel")) { return RelativeContentFactory.toFile(uri).toURI(); } else { return uri; } }