コード例 #1
0
 /**
  * Method for generating UUIDs using tag URIs. A hash is calculated from
  * the given tag URI using the specified hashing algorith,.
  * The resulting UUIDs are reproducible, ie. given the same tag URI and
  * hash algorithm, same UUID will always result, much like with the
  * default name-based generation method.
  *
  * Note that this a non-standard way of generating UUIDs; it will create
  * UUIDs that appear to be name-based (and which are, but not using the
  * method specified in UUID specs).
  *
  * @param name tag URI to base UUID on.
  * @param hasher Hashing algorithm to use. Note that the caller has to
  *  make sure that it's thread-safe to use 'hasher', either by never
  *  calling this method from multiple threads, or by explicitly sync'ing
  *  the calls.
  */
 public UUID GenerateTagURIBasedUUID(TagURI name, MD5 hasher)
 {
     return GenerateNameBasedUUID(null, name.ToString(), hasher);
 }
コード例 #2
0
 /**
  * Method for generating UUIDs using tag URIs. A hash is calculated from
  * the given tag URI (default being MD5 hash). The resulting UUIDs
  * are reproducible, ie. given the same tag URI, same UUID will always
  * result, much like with the default name-based generation method.
  *
  * Note that this a non-standard way of generating UUIDs; it will create
  * UUIDs that appear to be name-based (and which are, but not using the
  * method specified in UUID specs).
  *
  * @param name tag URI to base UUID on.
  */
 public UUID GenerateTagURIBasedUUID(TagURI name)
 {
     return GenerateNameBasedUUID(null, name.ToString());
 }
コード例 #3
0
 /**
  * Method for generating UUIDs using tag URIs. A hash is calculated from
  * the given tag URI (default being MD5 hash). The resulting UUIDs
  * are reproducible, ie. given the same tag URI, same UUID will always
  * result, much like with the default name-based generation method.
  *
  * Note that this a non-standard way of generating UUIDs; it will create
  * UUIDs that appear to be name-based (and which are, but not using the
  * method specified in UUID specs).
  *
  * @param name tag URI to base UUID on.
  */
 public UUID GenerateTagURIBasedUUID(TagURI name)
 {
     return(GenerateNameBasedUUID(null, name.ToString()));
 }
コード例 #4
0
 /**
  * Method for generating UUIDs using tag URIs. A hash is calculated from
  * the given tag URI using the specified hashing algorith,.
  * The resulting UUIDs are reproducible, ie. given the same tag URI and
  * hash algorithm, same UUID will always result, much like with the
  * default name-based generation method.
  *
  * Note that this a non-standard way of generating UUIDs; it will create
  * UUIDs that appear to be name-based (and which are, but not using the
  * method specified in UUID specs).
  *
  * @param name tag URI to base UUID on.
  * @param hasher Hashing algorithm to use. Note that the caller has to
  *  make sure that it's thread-safe to use 'hasher', either by never
  *  calling this method from multiple threads, or by explicitly sync'ing
  *  the calls.
  */
 public UUID GenerateTagURIBasedUUID(TagURI name, MD5 hasher)
 {
     return(GenerateNameBasedUUID(null, name.ToString(), hasher));
 }
コード例 #5
0
        public void testToString()
        {
            DateTime CALENDAR = DateTime.Now;

            // we'll test that a few expected constructed TagURI's create the
            // expected strings

            // first, some tests with a null calendar
            for (int i = 0; i < 4; ++i)
            {
                for (int j = 0; j < 4; ++j)
                {
                    TagURI tag_uri = new TagURI(AUTHORITIES[i], IDS[j], null);
                    String expected = "tag:" + AUTHORITIES[i] + ":" + IDS[j];
                    Assert.AreEqual(
                        expected,
                        tag_uri.ToString(), "Expected string did not match generated ToString()");
                }
            }

            // now some cases with date
            for (int i = 0; i < 4; ++i)
            {
                CALENDAR = new DateTime(2006, 6, 4);

                for (int j = 0; j < 4; ++j)
                {
                    TagURI tag_uri = new TagURI(AUTHORITIES[i], IDS[j], CALENDAR);
                    String expected = "tag:" + AUTHORITIES[i] + "," +
                        CALENDAR.Year + "-" +
                        CALENDAR.Month + "-" +
                        CALENDAR.Day + ":" + IDS[j];
                    Assert.AreEqual(
                        expected,
                        tag_uri.ToString(),
                        "Expected string did not match generated ToString()"
                        );
                }
            }

            // now some cases with date such that day is left out
            // (first of the month)
            for (int i = 0; i < 4; ++i)
            {
                CALENDAR = new DateTime(2006, 6, 1);

                for (int j = 0; j < 4; ++j)
                {
                    TagURI tag_uri = new TagURI(AUTHORITIES[i], IDS[j], CALENDAR);
                    String expected = "tag:" + AUTHORITIES[i] + "," +
                        CALENDAR.Year + "-" +
                        CALENDAR.Month + ":" + IDS[j];
                    Assert.AreEqual(
                        expected,
                        tag_uri.ToString(),
                        "Expected string did not match generated ToString()"
                        );
                }
            }

            // now some cases with date such that day and month are left out
            // (jan-1)
            for (int i = 0; i < 4; ++i)
            {
                CALENDAR = new DateTime(2006, 1, 1);

                for (int j = 0; j < 4; ++j)
                {
                    TagURI tag_uri = new TagURI(AUTHORITIES[i], IDS[j], CALENDAR);
                    String expected = "tag:" + AUTHORITIES[i] + "," +
                        CALENDAR.Year + ":" + IDS[j];
                    Assert.AreEqual(
                        expected,
                        tag_uri.ToString(),
                        "Expected string did not match generated ToString()"
                        );
                }
            }
        }