UriEncodingHelper

com.github.cloudfiles.core.http.UriEncodingHelper

An object providing functionality to encode and normalize URIs.

Many of the concrete ''FileSystem'' implementations have to manipulate URIs. This helper class provides some utility functionality in this area. It supports encoding and decoding URIs and their components, splitting URIs into their path components, concatenating path components, etc.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def componentCount(uri: String): Int

Returns the number of components of the given URI. This is defined as the number of separator characters contained in the URI.

Returns the number of components of the given URI. This is defined as the number of separator characters contained in the URI.

Value parameters

uri

the URI

Attributes

Returns

the number of components the URI consists of

def decode(s: String): String

URL-decodes the specified string. This function assumes that ''encode()'' has been used for the encoding.

URL-decodes the specified string. This function assumes that ''encode()'' has been used for the encoding.

Value parameters

s

the string to be decoded

Attributes

Returns

the decoded string

def decodeComponents(uri: String): String

Decodes all the components of the given URI. Works like ''encodeComponents()'', but applies decoding to the single components.

Decodes all the components of the given URI. Works like ''encodeComponents()'', but applies decoding to the single components.

Value parameters

uri

the URI

Attributes

Returns

the URI with its components decoded

def encode(s: String): String

URL-encodes the specified string. This is very similar to what Java's ''URLEncoder'' does; however, space characters are encoded using %20.

URL-encodes the specified string. This is very similar to what Java's ''URLEncoder'' does; however, space characters are encoded using %20.

Value parameters

s

the string to be encoded

Attributes

Returns

the encoded string

def encodeComponents(uri: String): String

Encodes all the components of the given URI. Note that it is typically not possible to encode the URI as a whole because then the separators will be encoded as well. This function splits the URI into its components first, then applies the encoding, and finally combines the parts to the resulting URI.

Encodes all the components of the given URI. Note that it is typically not possible to encode the URI as a whole because then the separators will be encoded as well. This function splits the URI into its components first, then applies the encoding, and finally combines the parts to the resulting URI.

Value parameters

uri

the URI

Attributes

Returns

the URI with its components encoded

def fromComponents(components: Seq[String]): String

Creates a URI string from the given components. The components are combined using the URI separator.

Creates a URI string from the given components. The components are combined using the URI separator.

Value parameters

components

the sequence with components

Attributes

Returns

the resulting URI

def fromComponentsWithEncode(components: Seq[String]): String

Creates a URI string from the given components that need to be encoded first. The encoded components are combined using the URI separator.

Creates a URI string from the given components that need to be encoded first. The encoded components are combined using the URI separator.

Value parameters

components

the sequence with components

Attributes

Returns

the resulting URI

def hasLeadingSeparator(uri: String): Boolean

Returns a flag whether the passed in URI string starts with a separator character.

Returns a flag whether the passed in URI string starts with a separator character.

Value parameters

uri

the URI to be checked

Attributes

Returns

'''true''' if the URI starts with a seprator; '''false''' otherwise

def hasParent(uri: String): Boolean

Checks whether the given URI has a parent element. If this function returns '''false''' the URI points to a top-level element in the iteration.

Checks whether the given URI has a parent element. If this function returns '''false''' the URI points to a top-level element in the iteration.

Value parameters

uri

the URI in question

Attributes

Returns

a flag whether this URI has a parent element

def hasTrailingSeparator(uri: String): Boolean

Returns a flag whether the passed in URI string ends with a separator character.

Returns a flag whether the passed in URI string ends with a separator character.

Value parameters

uri

the URI to be checked

Attributes

Returns

'''true''' if the URI ends with a separator; '''false''' otherwise

def mapComponents(uri: String)(f: String => String): String

Transforms a URI by applying the given mapping function to all its components. The URI is split into components, then the function is executed on each component, and finally the components are combined again.

Transforms a URI by applying the given mapping function to all its components. The URI is split into components, then the function is executed on each component, and finally the components are combined again.

