[Webfunds-commits] java/webfunds/sox ItemId.java

Ian Grigg iang@cypherpunks.ai
Tue, 27 Feb 2001 10:02:05 -0400 (AST)


iang        01/02/27 10:02:05

  Modified:    webfunds/sox ItemId.java
  Log:
  no sensible case of an empty ItemId array

Revision  Changes    Path
1.15      +15 -4     java/webfunds/sox/ItemId.java

Index: ItemId.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/ItemId.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ItemId.java	2001/02/27 01:28:28	1.14
+++ ItemId.java	2001/02/27 14:02:04	1.15
@@ -1,5 +1,5 @@
 /*
- * $Id: ItemId.java,v 1.14 2001/02/27 01:28:28 iang Exp $
+ * $Id: ItemId.java,v 1.15 2001/02/27 14:02:04 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -13,7 +13,7 @@
  * This class represents an Item identifer,
  * which is the standard way of refering to an item.
  *
- * @version $Revision: 1.14 $
+ * @version $Revision: 1.15 $
  */
 public class ItemId
     extends Id
@@ -63,11 +63,22 @@
     }
 
     /**
-     * Make and return an example ItemId for testing (other classes).
+     *  Make and return an example ItemId for testing (other classes).
+     *  In this case, the ItemId has a valid SHA1 like entry,
+     *  it is not empty (as there is no context where that makes sense?).
      */
     public static ItemId example()
     {
-        return new ItemId(ex()) ;
+        ItemId item;
+        byte[] id;
+        do
+        {
+            item = new ItemId(ex());
+            id = item.getId();
+        }
+            while ((id == null) || (id.length == 0)) ;
+
+        return item;
     }
 
     public static void main(String[] args)