affyfusion-109/src/affymetrix/calvin/data/DataGroupHeader.java

Code
Comments
Other
Rev Date Author Line
11 13 Sep 07 nicklas 1 /////////////////////////////////////////////////////////////////
11 13 Sep 07 nicklas 2 //
11 13 Sep 07 nicklas 3 // Copyright (C) 2005 Affymetrix, Inc.
11 13 Sep 07 nicklas 4 //
11 13 Sep 07 nicklas 5 // This library is free software; you can redistribute it and/or modify
11 13 Sep 07 nicklas 6 // it under the terms of the GNU Lesser General Public License as published
11 13 Sep 07 nicklas 7 // by the Free Software Foundation; either version 2.1 of the License,
11 13 Sep 07 nicklas 8 // or (at your option) any later version.
11 13 Sep 07 nicklas 9 //
11 13 Sep 07 nicklas 10 // This library is distributed in the hope that it will be useful, but
11 13 Sep 07 nicklas 11 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 13 Sep 07 nicklas 12 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 13 Sep 07 nicklas 13 // for more details.
11 13 Sep 07 nicklas 14 //
11 13 Sep 07 nicklas 15 // You should have received a copy of the GNU Lesser General Public License
11 13 Sep 07 nicklas 16 // along with this library; if not, write to the Free Software Foundation, Inc.,
11 13 Sep 07 nicklas 17 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
11 13 Sep 07 nicklas 18 //
11 13 Sep 07 nicklas 19 /////////////////////////////////////////////////////////////////
11 13 Sep 07 nicklas 20
11 13 Sep 07 nicklas 21
11 13 Sep 07 nicklas 22 package affymetrix.calvin.data;
11 13 Sep 07 nicklas 23
11 13 Sep 07 nicklas 24 import java.util.*;
11 13 Sep 07 nicklas 25
11 13 Sep 07 nicklas 26 /**  */
11 13 Sep 07 nicklas 27 public class DataGroupHeader {
11 13 Sep 07 nicklas 28       
11 13 Sep 07 nicklas 29   public DataGroupHeader() {
11 13 Sep 07 nicklas 30             clear();
11 13 Sep 07 nicklas 31         }
11 13 Sep 07 nicklas 32         
11 13 Sep 07 nicklas 33   public DataGroupHeader(String n) {
11 13 Sep 07 nicklas 34             clear();
11 13 Sep 07 nicklas 35             name = n;
11 13 Sep 07 nicklas 36         }
11 13 Sep 07 nicklas 37
11 13 Sep 07 nicklas 38   /** data dataGroup name */
11 13 Sep 07 nicklas 39   private String name;
11 13 Sep 07 nicklas 40         
11 13 Sep 07 nicklas 41   /** file position of the 1st data dataSet */
11 13 Sep 07 nicklas 42   private int dataSetPos;
11 13 Sep 07 nicklas 43         
11 13 Sep 07 nicklas 44   /** file position of the next dataGroup */
11 13 Sep 07 nicklas 45   private int nextGrpPos;
11 13 Sep 07 nicklas 46         
11 13 Sep 07 nicklas 47   /** data dataSets in this dataGroup */
11 13 Sep 07 nicklas 48   private Vector /*DataSetHdr*/ dataSetHdrs;
11 13 Sep 07 nicklas 49
11 13 Sep 07 nicklas 50   /**  */
11 13 Sep 07 nicklas 51   public void clear() {
11 13 Sep 07 nicklas 52             name="";
11 13 Sep 07 nicklas 53             dataSetPos = 0;
11 13 Sep 07 nicklas 54             nextGrpPos = 0;
11 13 Sep 07 nicklas 55             dataSetHdrs=null;
11 13 Sep 07 nicklas 56         }
11 13 Sep 07 nicklas 57         
11 13 Sep 07 nicklas 58   /**  */
11 13 Sep 07 nicklas 59   public void setName(String p) { name = p; }
11 13 Sep 07 nicklas 60         
11 13 Sep 07 nicklas 61   /**  */
11 13 Sep 07 nicklas 62   public String getName() { return name; }
11 13 Sep 07 nicklas 63         
11 13 Sep 07 nicklas 64   /** Get the data set count */
11 13 Sep 07 nicklas 65   public int getDataSetCnt() {
11 13 Sep 07 nicklas 66             if (dataSetHdrs != null)
11 13 Sep 07 nicklas 67                 return dataSetHdrs.size();
11 13 Sep 07 nicklas 68             return 0;
11 13 Sep 07 nicklas 69         }
11 13 Sep 07 nicklas 70   /**  */
11 13 Sep 07 nicklas 71   public void addDataSetHdr(DataSetHeader p) {
11 13 Sep 07 nicklas 72             if (dataSetHdrs == null)
11 13 Sep 07 nicklas 73                 dataSetHdrs = new Vector();
11 13 Sep 07 nicklas 74             dataSetHdrs.add(p);
11 13 Sep 07 nicklas 75         }
11 13 Sep 07 nicklas 76   /**  */
11 13 Sep 07 nicklas 77   public DataSetHeader getDataSet(int index) {
11 13 Sep 07 nicklas 78             return (DataSetHeader) dataSetHdrs.elementAt(index);
11 13 Sep 07 nicklas 79         }
11 13 Sep 07 nicklas 80         
11 13 Sep 07 nicklas 81   /**  */
11 13 Sep 07 nicklas 82   public Vector getDataSets() { return dataSetHdrs; }
11 13 Sep 07 nicklas 83
11 13 Sep 07 nicklas 84         /** Set the file position of the DataSet header.
11 13 Sep 07 nicklas 85         *  The value set here is not necessarily the value written to the file.
11 13 Sep 07 nicklas 86         */
11 13 Sep 07 nicklas 87   public void setDataSetPos(int pos) { dataSetPos  = pos; }
11 13 Sep 07 nicklas 88         
11 13 Sep 07 nicklas 89   /** Get the file position of the DataSet header. */
11 13 Sep 07 nicklas 90   public int getDataSetPos() { return dataSetPos; }
11 13 Sep 07 nicklas 91         
11 13 Sep 07 nicklas 92   /** Set the file position of the next DataGroup header. */
11 13 Sep 07 nicklas 93   public void setNextGroupPos(int pos) { nextGrpPos  = pos; }
11 13 Sep 07 nicklas 94         
11 13 Sep 07 nicklas 95   /** Get the file position of the next DataGroup header. */
11 13 Sep 07 nicklas 96   public int getNextGroupPos() { return nextGrpPos; }
11 13 Sep 07 nicklas 97         
11 13 Sep 07 nicklas 98   /**
11 13 Sep 07 nicklas 99    */
11 13 Sep 07 nicklas 100         public DataSetHeader findDataSetHeader(String dataSetName) {
11 13 Sep 07 nicklas 101             int n = getDataSetCnt();
11 13 Sep 07 nicklas 102             for (int i=0; i<n; i++)
11 13 Sep 07 nicklas 103             {
11 13 Sep 07 nicklas 104                 DataSetHeader dph = getDataSet(i);
11 13 Sep 07 nicklas 105                 if (dataSetName.compareTo(dph.getName()) == 0)
11 13 Sep 07 nicklas 106                     return dph;
11 13 Sep 07 nicklas 107             }
11 13 Sep 07 nicklas 108             return null;
11 13 Sep 07 nicklas 109         }
11 13 Sep 07 nicklas 110 }