wiiremotej
Class WRExtensionFactory

java.lang.Object
  extended by wiiremotej.WRExtensionFactory

public class WRExtensionFactory
extends java.lang.Object

A class representing a Nintendo (R) Wii Remote (TM) extension factory. It is used to obtain object-references to extensions based on their numeric codes.


Method Summary
 WRExtension createWRExtension(short code)
          Creates and returns a new WRExtension based on the given extension code.
static WRExtensionFactory getDefault()
          Returns the default WRExtensionFactory.
 boolean isExtensionRegistered(short code)
          Returns true if the given extension code has already been registered with this WRExtensionFactory; otherwise false.
 void registerExtension(WRExtension extensionType)
          Registers the given extension with this WRExtensionFactory.
 void removeExtension(short code)
          Removes the extension specified by the given code from this factory's list of registered extensions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createWRExtension

public WRExtension createWRExtension(short code)
Creates and returns a new WRExtension based on the given extension code.

Parameters:
code - the code indicating what kind of extension to return. If the code is unknown, null is returned.
Returns:
a new WRExtension matching code.

registerExtension

public void registerExtension(WRExtension extensionType)
                       throws java.lang.NullPointerException,
                              java.lang.IllegalArgumentException
Registers the given extension with this WRExtensionFactory. The provided WRExtension is used in two ways: 1. The getCode() method is used to identify this type of extension. 2. The getPayload() method is used to get the default payload for all extensions of this type created by the factory. Note that some extensions--particularly the Nunchuck and the Classic Controller--are registered by default.

Parameters:
extensionType - an instance of the type of WRExtension to be added.
Throws:
java.lang.NullPointerException - if extensionType is null.
java.lang.IllegalArgumentException - if the given extension (or another with the same code) is already registered with the current WRExtensionFactory.

removeExtension

public void removeExtension(short code)
Removes the extension specified by the given code from this factory's list of registered extensions. If the specified extension is not registered with this factory, then no action is taken.

Parameters:
code - the code of the extension to remove.

isExtensionRegistered

public boolean isExtensionRegistered(short code)
Returns true if the given extension code has already been registered with this WRExtensionFactory; otherwise false.

Returns:
true if the given extension code has already been registered with this WRExtensionFactory; otherwise false.

getDefault

public static WRExtensionFactory getDefault()
Returns the default WRExtensionFactory. Supports nunchuck and classic controller.

Returns:
the default WRExtensionFactory.