Re: [Simple-support] suggestion for re pattern checkers ...
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2012-07-08 23:30:53
|
If this is for validation you can always use the @Validate annotation.
--- On Sun, 8/7/12, -=}\*/{=- <rui...@gm...> wrote:
From: -=}\*/{=- <rui...@gm...>
Subject: [Simple-support] suggestion for re pattern checkers ...
To: sim...@li...
Received: Sunday, 8 July, 2012, 6:13 AM
hi,
it would be nice to be able configure RE pattern checkers for strings and primitives...
// primitive@Attribute (pattern="\d{2}")int max99;
// string@Attribute (pattern="\d{1,3}-\d{1,3}")String range;
@Element (pattern="[a-zA-Z]{4,20}")
String firstName;
@Attribute (pattern="\p{Lower}{14}")String username;
// object
@Element (pattern="[a-zA-Z]{4,20} [a-zA-Z]{4,20}")FullName fn;
@Rootclass FullName {
String firstName, String lastName;
// ... @FromString public void parse(String s) {...}
@ToString // you may want to use the real toString for other stuff public String toString() {return firstName + " " + lastName;}
}
//// the code bellow would be nicer though... no need to write parse code or repeat patterns :)//// object @Element (pattern="([a-zA-Z]{4,20}) ([a-zA-Z]{4,20})")
FullName fn;
// object @Element (pattern="([a-zA-Z]{4,20}) ([a-zA-Z]{4,20})")FullName fn;
@Root (asPrimitive = true)
class FullName {
@Pattern (group = 0) String firstName, @Pattern (group = 1) String lastName; // ... @ToString public String toString() {return firstName + " " + lastName;}
}
... implied when reading and optional when writing...
think about it :)
[NiceSunDay]r.
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|