LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  May 2015

HPS-SVN May 2015

Subject:

r2929 - /java/branches/HPSJAVA-499/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Fri, 8 May 2015 21:37:10 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (251 lines)

Author: [log in to unmask]
Date: Fri May  8 14:37:01 2015
New Revision: 2929

Log:
Remove parsing of alignment parameter values; this is handled better already by MilleParameter.

Modified:
    java/branches/HPSJAVA-499/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java

Modified: java/branches/HPSJAVA-499/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java
 =============================================================================
--- java/branches/HPSJAVA-499/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java	(original)
+++ java/branches/HPSJAVA-499/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java	Fri May  8 14:37:01 2015
@@ -12,7 +12,6 @@
  * translation or rotation of a detector component.
  * <p>
  * The format of the keys is ABCDE where:<br>
- *
  * <pre>
  * A == half == [1,2]
  * B == alignment type == [1,2]
@@ -29,164 +28,21 @@
 public final class SvtAlignmentConstant extends BaseConditionsObject {
 
     /**
-     * The alignment constant type which is rotation or translation.
-     */
-    public enum AlignmentType {
-        /** Rotation alignment type. */
-        ROTATION(1),
-        /** Translation alignment type. */
-        TRANSLATION(2);
-
-        /**
-         * The value of the alignment type constants.
-         */
-        private final int value;
-
-        /**
-         * Constructor that has value of constant.
-         *
-         * @param value the value of the constant
-         */
-        private AlignmentType(final int value) {
-            this.value = value;
-        }
-
-        /**
-         * Get the value for the alignment constant type.
-         *
-         * @return the value of the constant
-         */
-        int getValue() {
-            return this.value;
-        }
-    }
-
-    /**
-     * Top or bottom half.
-     */
-    public enum Half {
-        /** Bottom half. */
-        BOTTOM(2),
-        /** Top half. */
-        TOP(1);
-
-        /**
-         * The integer value designating top or bottom half.
-         */
-        private final int value;
-
-        /**
-         * Create from top or bottom value.
-         *
-         * @param value the value for half
-         */
-        private Half(final int value) {
-            this.value = value;
-        }
-
-        /**
-         * Get the value for the half.
-         *
-         * @return the value
-         */
-        int getValue() {
-            return this.value;
-        }
-    };
-
-    /**
      * Collection implementation for {@link SvtAlignmentConstant}.
      */
     @SuppressWarnings("serial")
     public static class SvtAlignmentConstantCollection extends BaseConditionsObjectCollection<SvtAlignmentConstant> {
+        
+        public SvtAlignmentConstant find(int id) {
+            for (SvtAlignmentConstant constant : this) {
+                if (constant.getParameter().equals(id)) {
+                    return constant;
+                }
+            }
+            return null;
+        }
+        
     };
-
-    /**
-     * The unit axis which for translations maps to XYZ. (Convention for rotation???)
-     */
-    public enum UnitAxis {
-        /** U unit axis. */
-        U(1),
-        /** V unit axis. */
-        V(2),
-        /** W unit axis. */
-        W(3);
-
-        /**
-         * Value for the constant.
-         */
-        private final int value;
-
-        /**
-         * Create from value.
-         *
-         * @param value the value
-         */
-        private UnitAxis(final int value) {
-            this.value = value;
-        }
-
-        /**
-         * Get the value for the unit axis.
-         *
-         * @return the value
-         */
-        int getValue() {
-            return this.value;
-        }
-    };
-
-    /**
-     * Maximum value of the module number.
-     */
-    private static final int MAX_MODULE_NUMBER = 10;
-
-    /**
-     * Decode the AlignmentType value from the key.
-     *
-     * @return the AlignmentType value from the key
-     * @see AlignmentType
-     */
-    public AlignmentType getAlignmentType() {
-        final int alignmentType = Integer.parseInt(getParameter().substring(1, 2));
-        if (alignmentType == AlignmentType.TRANSLATION.getValue()) {
-            return AlignmentType.TRANSLATION;
-        } else if (alignmentType == AlignmentType.ROTATION.getValue()) {
-            return AlignmentType.ROTATION;
-        } else {
-            throw new IllegalArgumentException("Could not parse valid AlignmentType from " + getParameter());
-        }
-    }
-
-    /**
-     * Decode the Half value from the key.
-     *
-     * @return the Half value from the key
-     * @see Half
-     */
-    public Half getHalf() {
-        final int half = Integer.parseInt(getParameter().substring(0, 1));
-        if (half == Half.TOP.getValue()) {
-            return Half.TOP;
-        } else if (half == Half.BOTTOM.getValue()) {
-            return Half.BOTTOM;
-        } else {
-            throw new IllegalArgumentException("Could not parse valid Half from " + getParameter());
-        }
-    }
-
-    /**
-     * Decode the module number from the key.
-     *
-     * @return the module number from the key
-     */
-    public int getModuleNumber() {
-        final int moduleNumber = Integer.parseInt(getParameter().substring(3, 5));
-        if (moduleNumber > MAX_MODULE_NUMBER || moduleNumber == 0) {
-            throw new IllegalArgumentException("The decoded module number " + moduleNumber + " is invalid.");
-        }
-        return moduleNumber;
-    }
 
     /**
      * Get the alignment constant's encoded, raw value.
@@ -194,27 +50,9 @@
      * @return the alignment constant's key
      */
     @Field(names = { "parameter" })
-    public String getParameter() {
+    public Integer getParameter() {
+        //System.out.println("parameter = " + this.getFieldValues().get("parameter") + "; type = " + this.getFieldValues().get("parameter").getClass());
         return getFieldValue("parameter");
-    }
-
-    /**
-     * Decode the UnitAxis from the key.
-     *
-     * @return the UnitAxis v
-     * @see UnitAxis
-     */
-    public UnitAxis getUnitAxis() {
-        final int unitAxis = Integer.parseInt(getParameter().substring(2, 3));
-        if (unitAxis == UnitAxis.U.getValue()) {
-            return UnitAxis.U;
-        } else if (unitAxis == UnitAxis.V.getValue()) {
-            return UnitAxis.V;
-        } else if (unitAxis == UnitAxis.W.getValue()) {
-            return UnitAxis.W;
-        } else {
-            throw new IllegalArgumentException("Could not parse valid UnitAxis from " + getParameter());
-        }
     }
 
     /**
@@ -223,7 +61,7 @@
      * @return the alignment constant's value as a double
      */
     @Field(names = { "value" })
-    public double getValue() {
+    public Double getValue() {
         return getFieldValue("value");
     }
 
@@ -234,12 +72,6 @@
      */
     @Override
     public String toString() {
-        final StringBuffer buff = new StringBuffer();
-        buff.append(super.toString());
-        buff.append("half: ").append(getHalf().getValue()).append('\n');
-        buff.append("alignment_type: ").append(getAlignmentType().getValue()).append('\n');
-        buff.append("unit_axis: ").append(getUnitAxis().getValue()).append('\n');
-        buff.append("module_number: ").append(getModuleNumber()).append('\n');
-        return buff.toString();
+        return "SvtAlignmentConstant parameter = " + this.getParameter() + "; value = " + this.getValue();
     }
 }

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use