summaryrefslogtreecommitdiff
path: root/sources/scala/tools/util/debug/ToStringDebugger.java
blob: 85e0e187768aa3d2533d16b54f59f6e6211c231b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002, LAMP/EPFL              **
** /_____/\____/\___/\____/____/                                        **
\*                                                                      */

// $Id$

package scala.tools.util.debug;

/**
 * This class implements a debugger that appends objects that are
 * instances of a specified class (or of one of its subclass) by
 * simply appending the string returned by their method "toString".
 */
public class ToStringDebugger implements Debugger {

    //########################################################################
    // Private Fields

    /** The class whose instances can be appended */
    private final Class clasz;

    //########################################################################
    // Public Constructors

    /** Initializes this instance. */
    public ToStringDebugger(Class clasz) {
        this.clasz = clasz;
    }

    //########################################################################
    // Public Methods

    public boolean canAppend(Object object) {
        return clasz.isInstance(object);
    }

    public void append(StringBuffer buffer, Object object) {
        buffer.append(object.toString());
    }

    //########################################################################
}