View Javadoc

1   package org.minetti.astrodevice.server.usb.jni.impl;
2   
3   import org.minetti.astrodevice.common.device.DeviceNode;
4   import org.minetti.astrodevice.server.usb.jni.UsbDeviceTreeBuilder;
5   
6   /**
7    * Builder of device tree.
8    * @author Jean-Philippe MINETTI
9    */
10  public final class UsbDeviceTreeBuilderImpl
11  		implements UsbDeviceTreeBuilder {
12  	
13  	/**
14  	 * Current parent node.
15  	 */
16  	private DeviceNode currentParentNode;
17  	
18  	/**
19  	 * Last node.
20  	 */
21  	private DeviceNode lastNode;
22  	
23  	/**
24  	 * Constructor.
25  	 * @param rootNode Root node.
26  	 */
27  	public UsbDeviceTreeBuilderImpl (final DeviceNode rootNode) {
28  		super();
29  		this.currentParentNode = null;
30  		this.lastNode = rootNode;
31  	}
32  
33  	/* (non-Javadoc)
34  	 * @see org.minetti.astrodevice.server.usb.jni.UsbDeviceTreeBuilder#down()
35  	 */
36  	public synchronized void down () {
37  		this.currentParentNode = this.lastNode;
38  	}
39  
40  	/* (non-Javadoc)
41  	 * @see org.minetti.astrodevice.server.usb.jni.UsbDeviceTreeBuilder#up()
42  	 */
43  	public synchronized void up () {
44  		this.lastNode = this.currentParentNode;
45  		this.currentParentNode = this.currentParentNode.getParent();
46  	}
47  
48  	/* (non-Javadoc)
49  	 * @see org.minetti.astrodevice.server.usb.jni.UsbDeviceTreeBuilder#addHostController(java.lang.String)
50  	 */
51  	public synchronized void addHostController (final String description) {
52  		this.lastNode = new DeviceNode(this.currentParentNode, description, null, null);
53  		this.currentParentNode.getChildren().add(this.lastNode);
54  	}
55  
56  	/* (non-Javadoc)
57  	 * @see org.minetti.astrodevice.server.usb.jni.UsbDeviceTreeBuilder#addRootHub()
58  	 */
59  	public synchronized void addRootHub () {
60  		this.lastNode = new DeviceNode(this.currentParentNode, "Root hub", null, null);
61  		this.currentParentNode.getChildren().add(this.lastNode);
62  	}
63  
64  	/* (non-Javadoc)
65  	 * @see org.minetti.astrodevice.server.usb.jni.UsbDeviceTreeBuilder#addHub(int, int, java.lang.String, java.lang.String, int, java.lang.String, short, short, short)
66  	 */
67  	public synchronized void addHub (final int vendorId, final int productId, final String manufacturerName, final String productDescription, final int productVersion, final String serialNumber, final short deviceClass,
68  			final short deviceSubClass, final short deviceProtocol) {
69  
70  		this.lastNode = new DeviceNode(this.currentParentNode, "Root hub", null, null);
71  		
72  		// TODO Auto-generated method stub
73  
74  		this.currentParentNode.getChildren().add(this.lastNode);
75  	}
76  
77  	/* (non-Javadoc)
78  	 * @see org.minetti.astrodevice.server.usb.jni.UsbDeviceTreeBuilder#add(int, int, java.lang.String, java.lang.String, int, java.lang.String, short, short, short)
79  	 */
80  	public synchronized void add (final int vendorId, final int productId, final String manufacturerName, final String productDescription, final int productVersion, final String serialNumber, final short deviceClass,
81  			final short deviceSubClass, final short deviceProtocol) {
82  		// TODO Auto-generated method stub
83  
84  	}
85  
86  }