[jbosscache-commits] JBoss Cache SVN: r5949 - searchable/trunk/src/main/java/org/jboss/cache/search.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Jun 4 10:32:05 EDT 2008


Author: navssurtani
Date: 2008-06-04 10:32:05 -0400 (Wed, 04 Jun 2008)
New Revision: 5949

Modified:
   searchable/trunk/src/main/java/org/jboss/cache/search/Transformer.java
Log:
Finished 3 static methods.

Modified: searchable/trunk/src/main/java/org/jboss/cache/search/Transformer.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/Transformer.java	2008-06-04 10:44:28 UTC (rev 5948)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/Transformer.java	2008-06-04 14:32:05 UTC (rev 5949)
@@ -11,25 +11,52 @@
  */
 public class Transformer
 {
-   public static Fqn getFqn(String docId)
+   public static String getKey(String docId)
    {
-      //TODO: Do the dirty work to convert a given document Id into an Fqn.
-      return null;
+      //Comes in the format "Fqn=[a/b/c]Key=[key]"
+
+      // This will be the index of the first time the sub-String "key=[" occurs within the whole String.
+      int startIndex = docId.indexOf("Key=[");
+
+      //The index of the endIndex of the key sequence so we know when to cut out. The startIndex integer is also passed in so that
+      // there will not be an error later of endIndex < startIndex because this char occurs earlier when the Fqn is stated.
+      int endIndex = docId.indexOf("]", startIndex);
+
+      //Make the startIndex index point at the first char in the key sequence.
+      startIndex += 1;
+
+      //The resultant key that will be returned.
+      String key = docId.substring(startIndex, endIndex);
+
+      return key;
    }
 
-   public static String getKey(String docId)
+   public static Fqn getFqn(String docId)
    {
-      //TODO: Get the document Id to give back a string.
-      return null;
+      // This will be the index of the first time the sub-String "Fqn=[" occurs within the whole String.
+      //Adding 1 so that the index being pointed at will be the first character in the Fqn sequence.
+      int startIndex = docId.indexOf("Fqn=[") + 1;
+
+      //The endIndex of the Fqn sequence so that we know when to cut out the sub-String.
+      int endIndex = docId.indexOf("]");
+
+      String fqnString = docId.substring(startIndex, endIndex);
+
+      Fqn fqn = Fqn.fromString(fqnString);
+      return fqn;
    }
 
    public static String generateId(Fqn fqn, String key)
    {
-      //TODO: Generate the Id from the given Fqn and key pairing to get a unique String.
+      StringBuilder sb = new StringBuilder();
+      sb.append("Fqn=[");
+      sb.append(fqn);
+      sb.append("]Key=[");
+      sb.append(key);
+      sb.append("]");
 
-      String generatedId = "Fqn = " + fqn + "key = " + key;
+      return sb.toString();
 
-      return generatedId;
    }
 
    //TODO: Look at HS documentation to see what can be done about non-String keys.




More information about the jbosscache-commits mailing list