public static Proxy buildProxyFromPacResult(String pacResult) {
    if (StringUtils.isBlank(pacResult) || pacResult.trim().toUpperCase(Locale.ENGLISH).startsWith(PAC_DIRECT)) {
      return Proxy.NO_PROXY;
    }
    String proxyDef = pacResult.trim();
    Proxy.Type type = Proxy.Type.HTTP;
    if (proxyDef.toUpperCase(Locale.ENGLISH).startsWith(PAC_SOCKS)) {
      type = Proxy.Type.SOCKS;
    } else if (!proxyDef.toUpperCase(Locale.ENGLISH).startsWith(PAC_PROXY)) {
      return Proxy.NO_PROXY;
    }

    String host = proxyDef.substring(PROXY_TYPE_LEN);
    Integer port = DEFAULT_PROXY_PORT;

    // Split port from host
    int indexOfPort = host.indexOf(':');
    if (indexOfPort != -1) {
      port = Integer.parseInt(host.substring(indexOfPort + 1).trim());
      host = host.substring(0, indexOfPort).trim();
    }

    SocketAddress adr = InetSocketAddress.createUnresolved(host, port);
    return new Proxy(type, adr);
  }
public static Proxy buildProxyFromPacResult(String pacResult) {
    if (StringUtils.isBlank(pacResult) || pacResult.trim().toUpperCase(Locale.ENGLISH).startsWith(PAC_DIRECT)) {
      return Proxy.NO_PROXY;
    }
    String proxyDef = pacResult.trim();
    Proxy.Type type = Proxy.Type.HTTP;
    if (proxyDef.toUpperCase(Locale.ENGLISH).startsWith(PAC_SOCKS)) {
      type = Proxy.Type.SOCKS;
    } else if (!proxyDef.toUpperCase(Locale.ENGLISH).startsWith(PAC_PROXY)) {
      return Proxy.NO_PROXY;
    }

    String host = proxyDef.substring(PROXY_TYPE_LEN);
    Integer port = DEFAULT_PROXY_PORT;

    
    int indexOfPort = host.indexOf(':');
    if (indexOfPort != -1) {
      port = Integer.parseInt(host.substring(indexOfPort + 1).trim());
      host = host.substring(0, indexOfPort).trim();
    }

    SocketAddress adr = InetSocketAddress.createUnresolved(host, port);
    return new Proxy(type, adr);
  }
public static Proxy buildProxyFromPacResult ( String pacResult ) { if ( StringUtils . isBlank ( pacResult ) || pacResult . trim ( ) . toUpperCase ( Locale . ENGLISH ) . startsWith ( PAC_DIRECT ) ) { return Proxy . NO_PROXY ; } String proxyDef = pacResult . trim ( ) ; Proxy . Type type = Proxy . Type . HTTP ; if ( proxyDef . toUpperCase ( Locale . ENGLISH ) . startsWith ( PAC_SOCKS ) ) { type = Proxy . Type . SOCKS ; } else if ( ! proxyDef . toUpperCase ( Locale . ENGLISH ) . startsWith ( PAC_PROXY ) ) { return Proxy . NO_PROXY ; } String host = proxyDef . substring ( PROXY_TYPE_LEN ) ; Integer port = DEFAULT_PROXY_PORT ; // Split port from host int indexOfPort = host . indexOf ( ' ' ) ; if ( indexOfPort != - 1 ) { port = Integer . parseInt ( host . substring ( indexOfPort + 1 ) . trim ( ) ) ; host = host . substring ( 0 , indexOfPort ) . trim ( ) ; } SocketAddress adr = InetSocketAddress . createUnresolved ( host , port ) ; return new Proxy ( type , adr ) ; }
***********************************************************************
The proxy evaluator will return a proxy string. This method will take this
string and build a matching <code>Proxy</code> for it.

@param pacResult
the result from the PAC parser.
@return a Proxy
**********************************************************************
*********************************************************************** The proxy evaluator will return a proxy string . This method will take this string and build a matching <code > Proxy< / code > for it .