View Javadoc

1   // Licensed to the Apache Software Foundation (ASF) under one or more contributor
2   // license agreements.  See the NOTICE.txt file distributed with this work for
3   // additional information regarding copyright ownership.  The ASF licenses this
4   // file to you under the Apache License, Version 2.0 (the "License"); you may not
5   // use this file except in compliance with the License.  You may obtain a copy of
6   // the License at
7   //
8   //     http://www.apache.org/licenses/LICENSE-2.0
9   //
10  // Unless required by applicable law or agreed to in writing, software
11  // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
13  // License for the specific language governing permissions and limitations under
14  // the License.
15  
16  package org.apache.oodt.pcs.input;
17  
18  //JDK imports
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  /**
23   * <p>
24   * A PGEGroup is a named set of named {@link PGEVector}s, {@link PGEScalar}s and
25   * {@link PGEMatrix}s.
26   * </p>
27   * 
28   * @author mattmann
29   * @version $Revision$
30   * 
31   */
32  public class PGEGroup {
33  
34    /* the name of the PGEGroup */
35    private String name = null;
36  
37    /* the HashMap of PGEScalars */
38    private Map<String, PGEScalar> scalars = null;
39  
40    /* the HashMap of PGEVectors */
41    private Map<String, PGEVector> vectors = null;
42  
43    /* the HashMap of PGEMatrixs */
44    private Map<String, PGEMatrix> matrixs = null;
45  
46    /* the HashMap of PGEGroups */
47    private Map<String, PGEGroup> groups = null;
48  
49    /**
50     * <p>
51     * Constructs a new PGEGroup with the given name
52     * </p>
53     */
54    public PGEGroup(String name) {
55      this.name = name;
56      this.scalars = new HashMap<String, PGEScalar>();
57      this.vectors = new HashMap<String, PGEVector>();
58      this.matrixs = new HashMap<String, PGEMatrix>();
59      this.groups = new HashMap<String, PGEGroup>();
60    }
61  
62    /**
63     * @return the name
64     */
65    public String getName() {
66      return name;
67    }
68  
69    /**
70     * @param name
71     *          the name to set
72     */
73    public void setName(String name) {
74      this.name = name;
75    }
76  
77    /**
78     * @return the scalars
79     */
80    public Map<String, PGEScalar> getScalars() {
81      return scalars;
82    }
83  
84    /**
85     * @param scalars
86     *          the scalars to set
87     */
88    public void setScalars(Map<String, PGEScalar> scalars) {
89      this.scalars = scalars;
90    }
91  
92    /**
93     * @return the vectors
94     */
95    public Map<String, PGEVector> getVectors() {
96      return vectors;
97    }
98  
99    /**
100    * @param vectors
101    *          the vectors to set
102    */
103   public void setVectors(Map<String, PGEVector> vectors) {
104     this.vectors = vectors;
105   }
106 
107   /**
108    * @return the matrixs
109    */
110   public Map<String, PGEMatrix> getMatrixs() {
111     return matrixs;
112   }
113 
114   /**
115    * @param matrixs
116    *          the matrixs to set
117    */
118   public void setMatrixs(Map<String, PGEMatrix> matrixs) {
119     this.matrixs = matrixs;
120   }
121 
122   /**
123    * @return the groups
124    */
125   public Map<String, PGEGroup> getGroups() {
126     return groups;
127   }
128 
129   /**
130    * @param groups
131    *          the groups to set
132    */
133   public void setGroups(Map<String, PGEGroup> groups) {
134     this.groups = groups;
135   }
136 
137   public void addScalar(PGEScalar scalar) {
138     if (this.scalars != null && !this.scalars.containsKey(scalar.getName())) {
139       this.scalars.put(scalar.getName(), scalar);
140     }
141   }
142 
143   public void addVector(PGEVector vector) {
144     if (this.vectors != null && !this.vectors.containsKey(vector.getName())) {
145       this.vectors.put(vector.getName(), vector);
146     }
147   }
148 
149   public void addMatrix(PGEMatrix matrix) {
150     if (this.matrixs != null && !this.matrixs.containsKey(matrix.getName())) {
151       this.matrixs.put(matrix.getName(), matrix);
152     }
153   }
154 
155   public PGEScalar getScalar(String name) {
156     if (this.scalars != null) {
157       return this.scalars.get(name);
158     } else
159       return null;
160   }
161 
162   public PGEVector getVector(String name) {
163     if (this.vectors != null) {
164       return this.vectors.get(name);
165     } else
166       return null;
167   }
168 
169   public PGEMatrix getMatrix(String name) {
170     if (this.matrixs != null) {
171       return this.matrixs.get(name);
172     } else
173       return null;
174   }
175 
176   public PGEGroup getGroup(String name) {
177     if (this.groups != null) {
178       return this.groups.get(name);
179     } else
180       return null;
181   }
182 
183   public int getNumScalars() {
184     if (this.scalars != null) {
185       return this.scalars.size();
186     } else
187       return 0;
188   }
189 
190   public int getNumVectors() {
191     if (this.vectors != null) {
192       return this.vectors.size();
193     } else
194       return 0;
195   }
196 
197   public int getNumMatrixs() {
198     if (this.matrixs != null) {
199       return this.matrixs.size();
200     } else
201       return 0;
202   }
203 
204   public int getNumGroups() {
205     if (this.groups != null) {
206       return this.groups.size();
207     } else
208       return 0;
209   }
210 
211 }