KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > samples > encoding > Data


1 package samples.encoding;
2
3 public class Data
4 {
5     public String JavaDoc stringMember;
6     public Float JavaDoc floatMember;
7     public Data dataMember;
8     
9     public String JavaDoc toString()
10     {
11         return getStringVal("", this);
12     }
13     
14     public String JavaDoc getStringVal(String JavaDoc indent, Data topLevel)
15     {
16         String JavaDoc ret = "\n" + indent + "Data:\n";
17         ret += indent + " str[" + stringMember + "]\n";
18         ret += indent + " float[" + floatMember + "]\n";
19         ret += indent + " data[";
20         
21         if (dataMember != null) {
22             if (dataMember == topLevel) {
23                 ret += " top level";
24             } else
25                 ret += dataMember.getStringVal(indent + " ", topLevel) + "\n" + indent;
26         } else
27             ret += " null";
28         
29         ret += " ]";
30         return ret;
31     }
32 }
33
Popular Tags