Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 4b387bd

Browse files
committed
Direct port from Jug.
1 parent ea5c3a5 commit 4b387bd

19 files changed

+5892
-1
lines changed

CREDITS

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
Here are people who have contributed to JUG development:
2+
3+
Tatu Saloranta, [email protected]: Author
4+
5+
Leonid Kunin: suggested adding 2 constructors (that were missing);
6+
needed when storing binary representations of UUIDs
7+
(added to v0.9.2)
8+
[v 0.9.2]
9+
10+
Paul Blankenbaker: provided the native code for accessing Ethernet
11+
MAC-addresses (on linux/x86, Solaris/sparc, Windows); first
12+
included in 1.0.0 release.
13+
[v 1.0.0]
14+
15+
Gernot Koller: pointed out a bug in UUID.toByteArray() method; was
16+
not using offset (fixed in 1.0.1)
17+
[v 1.0.1]
18+
19+
Dominique Jean-Prost: Suggested that there should be alternate method
20+
of loading native libs (implemented in 1.0.2).
21+
Also pointed out that method 'setLibDir' should be public, not
22+
protected (fixed in 1.0.2).
23+
[v 1.0.2]
24+
25+
Jeff Woodward: Pointed and fixed a bug in UUID.toByteArray() method
26+
(not sure if Gernot's fix was somehow overwritten in codebase
27+
or what...).
28+
[v 1.0.3]
29+
30+
D.J Hagberg: Submitted native code to use with Mac OS X, to use for
31+
accessing MAC address of primary network interface (code should
32+
also work with *BSDs?).
33+
Also contributed improvements to Ant's build.xml.
34+
[v 1.0.3]
35+
36+
G�ran L�wkrantz: Submitted native code for FreeBSD/x86
37+
[v 1.1]
38+
39+
Eric Bie: Wrote full unit test suite, using JUnit! Really REALLY
40+
useful addition (old ad hoc tests needed replacement).
41+
Also cleaned up ant build file significantly.
42+
[v 1.1]
43+
44+
Bill Sarra: Pointed out and fix Windows native code bug that would
45+
under some circumstances cause infinite looping when trying to
46+
access MAC addresses of all interfaces.
47+
[v 1.1]
48+
49+
Ralf S. Engelschall: Pointed out and fixed a bug in generating
50+
dummy broadcast ethernet addresses; interpretation of LSB/MSB
51+
was incorrect with respect to ethernet broadcast & structs.
52+
[v 1.1]
53+
54+
Wolfgang Hoschek: Suggested useful improvement to random UUIDs;
55+
there's no requirement for API to enforce use of SecureRandom.
56+
Thus, code now only expects Random, although still creates
57+
SecureRandom if no explicit generator is passed. This can help
58+
in reducing startup time of generator, as well as max. rate
59+
of UUID generation, depending on how quickly Random instance
60+
can be initialized & generates new numbers.
61+
62+
Jonas F�gedi: Contributed the patch to check for FreeBSD platform
63+
(which actually was part of an earlier patch that I somehow had
64+
managed not to get in... :-/ )
65+
[v 1.1.1]
66+
67+
David Pawson: Pointed out that the jar file was missing the necessary
68+
Main-Class definition, which prevented it from being invoked from
69+
command line using -jar switch.
70+
[v 1.1.2]
71+
72+
Pekka Enberg: Pointed out a bug in Linux JNI code; the socket was not
73+
properly closed
74+
[v 2.0.0]
75+
76+
Thomas Wernitz: Pointed out a problem with MacOS JNI code; wasn't
77+
properly looping through the interfaces
78+
[v 2.0.0]
79+
80+
Asher Glynn: Suggested usefulness of external file-based synchronization,
81+
to ensure that system clock moving backwards during reboot does not
82+
compromise uniqueness of produced UUIDs (which is obviously also mentioned
83+
in UUID specs, but previously not implemented in Jug).
84+
[v 2.0.0]
85+
86+
Wim Deblauwe: Pointed out problems with 2.0rc3 jars (missing
87+
com.ccg.net.ethernet package, no downloadable JNI code).
88+
[v 2.0rc3]
89+
90+
Klaus Rheinwald: Contributed non-netbios Windows JNI code for accessing
91+
Ethernet addresses
92+
[v 2.0rc5]
93+
94+
Tommi Laukkanen: Port to C#.
95+
[v 2.0.0]

