com.vaadin.shared.util
Class SharedUtil

java.lang.Object
  extended by com.vaadin.shared.util.SharedUtil
All Implemented Interfaces:
java.io.Serializable

public class SharedUtil
extends java.lang.Object
implements java.io.Serializable

Misc internal utility methods used by both the server and the client package.

Since:
7.1
Author:
Vaadin Ltd
See Also:
Serialized Form

Field Summary
static java.lang.String SIZE_PATTERN
          RegEx pattern to extract the width/height values.
 
Constructor Summary
SharedUtil()
           
 
Method Summary
static java.lang.String addGetParameters(java.lang.String uri, java.lang.String extraParams)
          Adds the get parameters to the uri and returns the new uri that contains the parameters.
static java.lang.String camelCaseToHumanFriendly(java.lang.String camelCaseString)
          Converts a camelCaseString to a human friendly format (Camel case string).
static java.lang.String capitalize(java.lang.String string)
          Capitalizes the first character in the given string in a way suitable for use in code (methods, properties etc)
static java.lang.String dashSeparatedToCamelCase(java.lang.String dashSeparated)
          Converts a dash ("-") separated string into camelCase.
static boolean equals(java.lang.Object o1, java.lang.Object o2)
          Checks if a and b are equals using Object.equals(Object).
static java.lang.String join(java.lang.String[] parts, java.lang.String separator)
          Joins the words in the input array together into a single string by inserting the separator string between each word.
static java.lang.String propertyIdToHumanFriendly(java.lang.Object propertyId)
          Converts a property id to a human friendly format.
static java.lang.String[] splitCamelCase(java.lang.String camelCaseString)
          Splits a camelCaseString into an array of words with the casing preserved.
static java.lang.String trimTrailingSlashes(java.lang.String value)
          Trims trailing slashes (if any) from a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZE_PATTERN

public static final java.lang.String SIZE_PATTERN
RegEx pattern to extract the width/height values.

See Also:
Constant Field Values
Constructor Detail

SharedUtil

public SharedUtil()
Method Detail

equals

public static boolean equals(java.lang.Object o1,
                             java.lang.Object o2)
Checks if a and b are equals using Object.equals(Object). Handles null values as well. Does not ensure that objects are of the same type. Assumes that the first object's equals method handle equals properly.

Parameters:
o1 - The first value to compare
o2 - The second value to compare
Returns:
true if the objects are equal, false otherwise

trimTrailingSlashes

public static java.lang.String trimTrailingSlashes(java.lang.String value)
Trims trailing slashes (if any) from a string.

Parameters:
value - The string value to be trimmed. Cannot be null.
Returns:
String value without trailing slashes.

splitCamelCase

public static java.lang.String[] splitCamelCase(java.lang.String camelCaseString)
Splits a camelCaseString into an array of words with the casing preserved.

Parameters:
camelCaseString - The input string in camelCase format
Returns:
An array with one entry per word in the input string
Since:
7.4

camelCaseToHumanFriendly

public static java.lang.String camelCaseToHumanFriendly(java.lang.String camelCaseString)
Converts a camelCaseString to a human friendly format (Camel case string).

In general splits words when the casing changes but also handles special cases such as consecutive upper case characters. Examples:

MyBeanContainer becomes My Bean Container AwesomeURLFactory becomes Awesome URL Factory SomeUriAction becomes Some Uri Action

Parameters:
camelCaseString - The input string in camelCase format
Returns:
A human friendly version of the input
Since:
7.4

join

public static java.lang.String join(java.lang.String[] parts,
                                    java.lang.String separator)
Joins the words in the input array together into a single string by inserting the separator string between each word.

Parameters:
parts - The array of words
separator - The separator string to use between words
Returns:
The constructed string of words and separators
Since:
7.4

capitalize

public static java.lang.String capitalize(java.lang.String string)
Capitalizes the first character in the given string in a way suitable for use in code (methods, properties etc)

Parameters:
string - The string to capitalize
Returns:
The capitalized string
Since:
7.4

propertyIdToHumanFriendly

public static java.lang.String propertyIdToHumanFriendly(java.lang.Object propertyId)
Converts a property id to a human friendly format. Handles nested properties by only considering the last part, e.g. "address.streetName" is equal to "streetName" for this method.

Parameters:
propertyId - The propertyId to format
Returns:
A human friendly version of the property id
Since:
7.4

addGetParameters

public static java.lang.String addGetParameters(java.lang.String uri,
                                                java.lang.String extraParams)
Adds the get parameters to the uri and returns the new uri that contains the parameters.

Parameters:
uri - The uri to which the parameters should be added.
extraParams - One or more parameters in the format "a=b" or "c=d&e=f". An empty string is allowed but will not modify the url.
Returns:
The modified URI with the get parameters in extraParams added.

dashSeparatedToCamelCase

public static java.lang.String dashSeparatedToCamelCase(java.lang.String dashSeparated)
Converts a dash ("-") separated string into camelCase.

Examples:

foo becomes foo foo-bar becomes fooBar foo--bar becomes fooBar

Parameters:
dashSeparated - The dash separated string to convert
Returns:
a camelCase version of the input string
Since:
7.5


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.