Ticket #72 (closed enhancement: fixed)

Opened 9 months ago

Last modified 9 months ago

stubXMLMatcherAnnotation should add delimiter if not set

Reported by: mikey Assigned to: schst
Priority: minor Milestone: 0.3.0
Component: XMLSerializer Version: SVN-trunk
Keywords: Cc:

Description

When using the stubXMLMatcherAnnotation one must supply the pattern to be used for the matching with regular expressions. If you forget to write a delimiter at the beginning and the end of the pattern an E_WARNING is issued twice:

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or
backslash in /path/to/stubbles/src/main/php/net/stubbles/xml/serializer/annotations/stubXMLMatcherAnnotation.php
on line 67

It would be more userfriendly if the annotation detects missing delimiters and tries to add them automatically to prevent the issue of this warnings.

(Notice: the pattern is used in line 50 as well.)

Change History

08/06/07 21:43:16 changed by schst

I'd rather not change this behaviour as I cannot think of any decent way to detect the delimeters. Furthermore, this will cause problems, when trying to use modifiers.

08/06/07 23:27:46 changed by mikey

Well, then what about suppressing the warning by prepending the function call with an @ sign, check the return value if it equals to false and throw an exception in this case that obviously something is wrong with the regular expression?

08/06/07 23:34:55 changed by mikey

Another additional idea would be to rename the property of the annotation from pattern to regex or regularExpression to make it more clear that a complete regular expression is required.

08/07/07 09:05:47 changed by schst

  • status changed from new to assigned.

08/20/07 20:43:41 changed by schst

  • status changed from assigned to closed.
  • resolution set to fixed.

stubXMLSerializer will now throw a stubXMLException if the pattern is no valid regular expression.