Nuxeo Enterprise Platform 5.4

org.nuxeo.common.utils
Class IdUtils

java.lang.Object
  extended by org.nuxeo.common.utils.IdUtils

public final class IdUtils
extends java.lang.Object

Utils for identifier generation.

Author:
Anahide Tchertchian

Field Summary
static java.util.regex.Pattern STUPID_REGEXP
           
 
Method Summary
static java.lang.String generateId(java.lang.String s)
          Deprecated. use generatePathSegment(java.lang.String) instead, or generateId(String, String, boolean, int) depending on the use cases
static java.lang.String generateId(java.lang.String s, java.lang.String wordSeparator, boolean lower, int maxChars)
          Generates an id from a non-null String.
static long generateLongId()
          Generates an unique long identifier.
static java.lang.String generatePathSegment(java.lang.String s)
          Deprecated. use PathSegmentService instead
static java.lang.String generateStringId()
          Generates an unique string identifier.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STUPID_REGEXP

public static final java.util.regex.Pattern STUPID_REGEXP
Method Detail

generateStringId

public static java.lang.String generateStringId()
Generates an unique string identifier.


generateLongId

public static long generateLongId()
Generates an unique long identifier.


generateId

public static java.lang.String generateId(java.lang.String s,
                                          java.lang.String wordSeparator,
                                          boolean lower,
                                          int maxChars)
Generates an id from a non-null String.

Replaces accented characters from a string by their ascii equivalent, removes non alphanumerical characters and replaces spaces by the given wordSeparator character.

Parameters:
s - the original String
wordSeparator - the word separator to use (usually '-')
lower - if lower is true, remove upper case
maxChars - maximum longer of identifier characters
Returns:
the identifier String

generateId

@Deprecated
public static java.lang.String generateId(java.lang.String s)
Deprecated. use generatePathSegment(java.lang.String) instead, or generateId(String, String, boolean, int) depending on the use cases

Generates an id from a non-null String.

Uses default values for wordSeparator: '-', lower: true, maxChars: 24.


generatePathSegment

@Deprecated
public static java.lang.String generatePathSegment(java.lang.String s)
Deprecated. use PathSegmentService instead

Generates a Nuxeo path segment from a non-null String.

Basically all characters are kept, except for slashes and initial/trailing spaces.


Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.