01: /*
02: * Copyright 2003 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: *
09: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */
13:
14: package com.sun.portal.common.util;
15:
16: public class URLEncodeUtils {
17:
18: /**
19: * Before any URL encoding, check to see if encoding is needed.
20: *
21: * @param value value to be checked
22: * @return <code>boolean</code>
23: */
24: public static boolean isEncodingNeeded(String value) {
25: boolean needsEncoding = false;
26: int length = value.length();
27: char c;
28: for (int i = 0; !needsEncoding && i < length; i++) {
29: c = value.charAt(i);
30: needsEncoding = (c < 'a' || c > 'z')
31: && (c < 'A' || c > 'Z') && c != '.' && c != '-'
32: && c != '*' && c != '_';
33: }
34: return needsEncoding;
35: }
36:
37: }
|