Tabnine Logo
URL.getRef
Code IndexAdd Tabnine to your IDE (free)

How to use
getRef
method
in
java.net.URL

Best Java code snippets using java.net.URL.getRef (Showing top 20 results out of 2,250)

Refine searchRefine arrow

  • URL.getQuery
  • URL.getPath
  • URL.getProtocol
  • URL.getHost
  • URL.getPort
  • URL.<init>
origin: stackoverflow.com

 String urlStr = "http://abc.dev.domain.com/0007AC/ads/800x480 15sec h.264.mp4";
URL url = new URL(urlStr);
URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
url = uri.toURL();
origin: robovm/robovm

/**
 * Returns true if {@code a} and {@code b} have the same protocol, host,
 * port, file, and reference.
 */
protected boolean equals(URL a, URL b) {
  return sameFile(a, b)
      && Objects.equal(a.getRef(), b.getRef())
      && Objects.equal(a.getQuery(), b.getQuery());
}
origin: robovm/robovm

String toExternalForm(URL url, boolean escapeIllegalCharacters) {
  StringBuilder result = new StringBuilder();
  result.append(url.getProtocol());
  result.append(':');
  String ref = url.getRef();
  if (ref != null) {
    result.append('#');
origin: multidots/android-app-common-tasks

/**
 * Parse a URL query and fragment parameters into a key-value bundle.
 *
 * @param url the URL to parse
 * @return a dictionary bundle of keys and values
 */
public static Map<String, String> parseUrl(String url) {
  // hack to prevent MalformedURLException
  url = url.replace("fbconnect", "http");
  try {
    URL u = new URL(url);
    Map<String, String> params = decodeUrl(u.getQuery());
    params.putAll(decodeUrl(u.getRef()));
    return params;
  } catch (MalformedURLException e) {
    return new HashMap<>();
  }
}
origin: bytedeco/javacpp

  urlFile = new File(new URI(resourceURL.toString().split("#")[0]));
} catch (IllegalArgumentException | URISyntaxException e) {
  urlFile = new File(resourceURL.getPath());
  timestamp = urlConnection.getLastModified();
  if (!noSubdir) {
    String path = resourceURL.getHost() + resourceURL.getPath();
    cacheSubdir = new File(cacheSubdir, path.substring(0, path.lastIndexOf('/') + 1));
if (resourceURL.getRef() != null) {
  String newName = resourceURL.getRef();
origin: geoserver/geoserver

assertTrue(graphic instanceof ExternalGraphic);
assertEquals(
    ((ExternalGraphic) graphic).getLocation().getPath(),
    iconFile.toURI().toURL().getPath());
assertEquals("param1=1", ((ExternalGraphic) graphic).getLocation().getQuery());
assertEquals("textAfterHash", ((ExternalGraphic) graphic).getLocation().getRef());
origin: stackoverflow.com

 String urlStr = "http://abc.dev.domain.com/0007AC/ads/800x480 15sec h.264.mp4";
URL url = new URL(urlStr);
URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
url = uri.toURL();
origin: multidots/android-app-common-tasks

/**
 * Parse a URL query and fragment parameters into a key-value bundle.
 *
 * @param url the URL to parse
 * @return a dictionary bundle of keys and values
 */
public static Map<String, String> parseUrl(String url) {
  // hack to prevent MalformedURLException
  url = url.replace("fbconnect", "http");
  try {
    URL u = new URL(url);
    Map<String, String> params = decodeUrl(u.getQuery());
    params.putAll(decodeUrl(u.getRef()));
    return params;
  } catch (MalformedURLException e) {
    return new HashMap<>();
  }
}
origin: stackoverflow.com

String urlStr = "http://www.example.com/CERECĀ® Materials & Accessories/IPS EmpressĀ® CAD.pdf"
 URL url= new URL(urlStr);
 URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
origin: stackoverflow.com

 public URL convertToURLEscapingIllegalCharacters(String string){
  try {
    String decodedURL = URLDecoder.decode(string, "UTF-8");
    URL url = new URL(decodedURL);
    URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); 
    return uri.toURL(); 
  } catch (Exception ex) {
    ex.printStackTrace();
    return null;
  }
}
origin: stackoverflow.com

 String urlStr = "http://abc.dev.domain.com/0007AC/ads/800x480 15sec h.264.mp4";
URL url = new URL(urlStr);
URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
url = uri.toURL();
origin: stackoverflow.com

 URL url = new URL("protocol://user:password@host:port/path/document?arg1=val1&arg2=val2#part");
url.getProtocol();
url.getUserInfo();
url.getAuthority();
url.getHost();
url.getPort();
url.getPath(); // document part is contained within the path field
url.getQuery();
url.getRef(); // gets #part
origin: oracle/opengrok

/**
 * Encode URL
 *
 * @param urlStr string URL
 * @return the encoded URL
 * @throws URISyntaxException URI syntax
 * @throws MalformedURLException URL malformed
 */
public static String encodeURL(String urlStr) throws URISyntaxException, MalformedURLException {
  URL url = new URL(urlStr);
  URI constructed = new URI(url.getProtocol(), url.getUserInfo(),
      url.getHost(), url.getPort(),
      url.getPath(), url.getQuery(), url.getRef());
  return constructed.toString();
}
origin: stackoverflow.com

 public URL parseUrl(String s) throws Exception {
   URL u = new URL(s);
   return new URI(
      u.getProtocol(), 
      u.getAuthority(), 
      u.getPath(),
      u.getQuery(), 
      u.getRef()).
      toURL();
}
origin: stackoverflow.com

 import java.net.*;
import java.io.*;

public class ParseURL {
 public static void main(String[] args) throws Exception {

  URL aURL = new URL("http://example.com:80/docs/books/tutorial"
            + "/index.html?name=networking#DOWNLOADING");

  System.out.println("protocol = " + aURL.getProtocol()); //http
  System.out.println("authority = " + aURL.getAuthority()); //example.com:80
  System.out.println("host = " + aURL.getHost()); //example.com
  System.out.println("port = " + aURL.getPort()); //80
  System.out.println("path = " + aURL.getPath()); //  /docs/books/tutorial/index.html
  System.out.println("query = " + aURL.getQuery()); //name=networking
  System.out.println("filename = " + aURL.getFile()); ///docs/books/tutorial/index.html?name=networking
  System.out.println("ref = " + aURL.getRef()); //DOWNLOADING
 }
}
origin: EngineHub/WorldEdit

/**
 * URL may contain spaces and other nasties that will cause a failure.
 *
 * @param existing the existing URL to transform
 * @return the new URL, or old one if there was a failure
 */
private static URL reformat(URL existing) {
  try {
    URL url = new URL(existing.toString());
    URI uri = new URI(
        url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(),
        url.getPath(), url.getQuery(), url.getRef());
    url = uri.toURL();
    return url;
  } catch (MalformedURLException e) {
    return existing;
  } catch (URISyntaxException e) {
    return existing;
  }
}
origin: apache/hive

private String evaluate(URL url, int index) {
 if (url == null || index < 0 || index >= partnames.length) {
  return null;
 }
 switch (partnames[index]) {
  case HOST          : return url.getHost();
  case PATH          : return url.getPath();
  case QUERY         : return url.getQuery();
  case REF           : return url.getRef();
  case PROTOCOL      : return url.getProtocol();
  case FILE          : return url.getFile();
  case AUTHORITY     : return url.getAuthority();
  case USERINFO      : return url.getUserInfo();
  case QUERY_WITH_KEY: return evaluateQuery(url.getQuery(), paths[index]);
  case NULLNAME:
  default            : return null;
 }
}
origin: spring-cloud/spring-cloud-config

/**
 * This provider can handle uris like https://git-codecommit.$AWS_REGION.amazonaws.com/v1/repos/$REPO
 * @see org.springframework.cloud.config.server.credentials.GitCredentialsProvider#canHandleUri(java.lang.String)
 */
public static boolean canHandle(String uri) {
  if (!hasText(uri)) {
    return false;
  }
  
  try {
     URL url = new URL(uri);
       URI u = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
    if (u.getScheme().equals("https")) {
      String host = u.getHost();
      if (host.endsWith(".amazonaws.com") && host.startsWith("git-codecommit.")) {
        return true;
      }
    }
  } catch (Throwable t) {
    // ignore all, we can't handle it
  }
  
  return false;
}
origin: apache/drill

private String evaluate(URL url, int index) {
 if (url == null || index < 0 || index >= partnames.length) {
  return null;
 }
 switch (partnames[index]) {
  case HOST          : return url.getHost();
  case PATH          : return url.getPath();
  case QUERY         : return url.getQuery();
  case REF           : return url.getRef();
  case PROTOCOL      : return url.getProtocol();
  case FILE          : return url.getFile();
  case AUTHORITY     : return url.getAuthority();
  case USERINFO      : return url.getUserInfo();
  case QUERY_WITH_KEY: return evaluateQuery(url.getQuery(), paths[index]);
  case NULLNAME:
  default            : return null;
 }
}
origin: datumbox/datumbox-framework

/**
 * This method splits a URL into parts and return a map containing them.
 * 
 * @param url
 * @return 
 */
public static Map<URLParts, String> splitURL(URL url) {
  Map<URLParts, String> urlParts = new HashMap<>();
  
  urlParts.put(URLParts.PROTOCOL, url.getProtocol());
  urlParts.put(URLParts.USERINFO, url.getUserInfo());
  urlParts.put(URLParts.AUTHORITY, url.getAuthority());
  urlParts.put(URLParts.HOST, url.getHost());
  urlParts.put(URLParts.PATH, url.getPath());
  urlParts.put(URLParts.QUERY, url.getQuery());
  urlParts.put(URLParts.FILENAME, url.getFile());
  urlParts.put(URLParts.REF, url.getRef());
  int port = url.getPort();
  if(port!=-1) {
    urlParts.put(URLParts.PORT, String.valueOf(port));
  }
  else {
    urlParts.put(URLParts.PORT, null);
  }
  
  return urlParts;
}

java.netURLgetRef

Javadoc

Returns the value of the reference part of this URL, or null if this URL has no reference part. This is also known as the fragment.

Popular methods of URL

  • <init>
  • openStream
    Opens a connection to this URL and returns anInputStream for reading from that connection. This meth
  • openConnection
    Returns a new connection to the resource referred to by this URL.
  • toString
    Constructs a string representation of this URL. The string is created by calling the toExternalForm
  • getPath
    Gets the path part of this URL.
  • toURI
    Returns a java.net.URI equivalent to this URL. This method functions in the same way as new URI (thi
  • getProtocol
    Gets the protocol name of this URL.
  • getFile
    Gets the file name of this URL. The returned file portion will be the same as getPath(), plus the c
  • toExternalForm
    Constructs a string representation of this URL. The string is created by calling the toExternalForm
  • getHost
    Gets the host name of this URL, if applicable. The format of the host conforms to RFC 2732, i.e. for
  • getPort
    Gets the port number of this URL.
  • getQuery
    Gets the query part of this URL.
  • getPort,
  • getQuery,
  • equals,
  • getUserInfo,
  • getAuthority,
  • hashCode,
  • getDefaultPort,
  • getContent,
  • setURLStreamHandlerFactory

Popular in Java

  • Reading from database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getExternalFilesDir (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • JButton (javax.swing)
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now