Abstract:
The invention consists of defining a generic class and a plurality of specific classes which extend from said generic class. Said specific classes are intended to be made into instances for the generation of an object tree. The generic class comprises a generic method of invoking a specific method of a specific class for the objects of the tree which are instances of this specific class. For a current object of the tree the generic method invokes said specific method if the current object is an instance of said specific class and it is recursively executed for the variables of the current object which are instances of one of said specific classes.

Description:
FIELD OF THE INVENTION  
         [0001]    The invention relates to a method of passing through a tree which contains objects which are instances of one or more specific classes with a view to invoking a specific method of one of said specific classes for the objects of said tree which are instances of said specific class.  
           [0002]    The invention also relates to a data structure written in an object programming language which comprises one or more specific classes intended to be instantiated for the generation of an object tree, at least one of said specific classes comprising at least one specific method.  
           [0003]    The invention also relates to a document written in an object programming language which comprises objects that are instances of specific classes defined in such a data structure.  
           [0004]    The invention also relates to a program written in an object programming language, comprising instructions for handling such a document when it is executed by a processor.  
           [0005]    The invention also relates to electronic equipment comprising a memory which contains such a program, such a document or such a data structure.  
           [0006]    The invention also relates to a signal which transports such a program, such a document or such a data structure.  
           [0007]    The invention has many applications particularly for processing document models.  
         BACKGROUND OF THE INVENTION  
         [0008]    Such an object tree is described, for example, in the specification “Document Object Model (DOM), level 1 specification, version 1.0, Oct. 1 1998” defined by the W3C consortium for modeling documents of the HTML or XML type.  
           [0009]    When such an object tree is handled, it is often necessary to pass through the tree to execute a specific method for certain objects. It is an object of the invention to propose a particularly efficient solution for passing through a tree comprising objects that are instances of one or more specific classes so as to invoke a specific method of one of said specific classes for the objects of said tree which objects are instances of this specific class.  
         SUMMARY OF THE INVENTION  
         [0010]    This object is achieved with a method of passing through a tree of objects as claimed in one of the claims 1 or 2 of the present application, with a data structure as claimed in claim 3, a document as claimed in claim 4 and a program as claimed in claim 5.  
           [0011]    The invention notably consists of dissociating the routing through the tree from the execution of specific methods. In fact, according to the invention, the generic method of invoking a specific method has for its function to route through the tree and invoke said specific method when it meets an object for which this method must be invoked. The specific methods carry out a specific processing for a current object. They do not manage the navigation in the tree.  
           [0012]    The invention thus permits to simplify the writing of data structures in which the route through a tree of objects is to be managed for the execution of certain methods for certain objects of the tree. 
       
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0013]    These and other aspects of the invention are apparent from and will be elucidated, by way of non-limitative example, with reference to the embodiment(s) described hereinafter.  
         [0014]    In the drawings:  
         [0015]    [0015]FIG. 1 is a diagrammatic representation of a data structure according to the invention,  
         [0016]    [0016]FIG. 2 gives an example of a tree that is generated in that the data structure represented in FIG. 1 is made into instances,  
         [0017]    [0017]FIG. 3 is a block diagram of an example of a method according to the invention,  
         [0018]    [0018]FIG. 4 is an example of equipment according to the invention which may receive signals, notably transport signals of a program or of a document according to the invention, and having a memory for storing such a program, such a document and such a data structure.  
     
    
     DESCRIPTION OF PREFERRED EMBODIMENTS  
       [0019]    In a general way a data structure according to the invention comprises a generic class GC and a plurality of specific classes SC i (i=1, . . . ,N) . Each class may comprise one or various instance variables notably instance variables of the object type. An instance variable of the object type is formed by an object or a table of objects that are instances of a specific class. A data structure according to the invention is defined so that its implementation generates a tree TR of objects ob i .  
         [0020]    According to the invention one or various specific classes SC I  comprise a specific method sM i . The specific methods sM I  have any number of arguments P I,j  (where j is any natural integer). The generic class GC comprises a generic method gM of invoking a specific method sM I  of a specific class SC I  for the objects ob I  of the tree TR which are instances of said specific class SC i . The specific classes SC I  extend from this generic class GC, so that they implicitly contain the generic method gM. To execute the generic method gM, the following arguments are to be specified:  
         [0021]    the specific method sM I  to be invoked,  
         [0022]    the specific class SC I  whose objects ob I  for which the specific method sM I  is to be invoked are instances,  
         [0023]    the arguments P i,j  of the method sM I , when it has any.  
         [0024]    In FIG. 1 is represented in diagrammatic manner an example of such a data structure. According to FIG. 1 the data structure DS comprises a generic class GC and five specific classes referred to as SC 1 , SC 2 , SC 3 , SC 4  and SC 5 . The specific class SC 1  comprises two instance variables which are instance objects of the specific classes SC 2  and SC 4 , respectively. These objects are numbered ob 2  and ob 4 , respectively. The specific class SC 2  comprises an instance variable which is an instance object of the specific class SC 3  and which is numbered ob 3 . The specific class SC 4  finally comprises two instance variables which are instance objects of the specific classes SC 2  and SC 5 , respectively, and which are numbered ob 2  and ob 5 , respectively.  
         [0025]    [0025]FIG. 2 shows an example of a tree TR which forms an instance of the data structure DS defined with respect to FIG. 1. This tree TR comprises an object ob 1  which points to a first object ob 2  and to an object ob 4 . The first object ob 2  is a first instance of the class SC 2 . The object ob 4  is an instance of the class SC 4 . The first object ob 2  points to a first object ob 3  which is a first instance of the class SC 3 . The object ob 4  points to a second object ob 2  which is a second instance of the class SC 2 , and to an object ob 5  which is an instance of the class SC 5 . The second object ob 2  points to a second object ob 3  which is a second instance of the class SC 3 .  
         [0026]    According to FIG. 1 the generic class GC comprises a generic method called gM(SC i , sM i , P i,j ) which is a generic method of invoking a specific method sM i  for the objects of the tree TR which are instances of a specific class SC i . When the generic method gM is executed for invoking a specific method sM i  that has one or more arguments P i,j , this or these arguments P i,j  are specified as arguments of the generic method gM. The specific classes sM i  (i=1, . . . , 5) extend from the generic class GC: in FIG. 1 this relationship is symbolized by the arrows H i (i=1, . . . , 5) . The specific classes SC 1 , SC 2  and SC 3  comprise each a specific method denoted sM 1 , sM 2  and sM 3 , respectively. The specific method sM 2  has two arguments denoted P 2,1  and P 2,2 , respectively. The other specific methods sM 1  and sM 3  do not have arguments.  
         [0027]    In FIG. 3 is represented a flowchart of a generic method gM(SC i , sM i , P i,j ) of routing through a tree to invoke the specific method sM i  for the objects of said tree which are instances of the specific class SC i . This generic method consists of routing through the tree from its root and carrying out the following steps for a current object of the tree denoted obj:  
         [0028]    step S 1 : test to determine whether the current object obj is an instance of the specific class SC i  (“Class(obj)=SC i ?”)  
         [0029]    step S 2 : if the current object is an instance of the class SC i  (arrow Y), invocation of the specific method sM i (P i,j )  
         [0030]    step S 3 : routing through the instance variables (field) of the current object obj and for each instance variable:  
         [0031]    if the instance variable is an instance object of a class extending from the generic class GC (“Class(field) extends from GC”), recursive execution of the generic method gM(SC i , sM i , P i,j ) for this object (step S 3 - 1 )  
         [0032]    if the instance variable is a table of instance objects of a class extending from the generic class GC (“Class(field[k]) extends from GC”), recursive execution of the generic method gM(SC i , sM i , P i,j ) for each object (step S 3 - 2 ).  
         [0033]    The invention is notably applied for the processing of document models, for example, for the processing of an XML diagram model which describes the format of an XML document (XML diagram and XML are a recommendation project and a recommendation, respectively, of the W3C consortium, available, for example, on the Internet site http://www.w3.org). Such a diagram constitutes a tree of objects called elements which are instances of a class “Element”. An Element may comprise one or various other elements. For each Element the diagram notably defines a name and a type. Generally, to simplify the description of the diagram, numbered types are used. A numbered type is defined once and for all in the diagram and it is then called by its name. If one wishes to utilize such a diagram, it is necessary to resolve the types of the elements it contains, that is to say, to search for the definition of the named type of each element found. For this purpose the class Element comprises a type resolving method “resolveElementType”.  
         [0034]    This method is advantageously a specific method in the sense of the present invention. The class Element is then a specific class in the sense of the invention which extends from a generic class. This generic class comprises a generic method of invoking a specific method. This generic method is executed for each element of the diagram to invoke the type resolving method “resolveElementType”. The data structure in which are defined the specific class “Element” and the generic class from which it extends is thus a data structure according to the invention. Similarly, the diagram is a document according to the invention and any program that handles this diagram is a program according to the invention.  
         [0035]    By applying the invention it is avoided having to manage the routing through the tree in the main part of the method of resolving the type.  
         [0036]    The generic method thus defined is advantageously utilized for invoking other specific methods which would be defined in the class Element, for example, a specific display method “printName” of the name of the elements of the diagram, utilized for debugging said diagram.  
         [0037]    [0037]FIG. 4 shows a diagram of electronic equipment EQU comprising:  
         [0038]    a microprocessor assembly MP which notably comprises a data memory DM, a program memory PM and a processor PC which make it possible to execute the programs stored in the program memory PM.  
         [0039]    a transmission device TX/RX permitting to receive signals, notably signals that transport programs.  
         [0040]    When the equipment EQU receives a signal SGL that transports a program SOFT according to the invention, this program SOFT is stored in the program memory PM. When the equipment EQU receives a signal SGL that transports a data structure DS according to the invention and/or a document DOC according to the invention, this data structure DS and/or this document DOC are stored in the data memory DM.