SHARE
TWEET

Untitled

a guest Dec 29th, 2016 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ar.edu.undav.ejemplo.config;
  2.  
  3. /**
  4.  * Juan Lagostena on 30/12/16
  5.  * .
  6.  */
  7. public class HerokuDatasourceParser {
  8.  
  9.     public static final String SEPARATOR = ":";
  10.     public static final String SLASH = "/";
  11.  
  12.     private String url;
  13.     private String username;
  14.     private String password;
  15.  
  16.     public void parseCompleteURL(String url) {
  17.         String[] urlFragments = url.split(SEPARATOR);
  18.  
  19.         this.username = urlFragments[2].substring(2);
  20.         String[] passwordAndHostFragments = urlFragments[3].split("@");
  21.         String host = passwordAndHostFragments[1];
  22.  
  23.         String[] portAndSchemaFragments = urlFragments[4].split(SLASH);
  24.  
  25.         this.password = passwordAndHostFragments[0];
  26.  
  27.         String port = portAndSchemaFragments[0];
  28.         String schema = portAndSchemaFragments[1];
  29.  
  30.         StringBuffer buffer = new StringBuffer();
  31.         this.url = buffer.append(urlFragments[0]).append(SEPARATOR).append(urlFragments[1]).append(SEPARATOR)
  32.                 .append(SLASH).append(SLASH).append(host).append(SEPARATOR).append(port).
  33.                         append("/").append(schema).toString();
  34.  
  35.     }
  36.  
  37.     public String getUrl() {
  38.         return url;
  39.     }
  40.  
  41.     public String getUsername() {
  42.         return username;
  43.     }
  44.  
  45.     public String getPassword() {
  46.         return password;
  47.     }
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top