Hello,
constraints are considered to be state-less restrictions on values. State-less means independent of a certain context, which is why you don't have a handle on the affected node within a custom Java constraint class. Only by tricking / working around the integrity checking framework would I suspect you might be able to get a hold of the current node.
What I'd do in such an instance is implement a Java-based form filter, which can generate the constraint definition dynamically based on the current node reference. Of course, this only works for form-based UIs and does not provide automatic validation during saving, if you don't include the validation code in your form filter / a policy.
Regards
Axel