FileDocCategorySizeDatePackage
TemplatedViolatedConstraintNameExtracter.javaAPI DocHibernate 3.2.51321Sat Nov 20 17:11:28 GMT 2004org.hibernate.exception

TemplatedViolatedConstraintNameExtracter

public abstract class TemplatedViolatedConstraintNameExtracter extends Object implements ViolatedConstraintNameExtracter
Knows how to extract a violated constraint name from an error message based on the fact that the constraint name is templated within the message.
author
Steve Ebersole

Fields Summary
Constructors Summary
Methods Summary
protected java.lang.StringextractUsingTemplate(java.lang.String templateStart, java.lang.String templateEnd, java.lang.String message)
Extracts the constraint name based on a template (i.e., templateStartconstraintNametemplateEnd).

param
templateStart The pattern denoting the start of the constraint name within the message.
param
templateEnd The pattern denoting the end of the constraint name within the message.
param
message The templated error message containing the constraint name.
return
The found constraint name, or null.

		int templateStartPosition = message.indexOf( templateStart );
		if ( templateStartPosition < 0 ) {
			return null;
		}

		int start = templateStartPosition + templateStart.length();
		int end = message.indexOf( templateEnd, start );
		if ( end < 0 ) {
			end = message.length();
		}

		return message.substring( start, end );