fr.emn.reactiveinput.descriptor
Class DescriptorUtilities

java.lang.Object
  extended byfr.emn.reactiveinput.descriptor.DescriptorUtilities

public class DescriptorUtilities
extends java.lang.Object

This class contains useful methods for creating your own descriptor.


Constructor Summary
DescriptorUtilities()
           
 
Method Summary
static java.lang.String booleanToString(boolean b)
           
static DeviceDescriptor createDD(java.lang.String script)
          Creates a DeviceDescriptor given its creation script.
static DeviceDescriptor[] createDDDeclares(java.lang.String listScript)
          Creates a group of descriptor declarations given their creation script.
static DeviceDescriptor[] createDDs(java.lang.String listScript)
          Creates a group of descriptors given their creation script (used by meta descriptors)
static InDescriptor createID(java.lang.String script)
          Creates a InDescriptor given its creation script.
static InDescriptor[] createIDs(java.lang.String listScript)
          Creates a group of descriptors given their creation script (used by meta descriptors)
static OutDescriptor createOD(java.lang.String script)
          Creates a OutDescriptor given its creation script.
static OutDescriptor[] createODs(java.lang.String listScript)
          Creates a group of descriptors given their creation script (used by meta descriptors)
protected static java.lang.String descriptorClassToKeyword(int type, java.lang.Class cl)
           
protected static java.lang.Class descriptorKeywordToClass(int type, java.lang.String keyword)
           
static DeviceDescriptor getDefaultDescriptor(Device d)
          Creates a default descriptor for the device d.
static InDescriptor getDefaultDescriptor(In s)
          Creates a default descriptor for the input slot o.
static OutDescriptor getDefaultDescriptor(Out o)
          Creates a default descriptor for the output slot o.
static DeviceDescriptor getDefaultSignature(DeviceFolder folder, Device device)
          Returns the default signature of a device for the given folder.
static java.lang.String getFullFolderName(DeviceFolder f)
          Returns the full name of a folder (path+name) to use with DDFolder.
static java.lang.String getScript(DeviceDescriptor desc)
          Returns the creation script for the DeviceDescriptor.
static java.lang.String getScript(DeviceDescriptor[] desc)
          Returns the creation script for a list of DeviceDescriptors.
static java.lang.String getScript(InDescriptor desc)
          Returns the creation script for the InDescriptor.
static java.lang.String getScript(InDescriptor[] desc)
          Returns the creation script for a list of InDescriptors.
static java.lang.String getScript(OutDescriptor desc)
          Returns the creation script for the OutDescriptor.
static java.lang.String getScript(OutDescriptor[] desc)
          Returns the creation script for a list of OutDescriptors.
static DeviceDescriptor getValid(DeviceDescriptor desc)
          Ensures that a device descriptor is valid.
static DeviceDescriptor[] getValid(DeviceDescriptor[] desc)
          Returns an array of valid descriptors.
static InDescriptor getValid(InDescriptor desc)
          Ensures that an InDescriptor is valid.
static InDescriptor[] getValid(InDescriptor[] desc)
          Returns an array of valid descriptors.
static OutDescriptor getValid(OutDescriptor desc)
          Ensures that an OutDescriptor is valid.
static OutDescriptor[] getValid(OutDescriptor[] desc)
          Returns an array of valid descriptors.
static DeviceDescriptor[] removeDescriptors(DeviceDescriptor[] desc, java.lang.Class cl)
          Removes all DDAny descriptors from the array.
