Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## umontreal.iro.lecuyer.xmlconfig
Class ParamReader.MethodComparator

    java.lang.Object
      umontreal.iro.lecuyer.xmlconfig.ParamReader.MethodComparator

All Implemented Interfaces:
  Comparator<Method>

Enclosing class:
  ParamReader

    public static class ParamReader.MethodComparator

extends Object
implements Comparator<Method>

Comparator for sorting the methods returned by `Introspection.getMethods(java.lang.Class)`. For more consistent searching of overloaded methods, the `ParamReader.processElement(org.w3c.dom.Element, umontreal.iro.lecuyer.xmlconfig.Param)` method sorts the methods returned by `Introspection.getMethods(java.lang.Class)`. Methods with different names are sorted in alphabetical order. If two or more methods have the same name, they are sorted from the greatest to the smallest visibility: public, protected, package-private, and private. If two methods share the same name and visibility, they are sorted from the greatest to the smallest number of arguments.

When methods with the same name, visibility, and same number of arguments must be compared, the comparator applies a test to each argument, until the methods can be ordered. First, argument 0 is compared with other methods' argument 0. If the arguments are equal, or cannot be ordered, the test is performed with argument 1, 2, etc., until the arguments can be ordered. If all the arguments are equal or cannot be ordered, the methods cannot be ordered and are declared equal by the comparator. In this case, the final order of the methods depends on the Virtual Machine being used.

Table 4: Score assigned to classes when comparing arguments
Class (including subclasses) | Score
`ParamReader` | 1
`Node` | 2
`Param` | 3
`TimeParam` or primitive type | 4
`Number` | 5
`File`, `URI`, `URL` | 6
`String` | 7
`Object` | 8
Other | 10
Arrays | 2xComponent

Arguments are compared based on their types only. To compare data types, the comparator assigns a score to each one and orders the type with the smallest score first. For array types, the score of the component type is multipled by two. If types have the same score, they are equal or cannot be ordered by this algorithm. Table 4 gives the score assigned to each class.

Constructor Summary
`ParamReader.MethodComparator()`

Method Summary
`int` | `compare(Method m1, Method m2)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.util.Comparator
`equals`

Constructor Detail

### ParamReader.MethodComparator

    public ParamReader.MethodComparator()

Method Detail

### compare

    public int compare(Method m1,
                       Method m2)

  Specified by:
    `compare` in interface `Comparator<Method>`

Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

To submit a bug or ask questions, send an e-mail to Richard Simard.