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