01/* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com */ 02
namespace Db4objects.Db4odoc.�onstructors 03
{ 04
class C1 05
{ 06
private string s; 07
08
private C1(string s) 09
{ 10
this.s=s; 11
} 12
13
override public string ToString() 14
{ 15
return s; 16
} 17
} 18
}
01' Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com 02
Namespace Db4objects.Db4odoc.Constructors 03
Class C1 04
Private s As String 05
06
Private Sub New(ByVal s As String) 07
Me.s = s 08
End Sub 09
10
Public Overrides Function ToString() As String 11
Return s 12
End Function 13
End Class 14
End Namespace
[/filter]
The above class is fine for use with and without callConstructors set.
The above C2 class needs to have callConstructors set to true. Otherwise, since transient members are not stored and the constructor code is not executed, toString() will potentially run into a NullPointerException on x.length().
The above C3 class needs to have callConstructors set to false (the default), since the (only) constructor will throw a NullPointerException when called with a null value.
This class cannot be cleanly reinstantiated by db4o: both approaches will fail, so one has to resort to configuring a translator.