static boolean stringToBoolean(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DescriptorUtilities

public DescriptorUtilities()
Method Detail

booleanToString

public static java.lang.String booleanToString(boolean b)

createDD

public static DeviceDescriptor createDD(java.lang.String script)
Creates a DeviceDescriptor given its creation script.

To retreive the class name, a "DD" prefix is added to the descriptor name and its first letter is put upper case.

If the class name is not a fully-qualified name, the "fr.emn.reactiveinput.descriptor" package is also added.

This method always returns a valid DeviceDescriptor. If the script is not valid, a DDError is returned.


createDDDeclares

public static DeviceDescriptor[] createDDDeclares(java.lang.String listScript)
Creates a group of descriptor declarations given their creation script.


createDDs

public static DeviceDescriptor[] createDDs(java.lang.String listScript)
Creates a group of descriptors given their creation script (used by meta descriptors)


createID

public static InDescriptor createID(java.lang.String script)
Creates a InDescriptor given its creation script.

To retreive the class name, a "ID" prefix is added to the descriptor name and its first letter is put upper case.

If the class name is not a fully-qualified name, the "fr.emn.reactiveinput.descriptor" package is also added.

This method always returns a valid InDescriptor. If the script is not valid, a IDError is returned.


createIDs

public static InDescriptor[] createIDs(java.lang.String listScript)
Creates a group of descriptors given their creation script (used by meta descriptors)


createOD

public static OutDescriptor createOD(java.lang.String script)
Creates a OutDescriptor given its creation script.

To retreive the class name, a "OD" prefix is added to the descriptor name and its first letter is put upper case.

If the class name is not a fully-qualified name, the "fr.emn.reactiveinput.descriptor" package is also added.

This method always returns a valid OutDescriptor. If the script is not valid, a ODError is returned.


createODs

public static OutDescriptor[] createODs(java.lang.String listScript)
Creates a group of descriptors given their creation script (used by meta descriptors)


getDefaultDescriptor

public static DeviceDescriptor getDefaultDescriptor(Device d)
Creates a default descriptor for the device d.

This descriptor includes device class, name, in and out slots. PENDING: RESTRICT DESCRIPTOR WITH ADDITIONAL DESCRIPTOR CLASSES


getDefaultDescriptor

public static InDescriptor getDefaultDescriptor(In s)
Creates a default descriptor for the input slot o. This descriptor includes (...). PENDING: RESTRICT DESCRIPTOR WITH ADDITIONAL DESCRIPTOR CLASSES


getDefaultDescriptor

public static OutDescriptor getDefaultDescriptor(Out o)
Creates a default descriptor for the output slot o. This descriptor includes (...). PENDING: RESTRICT DESCRIPTOR WITH ADDITIONAL DESCRIPTOR CLASSES


getDefaultSignature

public static DeviceDescriptor getDefaultSignature(DeviceFolder folder,
                                                   Device device)
Returns the default signature of a device for the given folder. This signature will be used by default to serialize the device.


descriptorKeywordToClass

protected static java.lang.Class descriptorKeywordToClass(int type,
                                                          java.lang.String keyword)

getFullFolderName

public static java.lang.String getFullFolderName(DeviceFolder f)
Returns the full name of a folder (path+name) to use with DDFolder.


getScript

public static java.lang.String getScript(DeviceDescriptor[] desc)
Returns the creation script for a list of DeviceDescriptors. (used by meta descriptors)


getScript

public static java.lang.String getScript(InDescriptor[] desc)
Returns the creation script for a list of InDescriptors. (used by meta descriptors)


getScript

public static java.lang.String getScript(OutDescriptor[] desc)
Returns the creation script for a list of OutDescriptors. (used by meta descriptors)


getScript

public static java.lang.String getScript(DeviceDescriptor desc)
Returns the creation script for the DeviceDescriptor.

In script form, the "DD" class suffix is removed, and the first character is put lowercase.

If the descriptor belongs to fr.emn.reactiveinput.descriptor package, its single name is used. For other descriptors, the fully-qualified class name is used.

If the descriptor is initially not valid (null or getString()=null), this method returns a DDError creation script.


getScript

public static java.lang.String getScript(InDescriptor desc)
Returns the creation script for the InDescriptor.

In script form, the "ID" class suffix is removed, and the first character is put lowercase.

If the descriptor belongs to fr.emn.reactiveinput.descriptor package, its single name is used. For other descriptors, the fully-qualified class name is used.

If the descriptor is initially not valid (null or getString()=null), this method returns a IDError creation script.


getScript

public static java.lang.String getScript(OutDescriptor desc)
Returns the creation script for the OutDescriptor.

In script form, the "OD" class suffix is removed, and the first character is put lowercase.

If the descriptor belongs to fr.emn.reactiveinput.descriptor package, its single name is used. For other descriptors, the fully-qualified class name is used.

If the descriptor is initially not valid (null or getString()=null), this method returns a ODError creation script.


descriptorClassToKeyword

protected static java.lang.String descriptorClassToKeyword(int type,
                                                           java.lang.Class cl)

getValid

public static DeviceDescriptor[] getValid(DeviceDescriptor[] desc)
Returns an array of valid descriptors.

If the array argument is null itself, returns an empty array.


getValid

public static InDescriptor[] getValid(InDescriptor[] desc)
Returns an array of valid descriptors.

If the array argument is null itself, returns an empty array.


getValid

public static OutDescriptor[] getValid(OutDescriptor[] desc)
Returns an array of valid descriptors.

If the array argument is null itself, returns an empty array.


getValid

public static DeviceDescriptor getValid(DeviceDescriptor desc)
Ensures that a device descriptor is valid.

Returns a DDError instead if:

  • desc argument is null
  • descriptor's class name is not valid
  • descriptor's string form is null
  • descriptor's string form has mismatched block delimiters


  • getValid

    public static InDescriptor getValid(InDescriptor desc)
    Ensures that an InDescriptor is valid.

    Returns a IDError instead if:

  • desc argument is null
  • descriptor's class name is not valid
  • descriptor's string form is null
  • descriptor's string form has mismatched block delimiters


  • getValid

    public static OutDescriptor getValid(OutDescriptor desc)
    Ensures that an OutDescriptor is valid.

    Returns a ODError instead if:

  • desc argument is null
  • descriptor's class name is not valid
  • descriptor's string form is null
  • descriptor's string form has mismatched block delimiters


  • removeDescriptors

    public static DeviceDescriptor[] removeDescriptors(DeviceDescriptor[] desc,
                                                       java.lang.Class cl)
    Removes all DDAny descriptors from the array. Used in DDAnd.

    If nothing remains, adds a DDAny.


    stringToBoolean

    public static boolean stringToBoolean(java.lang.String s)