View Javadoc
1   /*
2    * Created on 15.03.2004
3    *
4    * To change the template for this generated file go to
5    * Window - Preferences - Java - Code Generation - Code and Comments
6    */
7   package net.sf.dexterim.oscar.entity;
8   
9   import java.util.Hashtable;
10  import java.util.Iterator;
11  import java.util.Map;
12  
13  import net.sf.dexterim.oscar.server.Response;
14  
15  
16  /***
17   * @author christoph
18   *
19   * To change the template for this generated type comment go to
20   * Window - Preferences - Java - Code Generation - Code and Comments
21   */
22  public class SnacFamiliesVersions implements Response {
23  	private Map families;
24  	
25  	public SnacFamiliesVersions() {
26  		this.families = new Hashtable();
27  	}
28  	
29  	public void add(SnacFamily family) {
30  		families.put(family.getId(), family);
31  	}
32  	
33  	public Iterator iterator() {
34  		return families.values().iterator();
35  	}
36  
37  	/***
38  	 * @param snac
39  	 * @return
40  	 */
41  	public static Response create(Snac snac) {
42  		SnacFamiliesVersions versions = new SnacFamiliesVersions();
43  
44  		byte versionData[] = snac.getData();
45  		for (int i = 0; i < versionData.length; i += 4) {
46  			Word family = new Word(new byte[]{versionData[i], versionData[i + 1]});
47  			Word version = new Word(new byte[]{versionData[i + 2],
48  					versionData[i + 3]});
49  
50  			versions.add(new SnacFamily(family.getValue(), version.getValue()));
51  		}
52  
53  		return versions;
54  	}
55  }