Mug.csproj

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>9.0.30729</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{148CF4A3-3B6A-4326-83BE-6D51389AF298}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>Jug</RootNamespace>
12+
<AssemblyName>Jug</AssemblyName>
13+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<TargetFrameworkSubset>
16+
</TargetFrameworkSubset>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="nunit.framework, Version=2.5.3.9345, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
37+
<SpecificVersion>False</SpecificVersion>
38+
<HintPath>..\lib\nunit.framework.dll</HintPath>
39+
</Reference>
40+
<Reference Include="System" />
41+
<Reference Include="System.Core">
42+
<RequiredTargetFramework>3.5</RequiredTargetFramework>
43+
</Reference>
44+
<Reference Include="System.Xml.Linq">
45+
<RequiredTargetFramework>3.5</RequiredTargetFramework>
46+
</Reference>
47+
<Reference Include="System.Data.DataSetExtensions">
48+
<RequiredTargetFramework>3.5</RequiredTargetFramework>
49+
</Reference>
50+
<Reference Include="System.Data" />
51+
<Reference Include="System.Xml" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<Compile Include="Properties\AssemblyInfo.cs" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<Compile Include="TagURI.cs" />
58+
<Compile Include="Test\TagURITest.cs" />
59+
<Compile Include="Test\TestBase.cs" />
60+
<Compile Include="Test\UUIDGeneratorTest.cs" />
61+
<Compile Include="Test\TestUtil.cs" />
62+
<Compile Include="Test\UUIDTest.cs" />
63+
<Compile Include="Test\UUIDTimerTest.cs" />
64+
<Compile Include="TimestampSynchronizer.cs" />
65+
<Compile Include="UUID.cs" />
66+
<Compile Include="UUIDGenerator.cs" />
67+
<Compile Include="UUIDTimer.cs" />
68+
</ItemGroup>
69+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
70+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
71+
Other similar extension points exist, see Microsoft.Common.targets.
72+
<Target Name="BeforeBuild">
73+
</Target>
74+
<Target Name="AfterBuild">
75+
</Target>
76+
-->
77+
</Project>

Properties/AssemblyInfo.cs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Jug")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Microsoft")]
12+
[assembly: AssemblyProduct("Jug")]
13+
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("5a2d98f4-aa75-4e73-a989-bd033b9380bc")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

README

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"Test"
1+
Mono Uuid Generator (Mug) is a library for generating all (3) types of UUIDs on Mono and is direct translation from Java Uuid Generator (JUG).

TagURI.cs

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/* JUG Java Uuid Generator
2+
*
3+
* Copyright (c) 2002,2010 Tatu Saloranta, [email protected], Tommi S.E. Laukkanen, [email protected]
4+
*
5+
* Licensed under the License specified in the file LICENSE which is
6+
* included with the source code.
7+
* You may not use this file except in compliance with the License.
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
using System.Text;
17+
using System;
18+
19+
namespace Jug
20+
{
21+
22+
/**
23+
* A class that allows creation of tagURI instances.
24+
*
25+
* TagURIs are specified in IETF draft <draft-kindberg-tag-uri-01.txt>;
26+
* available for example at:
27+
*
28+
* http://sunsite.cnlab-switch.ch/ftp/mirror/internet-drafts/draft-kindberg-tag-uri-01.txt
29+
*/
30+
public class TagURI
31+
{
32+
private String mDesc;
33+
34+
/**
35+
* Constructor for creating tagURI instances.
36+
*
37+
* Typical string representations of tagURIs may look like:
38+
* <ul>
39+
* <li>tag:hp1.hp.com,2001:tst.1234567890
40+
* <li>tag:[email protected],2001-07-02:rock.123
41+
* </ul>
42+
* (see tagURI draft for more examples and full explanation of the
43+
* basic concepts)
44+
*
45+
* @param authority Authority that created tag URI; usually either a
46+
* fully-qualified domain name ("www.w3c.org") or an email address
47+
48+
* @param identifier A locally unique identifier; often file path or
49+
* URL path component (like, "tst.1234567890", "/home/tatu/index.html")
50+
* @param date Date to add as part of the tag URI, if any; null is used
51+
* used to indicate that no datestamp should be added.
52+
*
53+
*/
54+
public TagURI(String authority, String identifier, Nullable<DateTime> date)
55+
{
56+
StringBuilder b = new StringBuilder();
57+
b.Append("tag:");
58+
b.Append(authority);
59+
if (date != null)
60+
{
61+
b.Append(',');
62+
b.Append(date.Value.Year);
63+
// Month is optional if it's "january" and day is "1st":
64+
int month = date.Value.Month;
65+
int day = date.Value.Day;
66+
if (month != 1 || day != 1)
67+
{
68+
b.Append('-');
69+
b.Append(month);
70+
}
71+
if (day != 1)
72+
{
73+
b.Append('-');
74+
b.Append(day);
75+
}
76+
}
77+
78+
b.Append(':');
79+
b.Append(identifier);
80+
81+
mDesc = b.ToString();
82+
}
83+
84+
public override String ToString()
85+
{
86+
return mDesc;
87+
}
88+
89+
public override bool Equals(Object o)
90+
{
91+
if (o != null && o.GetType() == typeof(TagURI))
92+
{
93+
return mDesc.Equals(((TagURI)o).ToString());
94+
}
95+
return false;
96+
}
97+
98+
public override int GetHashCode()
99+
{
100+
return mDesc.GetHashCode();
101+
}
102+
103+
}
104+
105+
}

0 commit comments

Comments
 (0)