001 002 package railo.runtime.functions.other; 003 004 005 import org.safehaus.uuid.UUIDGenerator; 006 007 import railo.runtime.PageContext; 008 import railo.runtime.ext.function.Function; 009 010 /** 011 * Implements the Cold Fusion Function createuuid 012 */ 013 public final class CreateUUID implements Function { 014 private static UUIDGenerator generator = UUIDGenerator.getInstance(); 015 016 /** 017 * method to invoke the function 018 * @param pc 019 * @return UUID String 020 */ 021 public static String call(PageContext pc ) { 022 return invoke(); 023 } 024 public static String invoke() { 025 String uuid = generator.generateRandomBasedUUID().toString().toUpperCase(); 026 return new StringBuffer(uuid.substring(0,23)).append(uuid.substring(24)).toString(); 027 } 028 }