Inet6Address.java (getHostAddress): Fix textual representation of IPv6 address with embedded zeroes to conform to...

2004-11-18  Mattias Rehnberg  <Mattias.Rehnberg@home.se>

	* java/net/Inet6Address.java (getHostAddress): Fix textual
	representation of IPv6 address with embedded zeroes
	to conform to RFC 2373.

From-SVN: r90874
This commit is contained in:
Mattias Rehnberg 2004-11-18 17:11:40 +01:00 committed by Michael Koch
parent 3d8532aa2a
commit 4fdb8244ae
2 changed files with 8 additions and 9 deletions

View File

@ -1,3 +1,9 @@
2004-11-18 Mattias Rehnberg <Mattias.Rehnberg@home.se>
* java/net/Inet6Address.java (getHostAddress): Fix textual
representation of IPv6 address with embedded zeroes
to conform to RFC 2373.
2004-11-18 Jeroen Frijters <address@bogus.example.com>
* java/lang/StackTraceElement.java: Made final.

View File

@ -207,18 +207,11 @@ public final class Inet6Address extends InetAddress
for (int i = 0; i < 16; i += 2)
{
int x = ((ipaddress[i] & 0xFF) << 8) | (ipaddress[i + 1] & 0xFF);
boolean empty = sbuf.length() == 0;
if (empty)
{
if (i > 0)
sbuf.append("::");
}
else
if (i > 0)
sbuf.append(':');
if (x != 0 || i >= 14)
sbuf.append(Integer.toHexString(x));
sbuf.append(Integer.toHexString(x));
}
return sbuf.toString();