Example usage for java.net URI create

List of usage examples for java.net URI create

Introduction

In this page you can find the example usage for java.net URI create.

Prototype

public static URI create(String str) 

Source Link

Document

Creates a URI by parsing the given string.

Usage

From source file:com.google.mr4c.hadoop.MR4CArgumentParser.java

void parse() throws IOException {
    String[] args = stripEmptyArgs(m_args);
    if (args.length > 4 || args.length < 2) {
        throw new IllegalArgumentException(m_usage);
    }// ww w .  ja  v a 2 s .  co  m
    m_jar = args[0];
    m_exeConf = URI.create(args[1]);
    if (args.length == 3) {
        if (NumberUtils.isDigits(args[2])) {
            m_tasks = Integer.parseInt(args[2]);
        } else {
            m_cluster = args[2];
        }
    } else if (args.length > 3) {
        m_cluster = args[2];
        m_tasks = Integer.parseInt(args[3]);
    }
}

From source file:ch.iterate.openstack.swift.model.Region.java

public URI getStorageUrl(String container, String object) {
    return URI.create(this.getStorageUrl() + "/" + encode(container) + "/" + encode(object));
}

From source file:com.orange.clara.cloud.servicedbdumper.task.asynctask.AbstractTaskTest.java

@Before
public void init() throws DatabaseExtractionException {
    initMocks(this);
    job = new Job();
    DatabaseRef databaseRef = new DatabaseRef("service-1", URI.create("mysql://user:pass@mysql.db:3306/mydb"));
    DbDumperServiceInstance dbDumperServiceInstance = new DbDumperServiceInstance();
    dbDumperServiceInstance.setDatabaseRef(databaseRef);
    job.setDatabaseRefSrc(databaseRef);/* w  w w. j  a v  a 2s.c om*/
    job.setDatabaseRefTarget(databaseRef);
    job.setDbDumperServiceInstance(dbDumperServiceInstance);
    when(jobRepo.findOne(anyInt())).thenReturn(job);
}

From source file:ch.cyberduck.core.analytics.QloudstatAnalyticsProvider.java

@Override
public String getName() {
    return URI.create(target).getHost();
}

From source file:util.TestUtil.java

/**
 * Mocks a ServiceInstance.//from  w w  w.java2s  .  com
 *
 * @param serviceName the name of the service.
 * @return the mock.
 */
public static ServiceInstance mockServiceInstance(String serviceName) {
    ServiceInstance result = new ServiceInstance() {
        @Override
        public String getServiceId() {
            return serviceName;
        }

        @Override
        public String getHost() {
            return "localhost";
        }

        @Override
        public int getPort() {
            return 80;
        }

        @Override
        public boolean isSecure() {
            return false;
        }

        @Override
        public URI getUri() {
            return URI.create("http://localhost/" + serviceName);
        }
    };
    return result;
}

From source file:com.opengamma.language.config.ConfigurationFactoryBean.java

public void setConfigurationURI(final String configurationUri) {
    ArgumentChecker.notNull(configurationUri, "configurationURI");
    _configurationUri = URI.create(configurationUri);
}

From source file:ch.cyberduck.core.googledrive.DriveUrlProvider.java

@Override
public DescriptiveUrlBag toUrl(Path file) {
    final DescriptiveUrlBag list = new DescriptiveUrlBag();
    if (file.isFile()) {
        try {//from w w  w.  java2 s  .  com
            if (StringUtils.isBlank(file.attributes().getVersionId())) {
                return DescriptiveUrlBag.empty();
            }
            final File f = session.getClient().files().get(file.attributes().getVersionId()).execute();
            if (StringUtils.isNotBlank(f.getWebContentLink())) {
                list.add(new DescriptiveUrl(URI.create(f.getWebContentLink()), DescriptiveUrl.Type.http,
                        MessageFormat.format(LocaleFactory.localizedString("{0} URL"), "HTTP")));
            }
            if (StringUtils.isNotBlank(f.getWebViewLink())) {
                list.add(new DescriptiveUrl(URI.create(f.getWebViewLink()), DescriptiveUrl.Type.http,
                        MessageFormat.format(LocaleFactory.localizedString("{0} URL"), "Download")));
            }
        } catch (IOException e) {
            new DriveExceptionMappingService().map(e);
        }
    }
    return list;
}

From source file:org.ssc.txtproc.TextProcessor.java

private HttpGet buildRequest(@NotNull Options opt) {
    HttpGet connMethod = new HttpGet(URI.create(mHost + ":" + mPort.toString()));

    if (opt.GetOriginalText)
        connMethod.setHeader("include_original_doc", "true");

    if (opt.GetTokens)
        connMethod.setHeader("include_tokens", "true");

    if (!opt.GetStops)
        connMethod.setHeader("exclude_stops", "true");

    if (opt.GetNonStops)
        connMethod.setHeader("include_non_stops", "true");

    if (opt.StemByPorter)
        connMethod.setHeader("run_porter", "true");

    if (opt.StemByLancaster)
        connMethod.setHeader("run_lancaster", "true");

    if (opt.MeasureByLeveshtineDistance)
        connMethod.setHeader("calculate_levenshtine", "true");

    if (opt.MeasureByJaroWinkler)
        connMethod.setHeader("calculate_jaro_winkler", "true");

    if (opt.GetNGrams > 0)
        connMethod.setHeader("include_n_grams", (new Integer(opt.GetNGrams)).toString());

    return connMethod;
}

From source file:com.cognifide.qa.bb.proxy.analyzer.predicate.RequestPredicateImpl.java

@Override
public boolean accepts(HttpRequest request) {
    boolean result = false;
    URI uri = URI.create(request.getUri());
    String path = uri.getPath();//  w w  w  . jav  a 2  s. c o m
    if (path != null && path.startsWith(urlPrefix)) {
        String query = uri.getQuery();
        if (expectedParams.isEmpty() && StringUtils.isEmpty(query)) {
            result = true;
        } else if (StringUtils.isNotEmpty(query)) {
            List<NameValuePair> params = URLEncodedUtils.parse(query, Charsets.UTF_8);
            result = hasAllExpectedParams(expectedParams, params);
        }
    }
    return result;
}

From source file:com.seajas.search.contender.service.builder.RSSDirectoryBuilder.java

/**
 * Create a UTF-8 stream containing the contents of the directory as a stream.
 *
 * @param directory//from  www  .j  a v  a2  s .c o m
 * @return InputStream
 * @throws IOException
 */
public static InputStream build(final File directory) throws IOException {
    if (!directory.isDirectory())
        throw new IllegalStateException("The given handle is not a directory");

    // Create a simple feed

    SyndFeedImpl feed = new SyndFeedImpl();

    feed.setEntries(new ArrayList<SyndEntry>());

    // Then add the entries to it

    Map<String, Long> files = travelDirectory(directory, new HashMap<String, Long>());

    for (Map.Entry<String, Long> file : files.entrySet()) {
        SyndEntryImpl entry = new SyndEntryImpl();

        entry.setUri("file://" + file.getKey());
        entry.setTitle(file.getKey());
        entry.setPublishedDate(new Date(file.getValue()));

        feed.getEntries().add(entry);
    }

    // And serialize it to an InputStream

    SyndFeedOutput serializer = new SyndFeedOutput();

    try {
        WebFeeds.validate(feed, URI.create("file://" + directory.getAbsolutePath()));

        return IOUtils.toInputStream(serializer.outputString(feed, true));
    } catch (FeedException e) {
        throw new IOException("Unable to serialize stream", e);
    }
}