01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.util;
11:
12: /**
13: * <p>
14: * The {@link SizeOf} class tries to determine the size of memory structures.
15: * This is tried by reflection and so on, but if an object is
16: * 'SizeMeasurable' then it is asked to the object directly.
17: *</p>
18: *<p>
19: * So, if your object stores its bulk in private members, and you want
20: * its size to be determined adequately, then you should let it
21: * implement this interface.
22: *</p>
23: *<p>
24: * If you did not implement a class yourself, but have a clue how to
25: * guess the size anyhow, then you could also put this implementation
26: * in SizeOf itself (as for example was done for String). The
27: * disadvantage of this approach is of course that you don't have
28: * access to private members.
29: *</p>
30: * @author Michiel Meeuwissen
31: * @since MMBase-1.6
32: * @version $Id: SizeMeasurable.java,v 1.4 2005/05/20 09:02:54 michiel Exp $
33: */
34: public interface SizeMeasurable {
35: /**
36: * Determines the byte-size of this object
37: */
38: public int getByteSize();
39:
40: /**
41: * Determines the byte-size of this object using the given SizeOf instance.
42: * A SizeOf instance stores a Set already counted objects. So this method is typically called by SizeOf itself (recursion).
43: */
44: public int getByteSize(SizeOf sizeof);
45: }
|