From a4d7856733731fd2938df931594506f23f0b6dcc Mon Sep 17 00:00:00 2001
From: ribeaudc <ribeaudc>
Date: Fri, 18 Apr 2008 08:40:32 +0000
Subject: [PATCH] fix: - It should not be possible to get an instance of
 'Geometry'. Only its subclasses implements 'getDirectoryName'.

SVN: 5676
---
 bds/source/java/ch/systemsx/cisd/bds/hcs/Geometry.java |  4 ++--
 .../java/ch/systemsx/cisd/bds/hcs/PlateGeometry.java   | 10 +++++++++-
 .../java/ch/systemsx/cisd/bds/hcs/WellGeometry.java    | 10 +++++++++-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/bds/source/java/ch/systemsx/cisd/bds/hcs/Geometry.java b/bds/source/java/ch/systemsx/cisd/bds/hcs/Geometry.java
index 0987005a287..ab418ab8b8a 100644
--- a/bds/source/java/ch/systemsx/cisd/bds/hcs/Geometry.java
+++ b/bds/source/java/ch/systemsx/cisd/bds/hcs/Geometry.java
@@ -51,7 +51,7 @@ public class Geometry implements IStorable
 
     private final int columns;
 
-    protected Geometry(final int rows, final int columns)
+    Geometry(final int rows, final int columns)
     {
         assert columns > 0 : String.format(NOT_POSITIVE, "columns", columns);
         this.columns = columns;
@@ -82,7 +82,7 @@ public class Geometry implements IStorable
      * @param toString the output you get when calling {@link #toString()}.
      * @return <code>null</code> if operation fails.
      */
-    public final static Geometry createFromString(final String toString)
+    static Geometry createFromString(final String toString)
     {
         assert toString != null : "Given string can not be null.";
         final int index = toString.indexOf(X);
diff --git a/bds/source/java/ch/systemsx/cisd/bds/hcs/PlateGeometry.java b/bds/source/java/ch/systemsx/cisd/bds/hcs/PlateGeometry.java
index 7168f9390f7..cb06a5159b6 100644
--- a/bds/source/java/ch/systemsx/cisd/bds/hcs/PlateGeometry.java
+++ b/bds/source/java/ch/systemsx/cisd/bds/hcs/PlateGeometry.java
@@ -50,7 +50,15 @@ public final class PlateGeometry extends Geometry
      */
     final static Geometry loadFrom(final IDirectory directory)
     {
-        return loadFrom(directory, PLATE_GEOMETRY);
+        return new PlateGeometry(loadFrom(directory, PLATE_GEOMETRY));
+    }
+
+    /**
+     * Creates a new <code>WellGeometry</code> from given <var>toString</var>.
+     */
+    public final static Geometry createFromString(final String toString)
+    {
+        return new PlateGeometry(Geometry.createFromString(toString));
     }
 
     //
diff --git a/bds/source/java/ch/systemsx/cisd/bds/hcs/WellGeometry.java b/bds/source/java/ch/systemsx/cisd/bds/hcs/WellGeometry.java
index 017b1d6ea33..60bdeb4d6c8 100644
--- a/bds/source/java/ch/systemsx/cisd/bds/hcs/WellGeometry.java
+++ b/bds/source/java/ch/systemsx/cisd/bds/hcs/WellGeometry.java
@@ -50,7 +50,15 @@ public final class WellGeometry extends Geometry
      */
     final static Geometry loadFrom(final IDirectory directory)
     {
-        return loadFrom(directory, WELL_GEOMETRY);
+        return new WellGeometry(loadFrom(directory, WELL_GEOMETRY));
+    }
+
+    /**
+     * Creates a new <code>WellGeometry</code> from given <var>toString</var>.
+     */
+    public final static Geometry createFromString(final String toString)
+    {
+        return new WellGeometry(Geometry.createFromString(toString));
     }
 
     //
-- 
GitLab