rewrite-api-servlet 2.0.0.Alpha6

org.ocpsoft.rewrite.servlet.util
Class URLBuilder

java.lang.Object
  extended by org.ocpsoft.rewrite.servlet.util.URLBuilder

public class URLBuilder
extends Object

Utility for building URL strings. Also manages the URL query string with the help of QueryStringBuilder.

Author:
Lincoln Baxter, III

Method Summary
 URLBuilder addQueryParameters(String parameters)
          Parse and add more query parameters to this URLBuilder
 URLBuilder appendPathSegments(List<String> segments)
          Append additional path segments to the end of this URL.
 URLBuilder appendPathSegments(String segments)
          Append additional path segments to the end of this URL.
static URLBuilder createFrom(List<String> segments, Metadata metadata)
          Create a new instance of URLBuilder from the given URL path segments and Metadata.
static URLBuilder createFrom(List<String> segments, Metadata metadata, QueryStringBuilder query)
          Create a new instance of URLBuilder from the given URL segments, Metadata, and QueryStringBuilder.
static URLBuilder createFrom(String segments)
          Create a new instance of URLBuilder from the given URL path segments.
static URLBuilder createNew()
          Return a new instance of URLBuilder.
 URLBuilder decode()
          Return this URLBuilder after path segments and query parameters have been decoded.
 URLBuilder encode()
          Return this URLBuilder after path segments and query parameters have been encoded.
 String getEncoding()
          Get the character encoding of this URL (default UTF-8)
 Metadata getMetadata()
          Get the Metadata object for this URL
 QueryStringBuilder getQueryStringBuilder()
          Get the QueryStringBuilder object for this URL
 List<String> getSegments()
          Return all segments (separated by '/') in this URL
 boolean hasLeadingSlash()
          Return true if this URL begins with '/'
 boolean hasTrailingSlash()
          Return true if this URL ends with '/'
 int numSegments()
          Get the number of segments (separated by '/') in this URL
 void setEncoding(String encoding)
          Set the character encoding of this URL (default UTF-8)
 URLBuilder setMetadata(Metadata metadata)
          Set the Metadata object for this URL
 URLBuilder setQueryString(QueryStringBuilder query)
          Set the QueryStringBuilder object for this URL
 String toPath()
          Return the portion of this URL representing the path.
 String toString()
          Return a String representation of this URL
 URI toURI()
          Return a URI representation of this URL including path and query string
 String toURL()
          Return a String representation of this URL including path and query string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

createNew

public static URLBuilder createNew()
Return a new instance of URLBuilder. Until modified. This URL will be blank.


createFrom

public static URLBuilder createFrom(List<String> segments,
                                    Metadata metadata,
                                    QueryStringBuilder query)
Create a new instance of URLBuilder from the given URL segments, Metadata, and QueryStringBuilder.


createFrom

public static URLBuilder createFrom(List<String> segments,
                                    Metadata metadata)
Create a new instance of URLBuilder from the given URL path segments and Metadata.


createFrom

public static URLBuilder createFrom(String segments)
Create a new instance of URLBuilder from the given URL path segments.


appendPathSegments

public URLBuilder appendPathSegments(List<String> segments)
Append additional path segments to the end of this URL. When called the first time, this method will also initialize the Metadata for this URLBuilder based on the parsed segments given.


appendPathSegments

public URLBuilder appendPathSegments(String segments)
Append additional path segments to the end of this URL. When called the first time, this method will also initialize the Metadata for this URLBuilder based on the parsed segments given.


addQueryParameters

public URLBuilder addQueryParameters(String parameters)
Parse and add more query parameters to this URLBuilder


decode

public URLBuilder decode()
Return this URLBuilder after path segments and query parameters have been decoded.


encode

public URLBuilder encode()
Return this URLBuilder after path segments and query parameters have been encoded.


getEncoding

public String getEncoding()
Get the character encoding of this URL (default UTF-8)


getMetadata

public Metadata getMetadata()
Get the Metadata object for this URL


getQueryStringBuilder

public QueryStringBuilder getQueryStringBuilder()
Get the QueryStringBuilder object for this URL


setQueryString

public URLBuilder setQueryString(QueryStringBuilder query)
Set the QueryStringBuilder object for this URL


getSegments

public List<String> getSegments()
Return all segments (separated by '/') in this URL


hasLeadingSlash

public boolean hasLeadingSlash()
Return true if this URL begins with '/'


hasTrailingSlash

public boolean hasTrailingSlash()
Return true if this URL ends with '/'


numSegments

public int numSegments()
Get the number of segments (separated by '/') in this URL


setEncoding

public void setEncoding(String encoding)
Set the character encoding of this URL (default UTF-8)


setMetadata

public URLBuilder setMetadata(Metadata metadata)
Set the Metadata object for this URL


toPath

public String toPath()
Return the portion of this URL representing the path.


toString

public String toString()
Return a String representation of this URL

Overrides:
toString in class Object

toURI

public URI toURI()
Return a URI representation of this URL including path and query string


toURL

public String toURL()
Return a String representation of this URL including path and query string


rewrite-api-servlet 2.0.0.Alpha6

Copyright © 2013 OCPsoft. All Rights Reserved.