Java URI Create create(final String uri)

Here you can find the source of create(final String uri)

Description

Creates or obtains a new URI;.

License

Apache License

Parameter

Parameter Description
uri the uri

Return

the uri

Declaration

public static URI create(final String uri) 

Method Source Code

//package com.java2s;
/*//from w w w.  j  a  va2 s  . co m
 * Copyright: Almende B.V. (2014), Rotterdam, The Netherlands
 * License: The Apache Software License, Version 2.0
 */

import java.lang.ref.WeakReference;
import java.net.URI;

import java.util.HashMap;
import java.util.Map;

public class Main {
    private static final Map<String, WeakReference<URI>> uris = new HashMap<String, WeakReference<URI>>(100);

    /**
     * Creates or obtains a new URI;.
     *
     * @param uri
     *            the uri
     * @return the uri
     */
    public static URI create(final String uri) {
        final WeakReference<URI> ref = uris.get(uri);
        if (ref != null) {
            final URI res = ref.get();
            if (res != null) {
                return res;
            }
        }
        final URI newUri = URI.create(uri.intern());
        uris.put(uri, new WeakReference<URI>(newUri));
        return newUri;
    }
}

Related

  1. addQueryParamsToUri(String uri, Map queryParams)
  2. addQueryString(final URI uri, final String queryString)
  3. convertToURI(String uriOrPath)
  4. convertToURI(String uriString, Map aliasMap)
  5. convertToURI(String value)
  6. createAbsoluteURI(URI base, String uri)
  7. createConnection(final String uri, final String authValue)
  8. createDatastream(String registrationUri, String APIKey, String xmlDescription)
  9. createDefaultName(final String uri)