aspose file tools*
The moose likes Beginning Java and the fly likes validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "validation" Watch "validation" New topic
Author

validation

lanshu usav
Greenhorn

Joined: Aug 18, 2005
Posts: 3
Dear friends,

I have a Srting that is passed to me. I need to verify that the string passed is an object of a URLEncodedString class. I request you guys for an idea how to do it.


Thanks,
lanshu
Thomas Paul Bigbee
Ranch Hand

Joined: Jun 28, 2005
Posts: 71
Create a boolean good flag

Try and create URL object with your string
if the object can be created, set the good flag to true
else catch the exception and take appropriate action.

public URL(String spec)
throws MalformedURLException


Creates a URL object from the String representation.

This constructor is equivalent to a call to the two-argument constructor with a null first argument.


Parameters:

spec - the String to parse as a URL.

Throws:

MalformedURLException - If the string specifies an unknown protocol.

See Also:

URL(java.net.URL, java.lang.String)
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 690
    
    1
Where is the URLEncodedString class defined?
I find something with a similiar name: java.net.URLEncoder in the 1.5 doc.


If you are asking how to detect if a String has been encoded:
You could run it thru the decode and then encode it and compare to original.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validation