Makefile.am: Added URLDecoder and URLEncoder.
* Makefile.am: Added URLDecoder and URLEncoder. * Makefile.in: Rebuilt. * java/net/ServerSocket.java (setSocketFactory): Renamed from setSocketImplFactory to match spec. * java/net/Socket.java (getSoLinger): Changed return type to match spec. * java/net/URLDecoder.java: New file. * java/net/URLEncoder.java: New file. From-SVN: r26605
This commit is contained in:
parent
d2692ef86e
commit
12571b1f96
8 changed files with 146 additions and 5 deletions
|
@ -1,3 +1,16 @@
|
|||
1999-04-23 Warren Levy <warrenl@cygnus.com>
|
||||
|
||||
* Makefile.am: Added URLDecoder and URLEncoder.
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
* java/net/ServerSocket.java (setSocketFactory): Renamed from
|
||||
setSocketImplFactory to match spec.
|
||||
* java/net/Socket.java (getSoLinger): Changed return type to
|
||||
match spec.
|
||||
|
||||
* java/net/URLDecoder.java: New file.
|
||||
* java/net/URLEncoder.java: New file.
|
||||
|
||||
1999-04-21 Tom Tromey <tromey@cygnus.com>
|
||||
|
||||
* java/lang/natString.cc (getBytes): Reverted earlier change and
|
||||
|
|
|
@ -513,6 +513,8 @@ java/net/SocketImpl.java \
|
|||
java/net/SocketImplFactory.java \
|
||||
java/net/URL.java \
|
||||
java/net/URLConnection.java \
|
||||
java/net/URLDecoder.java \
|
||||
java/net/URLEncoder.java \
|
||||
java/net/URLStreamHandler.java \
|
||||
java/net/URLStreamHandlerFactory.java \
|
||||
java/net/UnknownHostException.java \
|
||||
|
|
|
@ -374,6 +374,8 @@ java/net/SocketImpl.java \
|
|||
java/net/SocketImplFactory.java \
|
||||
java/net/URL.java \
|
||||
java/net/URLConnection.java \
|
||||
java/net/URLDecoder.java \
|
||||
java/net/URLEncoder.java \
|
||||
java/net/URLStreamHandler.java \
|
||||
java/net/URLStreamHandlerFactory.java \
|
||||
java/net/UnknownHostException.java \
|
||||
|
@ -691,7 +693,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
|
|||
.deps/java/net/ServerSocket.P .deps/java/net/Socket.P \
|
||||
.deps/java/net/SocketException.P .deps/java/net/SocketImpl.P \
|
||||
.deps/java/net/SocketImplFactory.P .deps/java/net/URL.P \
|
||||
.deps/java/net/URLConnection.P .deps/java/net/URLStreamHandler.P \
|
||||
.deps/java/net/URLConnection.P .deps/java/net/URLDecoder.P \
|
||||
.deps/java/net/URLEncoder.P .deps/java/net/URLStreamHandler.P \
|
||||
.deps/java/net/URLStreamHandlerFactory.P \
|
||||
.deps/java/net/UnknownHostException.P \
|
||||
.deps/java/net/UnknownServiceException.P \
|
||||
|
|
|
@ -96,7 +96,7 @@ public class ServerSocket
|
|||
return impl.toString();
|
||||
}
|
||||
|
||||
public static void setSocketImplFactory (SocketImplFactory fac)
|
||||
public static void setSocketFactory (SocketImplFactory fac)
|
||||
throws IOException
|
||||
{
|
||||
factory = fac;
|
||||
|
|
|
@ -156,7 +156,7 @@ public class Socket
|
|||
throw new InternalError("Socket.setSoLinger not implemented");
|
||||
}
|
||||
|
||||
public boolean getSoLinger() throws SocketException
|
||||
public int getSoLinger() throws SocketException
|
||||
{
|
||||
throw new InternalError("Socket.getSoLinger not implemented");
|
||||
}
|
||||
|
|
48
libjava/java/net/URLDecoder.java
Normal file
48
libjava/java/net/URLDecoder.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
// URLDecoder.java - Provides a method for decoding strings according to
|
||||
// application/x-www-form-urlencoded MIME type.
|
||||
|
||||
/* Copyright (C) 1999 Cygnus Solutions
|
||||
|
||||
This file is part of libgcj.
|
||||
|
||||
This software is copyrighted work licensed under the terms of the
|
||||
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
||||
details. */
|
||||
|
||||
package java.net;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* @author Warren Levy <warrenl@cygnus.com>
|
||||
* @date April 22, 1999.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Written using on-line Java Platform 1.2 API Specification.
|
||||
* Status: Believed complete and correct.
|
||||
*/
|
||||
|
||||
// JDK1.2
|
||||
public class URLDecoder
|
||||
{
|
||||
// This method, per the JCL, is conservative in that it encodes
|
||||
// some "allowable" characters as % triplets.
|
||||
public static String decode(String s) throws Exception
|
||||
{
|
||||
String str = s.replace('+', ' ');
|
||||
String result = "";
|
||||
int i;
|
||||
int start = 0;
|
||||
while ((i = str.indexOf('%', start)) >= 0)
|
||||
{
|
||||
result = result + str.substring(start, i) +
|
||||
(char) Integer.parseInt(str.substring(i + 1, i + 3), 16);
|
||||
start = i + 3;
|
||||
}
|
||||
|
||||
if (start < str.length())
|
||||
result = result + str.substring(start);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
71
libjava/java/net/URLEncoder.java
Normal file
71
libjava/java/net/URLEncoder.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
// URLEncoder.java - Provides a method for encoding strings according to
|
||||
// application/x-www-form-urlencoded MIME type.
|
||||
|
||||
/* Copyright (C) 1999 Cygnus Solutions
|
||||
|
||||
This file is part of libgcj.
|
||||
|
||||
This software is copyrighted work licensed under the terms of the
|
||||
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
||||
details. */
|
||||
|
||||
package java.net;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* @author Warren Levy <warrenl@cygnus.com>
|
||||
* @date April 22, 1999.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Written using on-line Java Platform 1.2 API Specification, as well
|
||||
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
|
||||
* Status: Believed complete and correct.
|
||||
*/
|
||||
|
||||
public class URLEncoder
|
||||
{
|
||||
// This method, per the JCL, is conservative in that it encodes
|
||||
// some "allowable" characters as % triplets.
|
||||
public static String encode(String s)
|
||||
{
|
||||
// Get the bytes in ISO-Latin-1 (i.e. 8859_1) per the JCL.
|
||||
// Even though it is the default in most cases, it's specified here
|
||||
// just in case System.getProperty("file.encoding") is not "8859_1".
|
||||
String result = "";
|
||||
try
|
||||
{
|
||||
byte[] buf = s.getBytes("8859_1");
|
||||
int start = 0;
|
||||
for (int i = 0; i < buf.length; i++)
|
||||
// For efficiency, check the byte in order of most likely
|
||||
// possibility so as to minimize the number of comparisons.
|
||||
// Hence, exclude all the alphanumeric & allowed special chars first.
|
||||
if ((buf[i] >= 'a' && buf[i] <= 'z') ||
|
||||
(buf[i] >= 'A' && buf[i] <= 'Z') ||
|
||||
(buf[i] >= '0' && buf[i] <= '9') ||
|
||||
buf[i] == '-' || buf[i] == '_' || buf[i] == '.' || buf[i] == '*')
|
||||
; // This is the most likely case so exclude first for efficiency.
|
||||
else if (buf[i] == ' ')
|
||||
buf[i] = (byte) '+'; // Replace space char with plus symbol.
|
||||
else
|
||||
{
|
||||
result = result + new String(buf, start, i - start, "8859_1") +
|
||||
"%" + Integer.toHexString(((int) buf[i]) & 0xFF);
|
||||
start = i + 1;
|
||||
}
|
||||
|
||||
// Append remainder of allowable chars from the string, if any.
|
||||
if (start < buf.length)
|
||||
result = result +
|
||||
new String(buf, start, buf.length - start, "8859_1");
|
||||
}
|
||||
catch (UnsupportedEncodingException ex)
|
||||
{
|
||||
// This should never happen as "8859_1" is the default encoding.
|
||||
return s;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -96,10 +96,14 @@ libgcj_basedir = @libgcj_basedir@
|
|||
AUTOMAKE_OPTIONS = foreign dejagnu no-installinfo
|
||||
|
||||
# Setup the testing framework, if you have one
|
||||
EXPECT = `if [ -f $(top_builddir)/../expect/expect ] ; then echo $(top_builddir)/../expect/expect ; else echo expect ; fi`
|
||||
EXPECT = `if [ -f $(top_builddir)/../expect/expect ] ; then \
|
||||
echo $(top_builddir)/../expect/expect ; \
|
||||
else echo expect ; fi`
|
||||
|
||||
|
||||
RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then echo $(top_srcdir)/../dejagnu/runtest ; else echo runtest; fi`
|
||||
RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
|
||||
echo $(top_srcdir)/../dejagnu/runtest ; \
|
||||
else echo runtest; fi`
|
||||
|
||||
|
||||
RUNTESTFLAGS = @AM_RUNTESTFLAGS@
|
||||
|
|
Loading…
Add table
Reference in a new issue