View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2007 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of 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,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // GenomeBrowser Project
18  //
19  // TrackConfigChangeImpl.java
20  // Since: Jun 20, 2007
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.track.impl;
26  
27  import java.util.HashSet;
28  
29  import org.utgenome.gwt.utgb.client.track.TrackConfig;
30  import org.utgenome.gwt.utgb.client.track.TrackConfigChange;
31  import org.utgenome.gwt.utgb.client.util.CanonicalProperties;
32  
33  public class TrackConfigChangeImpl implements TrackConfigChange {
34  
35  	TrackConfig _config;
36  	HashSet<String> changedParamSet = new HashSet<String>();
37  
38  	public TrackConfigChangeImpl(TrackConfig config, String changedParam) {
39  		this._config = config;
40  		changedParamSet.add(changedParam);
41  	}
42  
43  	public boolean contains(String configParameterName) {
44  		return changedParamSet.contains(CanonicalProperties.toCanonicalName(configParameterName));
45  	}
46  
47  	public boolean containsOneOf(String[] configParameterName) {
48  
49  		for (int i = 0; i < configParameterName.length; i++) {
50  			if (changedParamSet.contains(CanonicalProperties.toCanonicalName(configParameterName[i])))
51  				return true;
52  		}
53  		return false;
54  	}
55  
56  	public String getValue(String configParamName) {
57  		return _config.getParameter(configParamName);
58  	}
59  
60  	public int getIntValue(String configParamName) {
61  		String value = _config.getParameter(configParamName);
62  		return Integer.parseInt(value);
63  	}
64  
65  	public float getFloatValue(String configParamName) {
66  		String value = _config.getParameter(configParamName);
67  		return Float.parseFloat(value);
68  	}
69  
70  	public boolean getBoolValue(String configParamName) {
71  		String value = _config.getParameter(configParamName);
72  		return Boolean.parseBoolean(value);
73  	}
74  
75  	public HashSet<String> getChangedParamSet() {
76  		return changedParamSet;
77  	}
78  }