com.eaio.uuid
Class UUIDGen

java.lang.Object
  extended by com.eaio.uuid.UUIDGen

public final class UUIDGen
extends Object

This class contains methods to generate UUID fields. These methods have been refactored out of UUID.

Starting with version 2, this implementation tries to obtain the MAC address of the network card. Under Microsoft Windows, the ifconfig command is used which may pop up a command window in Java Virtual Machines prior to 1.4 once this class is initialized. The command window is closed automatically.

The MAC address code has been tested extensively in Microsoft Windows, Linux, Solaris 8, HP-UX 11, but should work in MacOS X and BSDs, too.

If you use JDK 6 or later, the code in InterfaceAddress will be used.

Version:
$Id: UUIDGen.java 2914 2010-04-23 11:35:00Z johann $
Author:
Johann Burkard
See Also:
UUID, UUID

Method Summary
static long createTime(long currentTimeMillis)
          Creates a new time field from the given timestamp.
static long getClockSeqAndNode()
          Returns the current clockSeqAndNode value.
static String getMACAddress()
          Returns the MAC address.
static long newTime()
          Generates a new time field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getClockSeqAndNode

public static long getClockSeqAndNode()
Returns the current clockSeqAndNode value.

Returns:
the clockSeqAndNode value
See Also:
UUID.getClockSeqAndNode()

newTime

public static long newTime()
Generates a new time field. Each time field is unique and larger than the previously generated time field.

Returns:
a new time value
See Also:
UUID.getTime()

createTime

public static long createTime(long currentTimeMillis)
Creates a new time field from the given timestamp. Note that even identical values of currentTimeMillis will produce different time fields.

Parameters:
currentTimeMillis - the timestamp
Returns:
a new time value
See Also:
UUID.getTime()

getMACAddress

public static String getMACAddress()
Returns the MAC address. Not guaranteed to return anything.

Returns:
the MAC address, may be null


Copyright © 2003-2011. All Rights Reserved.