001    /*
002     * $Id: HDFArray.java,v 1.8 2012/02/19 17:35:41 davep Exp $
003     *
004     * This file is part of McIDAS-V
005     *
006     * Copyright 2007-2012
007     * Space Science and Engineering Center (SSEC)
008     * University of Wisconsin - Madison
009     * 1225 W. Dayton Street, Madison, WI 53706, USA
010     * https://www.ssec.wisc.edu/mcidas
011     * 
012     * All Rights Reserved
013     * 
014     * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
015     * some McIDAS-V source code is based on IDV and VisAD source code.  
016     * 
017     * McIDAS-V is free software; you can redistribute it and/or modify
018     * it under the terms of the GNU Lesser Public License as published by
019     * the Free Software Foundation; either version 3 of the License, or
020     * (at your option) any later version.
021     * 
022     * McIDAS-V is distributed in the hope that it will be useful,
023     * but WITHOUT ANY WARRANTY; without even the implied warranty of
024     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
025     * GNU Lesser Public License for more details.
026     * 
027     * You should have received a copy of the GNU Lesser Public License
028     * along with this program.  If not, see http://www.gnu.org/licenses.
029     */
030    
031    package edu.wisc.ssec.mcidasv.data.hydra;
032    
033    public class HDFArray {
034    
035       Class type;
036       int length;
037    
038       public HDFArray(Class type) {
039        this.type = type;
040       }
041    
042       public Object getArray() {
043         return null;
044       }
045    
046       public Class getType() {
047         return type;
048       }
049    
050       public static HDFArray make(float[] array) {
051         return new HDFFloatArray(array);
052       }
053    
054       public static HDFArray make(double[] array) {
055         return new HDFDoubleArray(array);
056       }
057    
058       public static HDFArray make(int[] array) {
059         return new HDFIntArray(array);
060       }
061    
062       public static HDFArray make(short[] array) {
063         return new HDFShortArray(array);
064       }
065    
066       public static HDFArray make(String[] array) {
067         return new HDFStringArray(array);
068       }
069    }
070    
071    class HDFFloatArray extends HDFArray {
072      float[] float_array;
073      public HDFFloatArray(float[] fa) {
074        super(Float.TYPE);
075        float_array = fa;
076        length = fa.length;
077      }
078      public float[] getArray() {
079        return float_array;
080      }
081    }
082    
083    class HDFDoubleArray extends HDFArray {
084      double[] double_array;
085      public HDFDoubleArray(double[] da) {
086        super(Double.TYPE);
087        double_array = da;
088        length = da.length;
089      }
090      public double[] getArray() {
091        return double_array;
092      }
093    }
094    
095    class HDFShortArray extends HDFArray {
096      short[] short_array;
097      public HDFShortArray(short[] sa) {
098        super(Short.TYPE);
099        short_array = sa;
100        length = sa.length;
101      }
102      public short[] getArray() {
103        return short_array;
104      }
105    }
106    
107    class HDFIntArray extends HDFArray {
108      int[] int_array;
109      public HDFIntArray(int[] ia) {
110        super(Integer.TYPE);
111        int_array = ia;
112        length = ia.length;
113      }
114      public int[] getArray() {
115        return int_array;
116      }
117    }
118    
119    class HDFByteArray extends HDFArray {
120      byte[] byte_array;
121      public HDFByteArray(byte[] ba) {
122        super(Byte.TYPE);
123        byte_array = ba;
124        length = ba.length;
125      }
126      public byte[] getArray() {
127        return byte_array;
128      }
129    }
130    
131    
132    class HDFStringArray extends HDFArray {
133      String[] string_array;
134      public HDFStringArray(String[] sa) {
135        super(String.class);
136        string_array = sa;
137        length = sa.length;
138      }
139      public String[] getArray() {
140        return string_array;
141      }
142    }