Re: Data::Dumper for java



horos11@xxxxxxxxx wrote:
Perl has a very nice class called Data::Dumper which recursively
prints out data structures and objects, such that if an object owns
other objects, those too are printed out in 'standardized' form (ie:
showing all public and private fields of those subobjects).

Is there an equivalent module in java?

I know you could make one using reflection; my question is *has*
someone made one, one that is tunable (ie: that can override objects'
toString() methods, shows only so many levels of output, etc. Being
able to override toString() for subobjects is very important because
Java so helpfully provides a somewhat meaningless toString() function
for Object)


I'm unfamiliar with Perl and it's libraries, so I have to ask -- what would you do with such a thing?

For debugging, my debugger shows me all I need, with out any work whatsoever on my part. I haven't looked into logging utilities but the default ones do take an object as a parameter. This might just invoke toString() however. Then there's Serialization and XMLEncoder/Decoder, which might be consdiered "stadardized" forms also.

For documentation, there's this thing called Javadoc. Try it, you might like it.
.



Relevant Pages

  • Data::Dumper for java
    ... showing all public and private fields of those subobjects). ... one that is tunable (ie: that can override objects' ... toString() methods, shows only so many levels of output, etc. ... Java so helpfully provides a somewhat meaningless toStringfunction ...
    (comp.lang.java.programmer)
  • Re: Impossible to pass implicitly vairable names of values by explicitly passing the other?
    ... I have thought about a similar trick before. ... Java library objects, ... If the object in question are your own, override the toString() ... You can also override the toStringmethod in an anonymous inner ...
    (comp.lang.java.programmer)
  • Re: ***Javaprogramm gibt falsche Ausgabe aus***
    ... String konvertieren, welcher dann ausgegeben wird. ... benutzt Java die Methode toString(). ... Bei einem Array ...
    (de.comp.lang.java)
  • Re: Bibliothekserweiterungen in C
    ... Die Laufzeitumgebung in Java kann annehmen, das für jedes Objekt eine Funktion toStringbereitsteht. ... Über die Vererbungsautomatik bei der Erstellung neuer Objekte wird immer dafür gesorgt, das wenigstens eine Standard-Implementierung beigefügt ist. ... man selbst den Aufwand treiben und sicherstellen, das in JEDER Struktur einen Funktionszeiger auf die toString() Funktion existiert. ...
    (de.comp.lang.c)
  • Re: AspectJ: solution to Javas repetitiveness?
    ... While I'm very impressed with the Eclipse IDE for Java and the ... equal, toString(), toXML, fromString, fromXMLfor all of them. ... Perhaps for very simple classes whose instance variables are ... equals() and hashCode... ...
    (comp.lang.java.programmer)