--- /dev/null
+// DummyResourceIndexer.java\r
+// $Id: DummyResourceReference.java,v 1.1 2010/06/15 12:20:15 smhuang Exp $ \r
+// (c) COPYRIGHT MIT and INRIA, 1997.\r
+// Please first read the full copyright statement in file COPYRIGHT.html\r
+\r
+package org.w3c.tools.resources;\r
+\r
+/**\r
+ * This class implements the ResourceReference interface. For external\r
+ * use only. The ResourceStoreManager has its own Reference class.\r
+ */\r
+\r
+public class DummyResourceReference implements ResourceReference {\r
+\r
+ /**\r
+ * The lock count associated to the reference.\r
+ */\r
+ protected int lockCount = 0;\r
+\r
+ private Resource resource = null;\r
+ private String identifier = null;\r
+\r
+ /**\r
+ * update the cached context of that reference.\r
+ * @param ctxt the new ResourceContext.\r
+ */\r
+ public void updateContext(ResourceContext ctxt) {\r
+ }\r
+\r
+ /**\r
+ * Lock the refered resource in memory.\r
+ * @return A real pointer to the resource.\r
+ * @exception InvalidResourceException is thrown if the resource is\r
+ * invalid (has been deleted or everything else).\r
+ */\r
+ public Resource lock()\r
+ throws InvalidResourceException\r
+ {\r
+ if (resource == null)\r
+ throw new InvalidResourceException(identifier,\r
+ "This reference has been invalidated");\r
+ lockCount++;\r
+ return resource;\r
+ }\r
+\r
+ /**\r
+ * Lock the refered resource in memory.\r
+ * @return A real pointer to the resource.\r
+ * @exception InvalidResourceException is thrown if the resource is\r
+ * invalid (has been deleted or everything else).\r
+ */\r
+ public Resource unsafeLock()\r
+ throws InvalidResourceException\r
+ {\r
+ return lock();\r
+ }\r
+ /**\r
+ * How many locks?\r
+ * @return an int.\r
+ */\r
+ public int nbLock() {\r
+ return lockCount;\r
+ }\r
+\r
+ /**\r
+ * Unlock that resource from memory.\r
+ */\r
+ public void unlock() {\r
+ lockCount--;\r
+ }\r
+\r
+ /**\r
+ * Is that resource reference locked ?\r
+ */\r
+ public boolean isLocked() {\r
+ return lockCount != 0;\r
+ }\r
+\r
+ /**\r
+ * Set this reference as invalid.\r
+ */\r
+ public void invalidate() {\r
+ resource = null;\r
+ }\r
+\r
+ /**\r
+ * @param resource The resource to reference.\r
+ */\r
+ public DummyResourceReference(Resource resource) {\r
+ this.resource = resource;\r
+ this.identifier = resource.getIdentifier();\r
+ }\r
+\r
+}\r