org.cruxframework.crux.core.server.rest.core
Class UriBuilder

java.lang.Object
  extended by org.cruxframework.crux.core.server.rest.core.UriBuilder

public class UriBuilder
extends Object

Version:
$Revision: 1 $
Author:
Bill Burke

Constructor Summary
UriBuilder()
           
 
Method Summary
 URI build(Object... values)
           
 URI buildFromMap(Map<String,? extends Object> paramMap, boolean fromEncodedMap)
           
protected  URI buildFromValues(boolean encoded, Object... values)
           
 UriBuilder clone()
           
static Matcher createUriParamMatcher(String string)
           
 UriBuilder fragment(String fragment)
           
static UriBuilder fromUri(String uriTemplate)
          Create a new instance initialized from an existing URI.
static UriBuilder fromUri(URI uri)
          Create a new instance initialized from an existing URI.
 String getFragment()
           
 String getHost()
           
 String getPath()
           
 List<String> getPathParamNamesInDeclarationOrder()
          Return a unique order list of path params
 int getPort()
           
 String getQuery()
           
 String getScheme()
           
 String getUserInfo()
           
 UriBuilder host(String host)
           
 UriBuilder path(Class<?> resource)
           
 UriBuilder path(Method method)
           
 UriBuilder path(String segment)
           
protected static String paths(boolean encode, String basePath, String... segments)
           
 UriBuilder port(int port)
           
protected  StringBuffer replaceParameter(Map<String,? extends Object> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer)
           
 UriBuilder replacePath(String path)
           
protected  StringBuffer replacePathParameter(String name, String value, boolean isEncoded, String string, StringBuffer buffer)
           
 UriBuilder replaceQuery(String query)
           
protected  StringBuffer replaceQueryStringParameter(Map<String,? extends Object> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer)
           
 UriBuilder scheme(String scheme)
           
 UriBuilder schemeSpecificPart(String ssp)
           
 UriBuilder uri(String uriTemplate)
           
 UriBuilder uri(URI uri)
           
 UriBuilder uriTemplate(String uriTemplate)
          You may put path parameters anywhere within the uriTemplate except port
 UriBuilder userInfo(String ui)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UriBuilder

public UriBuilder()
Method Detail

clone

public UriBuilder clone()
Overrides:
clone in class Object

uriTemplate

public UriBuilder uriTemplate(String uriTemplate)
You may put path parameters anywhere within the uriTemplate except port

Parameters:
uriTemplate -
Returns:

uri

public UriBuilder uri(String uriTemplate)
               throws IllegalArgumentException
Throws:
IllegalArgumentException

uri

public UriBuilder uri(URI uri)
               throws IllegalArgumentException
Throws:
IllegalArgumentException

scheme

public UriBuilder scheme(String scheme)
                  throws IllegalArgumentException
Throws:
IllegalArgumentException

schemeSpecificPart

public UriBuilder schemeSpecificPart(String ssp)
                              throws IllegalArgumentException
Throws:
IllegalArgumentException

userInfo

public UriBuilder userInfo(String ui)

host

public UriBuilder host(String host)
                throws IllegalArgumentException
Throws:
IllegalArgumentException

port

public UriBuilder port(int port)
                throws IllegalArgumentException
Throws:
IllegalArgumentException

paths

protected static String paths(boolean encode,
                              String basePath,
                              String... segments)

path

public UriBuilder path(String segment)
                throws IllegalArgumentException
Throws:
IllegalArgumentException

path

public UriBuilder path(Class<?> resource)
                throws IllegalArgumentException
Throws:
IllegalArgumentException

path

public UriBuilder path(Method method)
                throws IllegalArgumentException
Throws:
IllegalArgumentException

replaceQuery

public UriBuilder replaceQuery(String query)
                        throws IllegalArgumentException
Throws:
IllegalArgumentException

fragment

public UriBuilder fragment(String fragment)
                    throws IllegalArgumentException
Throws:
IllegalArgumentException

buildFromMap

public URI buildFromMap(Map<String,? extends Object> paramMap,
                        boolean fromEncodedMap)
                 throws IllegalArgumentException,
                        UriBuilderException
Throws:
IllegalArgumentException
UriBuilderException

replacePathParameter

protected StringBuffer replacePathParameter(String name,
                                            String value,
                                            boolean isEncoded,
                                            String string,
                                            StringBuffer buffer)

createUriParamMatcher

public static Matcher createUriParamMatcher(String string)

replaceParameter

protected StringBuffer replaceParameter(Map<String,? extends Object> paramMap,
                                        boolean fromEncodedMap,
                                        boolean isTemplate,
                                        String string,
                                        StringBuffer buffer)

replaceQueryStringParameter

protected StringBuffer replaceQueryStringParameter(Map<String,? extends Object> paramMap,
                                                   boolean fromEncodedMap,
                                                   boolean isTemplate,
                                                   String string,
                                                   StringBuffer buffer)

getPathParamNamesInDeclarationOrder

public List<String> getPathParamNamesInDeclarationOrder()
Return a unique order list of path params

Returns:

build

public URI build(Object... values)
          throws IllegalArgumentException,
                 UriBuilderException
Throws:
IllegalArgumentException
UriBuilderException

buildFromValues

protected URI buildFromValues(boolean encoded,
                              Object... values)

getHost

public String getHost()

getScheme

public String getScheme()

getPort

public int getPort()

getUserInfo

public String getUserInfo()

getPath

public String getPath()

getQuery

public String getQuery()

getFragment

public String getFragment()

replacePath

public UriBuilder replacePath(String path)

fromUri

public static UriBuilder fromUri(URI uri)
Create a new instance initialized from an existing URI.

Parameters:
uri - a URI that will be used to initialize the UriBuilder.
Returns:
a new UriBuilder.
Throws:
IllegalArgumentException - if uri is null.

fromUri

public static UriBuilder fromUri(String uriTemplate)
Create a new instance initialized from an existing URI.

Parameters:
uriTemplate - a URI template that will be used to initialize the UriBuilder, may contain URI parameters.
Returns:
a new UriBuilder.
Throws:
IllegalArgumentException - if uriTemplate is not a valid URI template or is null.


Copyright © 2014. All rights reserved.