FileDocCategorySizeDatePackage
UPnPDeviceImpl.javaAPI DocAzureus 3.0.3.44915Tue Sep 25 13:45:14 BST 2007com.aelitis.net.upnp.impl.device

UPnPDeviceImpl

public class UPnPDeviceImpl extends Object implements UPnPDevice
author
parg

Fields Summary
private UPnPRootDeviceImpl
root_device
private String
device_type
private String
friendly_name
private String
model_name
private String
model_number
private String
model_url
private List
devices
private List
services
Constructors Summary
protected UPnPDeviceImpl(UPnPRootDeviceImpl _root_device, String indent, org.gudy.azureus2.plugins.utils.xml.simpleparser.SimpleXMLParserDocumentNode device_node)

	
	
	
						
									
				 
	
		root_device		= _root_device;
		
		device_type		= getMandatoryField( device_node, "DeviceType" );
		friendly_name	= getMandatoryField( device_node, "FriendlyName" );
		
		/*
		  <modelName>3Com ADSL 11g</modelName> 
		  <modelNumber>1.07</modelNumber> 
		  <modelURL>http://www.3com.com/</modelURL> 
		  */
		
		model_name		= getOptionalField( device_node, "modelName" );
		model_number	= getOptionalField( device_node, "modelNumber");
		model_url		= getOptionalField( device_node, "modelURL");
		
		boolean	interested = device_type.equalsIgnoreCase( "urn:schemas-upnp-org:device:WANConnectionDevice:1" );
		
		root_device.getUPnP().log( indent + friendly_name + (interested?" *":""));
		
		SimpleXMLParserDocumentNode	service_list = device_node.getChild( "ServiceList" );
		
		if ( service_list != null ){
				
			SimpleXMLParserDocumentNode[] service_nodes = service_list.getChildren();
			
			for (int i=0;i<service_nodes.length;i++){
				
				services.add( new UPnPServiceImpl( this, indent + "  ", service_nodes[i]));
			}
		}
		
		SimpleXMLParserDocumentNode	dev_list = device_node.getChild( "DeviceList" );
		
		if ( dev_list != null ){
				
			SimpleXMLParserDocumentNode[] device_nodes = dev_list.getChildren();
			
			for (int i=0;i<device_nodes.length;i++){
				
				devices.add( new UPnPDeviceImpl( root_device, indent + "  ", device_nodes[i]));
			}
		}
	
Methods Summary
public synchronized voidclearRelativeBaseURL()

		root_device.clearRelativeBaseURL();
	
public java.lang.StringgetAbsoluteURL(java.lang.String url)

		return( root_device.getAbsoluteURL(url));
	
public java.lang.StringgetDeviceType()

		return( device_type );
	
public java.lang.StringgetFriendlyName()

		return( friendly_name );
	
public java.net.InetAddressgetLocalAddress()

		return( root_device.getLocalAddress());
	
protected java.lang.StringgetMandatoryField(org.gudy.azureus2.plugins.utils.xml.simpleparser.SimpleXMLParserDocumentNode node, java.lang.String name)

		SimpleXMLParserDocumentNode	child = node.getChild(name);
		
		if ( child == null ){
			
			root_device.getUPnP().log( "Mandatory field '" + name + "' is missing" );
			
			return( "<missing field '" + name + "'>" );
		}
		
		return( child.getValue().trim());
	
public java.lang.StringgetModeURL()

		return( model_url );
	
public java.lang.StringgetModelName()

		return( model_name );
	
public java.lang.StringgetModelNumber()

		return( model_number );
	
protected java.lang.StringgetOptionalField(org.gudy.azureus2.plugins.utils.xml.simpleparser.SimpleXMLParserDocumentNode node, java.lang.String name)

		SimpleXMLParserDocumentNode	child = node.getChild(name);
		
		if ( child == null ){
			
			return( null);
		}
		
		return( child.getValue().trim());
	
public UPnPRootDevicegetRootDevice()

		return( root_device );
	
public UPnPService[]getServices()

		UPnPService[]	res = new UPnPService[services.size()];
		
		services.toArray( res );
		
		return( res );
	
public UPnPDevice[]getSubDevices()

		UPnPDevice[]	res = new UPnPDevice[devices.size()];
		
		devices.toArray( res );
		
		return( res );
	
public UPnPImplgetUPnP()

		return( (UPnPImpl)root_device.getUPnP());
	
public synchronized voidrestoreRelativeBaseURL()

		root_device.restoreRelativeBaseURL();