Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.common.utils
Class IdUtils

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

public final class IdUtils
extends Object

Utils for identifier generation.

Author:
Anahide Tchertchian

Field Summary
static Pattern STUPID_REGEXP
           
 
Method Summary
static String generateId(String s)
          Deprecated. use generatePathSegment(java.lang.String) instead, or generateId(String, String, boolean, int) depending on the use cases
static String generateId(String s, String wordSeparator, boolean lower, int maxChars)
          Generates an id from a non-null String.
static long generateLongId()
          Generates an unique long identifier.
static String generatePathSegment(String s)
          Deprecated. use PathSegmentService instead
static 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 Pattern STUPID_REGEXP
Method Detail

generateStringId

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


generateLongId

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


generateId

public static String generateId(String s,
                                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 String generateId(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 String generatePathSegment(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 ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.