diff src/org/dancres/blitz/entry/Types.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/dancres/blitz/entry/Types.java	Sat Mar 21 11:00:06 2009 +0000
@@ -0,0 +1,38 @@
+package org.dancres.blitz.entry;
+
+import java.io.IOException;
+
+public class Types {
+    /**
+       Despite appearances, this method doesn't ever need to be called
+       within a DiskTxn because it will only ever be invoked as the indirect
+       result of a write.  A write forces loading/creation of the appropriate
+       EntryRepository and <B>then</B> generates an event which can wake
+       up the notify system or blocked match requests.
+     */
+    public static boolean isSubtype(String aType, String aSubtype) {
+
+        if (aType.equals(aSubtype))
+            return true;
+
+        EntryRepository myRepos = null;
+
+        try {
+            myRepos = EntryRepositoryFactory.get().find(aType);
+        } catch (IOException anIOE) {
+            // We only ever operate off in-memory entry repos so we never
+            // hit disk which means we won't get a Dbe
+        }
+
+        if (myRepos != null) {
+            String[] theSubtypes = myRepos.getSubtypes();
+
+            for (int i = 0 ; i < theSubtypes.length; i++) {
+                if (theSubtypes[i].equals(aSubtype))
+                    return true;
+            }
+        }
+
+        return false;
+    }
+}