Value parameters

f

the mapping function for components

uri

the URI

Attributes

Returns

the resulting URI

def removeLeading(s: String, prefix: String): String

Removes the given prefix from the string if it exists. If the string does not start with this prefix, it is not changed.

Removes the given prefix from the string if it exists. If the string does not start with this prefix, it is not changed.

Value parameters

prefix

the prefix to remove

s

the string

Attributes

Returns

the resulting string

def removeLeadingSeparator(uri: String): String

Removes a leading separator from the given URI if it is present. Otherwise, the URI is returned as is.

Removes a leading separator from the given URI if it is present. Otherwise, the URI is returned as is.

Value parameters

uri

the URI

Attributes

Returns

the URI with a leading separator removed

def removeTrailing(s: String, c: String): String

Removes the given character from the string if it is the last one. If the string does not end with this character, it is not changed.

Removes the given character from the string if it is the last one. If the string does not end with this character, it is not changed.

Value parameters

c

the character to remove

s

the string

Attributes

Returns

the resulting string

def removeTrailingSeparator(uri: String): String

Removes a trailing separator from the passed in URI if it is present. If the URI does not end with a separator, it is returned as is.

Removes a trailing separator from the passed in URI if it is present. If the URI does not end with a separator, it is returned as is.

Value parameters

uri

the URI

Attributes

Returns

the URI with a trailing separator removed

def splitAndDecodeComponents(uri: String): Seq[String]

Splits the given URI into its components separated by the URI separator and then applies URL decoding to the resulting components. This is useful for URI paths pointing to hierarchical file systems; after the decoding, the components contain the correct names of folders and files.

Splits the given URI into its components separated by the URI separator and then applies URL decoding to the resulting components. This is useful for URI paths pointing to hierarchical file systems; after the decoding, the components contain the correct names of folders and files.

Value parameters

uri

the URI to be split

Attributes

Returns

a sequence with the single components

def splitComponents(uri: String): Seq[String]

Splits the given URI into its components separated by the URI separator.

Splits the given URI into its components separated by the URI separator.

Value parameters

uri

the URI to be split

Attributes

Returns

an array with the single components

def splitParent(uri: String): (String, String)

Splits the given URI in a parent URI and a name. This function determines the position of the last name component in the given URI. The URI is split at this position, and both strings are returned. The separator is not contained in any of these components, i.e. the parent URI does not end with a separator nor does the name start with one. If the URI has no parent, the resulting parent string is empty. If the URI just consists of the scheme and the authorization, it is returned in the parent string, and the name is empty.

Splits the given URI in a parent URI and a name. This function determines the position of the last name component in the given URI. The URI is split at this position, and both strings are returned. The separator is not contained in any of these components, i.e. the parent URI does not end with a separator nor does the name start with one. If the URI has no parent, the resulting parent string is empty. If the URI just consists of the scheme and the authorization, it is returned in the parent string, and the name is empty.

Value parameters

uri

the URI to be split

Attributes

Returns

a tuple with the parent URI and the name component

def withLeadingSeparator(uri: String): String

Makes sure that the passed in URI starts with a separator. A separator is added in front if and only if the passed in string does not already start with one.

Makes sure that the passed in URI starts with a separator. A separator is added in front if and only if the passed in string does not already start with one.

Value parameters

uri

the URI to be checked

Attributes

Returns

the URI with a leading separator

def withTrailingSeparator(uri: String): String

Makes sure that the passed in URI ends with a separator. A separator is added if and only if the passed in string does not already end with one.

Makes sure that the passed in URI ends with a separator. A separator is added if and only if the passed in string does not already end with one.

Value parameters

uri

the URI to be checked

Attributes

Returns

the URI ending with a separator

Concrete fields

final val UriSeparator: "/"

Constant for the path separator character in URIs.

Constant for the path separator character in URIs.

Attributes