Revision: 139
http://treebase.svn.sourceforge.net/treebase/?rev=139&view=rev
Author: rvos
Date: 2009-06-28 10:13:26 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Adding PhyloWSPath, a class that abstracts away the exact structure of whatever comes between the /phylows/ url fragment and the TB2:${id} fragment.
Added Paths:
-----------
trunk/treebase-core/src/main/java/org/cipres/treebase/PhyloWSPath.java
Added: trunk/treebase-core/src/main/java/org/cipres/treebase/PhyloWSPath.java
===================================================================
--- trunk/treebase-core/src/main/java/org/cipres/treebase/PhyloWSPath.java (rev 0)
+++ trunk/treebase-core/src/main/java/org/cipres/treebase/PhyloWSPath.java 2009-06-28 10:13:26 UTC (rev 139)
@@ -0,0 +1,48 @@
+package org.cipres.treebase;
+
+import org.cipres.treebase.domain.TBPersistable;
+
+public class PhyloWSPath {
+ private NamespacedGUID mNamespacedGUID;
+ private Package mPackage;
+
+ public StringBuilder getPath(StringBuilder sb) {
+ String[] packagePathFragments = mPackage.getName().split("\\.");
+ return sb
+ // i.e. admin, matrix, study, taxon or tree
+ .append(packagePathFragments[packagePathFragments.length-1])
+ .append('/');
+ }
+
+ public String getPath() {
+ return getPath(new StringBuilder()).toString();
+ }
+
+ /**
+ *
+ */
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ return getPath(sb).append(mNamespacedGUID.toString()).toString();
+ }
+
+ /**
+ *
+ * @param tbPersistable
+ */
+ public PhyloWSPath(TBPersistable tbPersistable) {
+ mNamespacedGUID = tbPersistable.getNamespacedGUID();
+ mPackage = tbPersistable.getClass().getPackage();
+ }
+
+ /**
+ *
+ * @param pPackage
+ * @param namespacedGUID
+ */
+ public PhyloWSPath(Package pPackage, NamespacedGUID namespacedGUID) {
+ mPackage = pPackage;
+ mNamespacedGUID = namespacedGUID;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|