OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [java/] [net/] [Inet4Address.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* Inet4Address.java --
2
   Copyright (C) 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package java.net;
40
 
41
import java.io.ObjectStreamException;
42
 
43
/*
44
 * Written using on-line Java Platform 1.4 API Specification and
45
 * RFC 1884 (http://www.ietf.org/rfc/rfc1884.txt),
46
 * RFC 1918 (http://www.ietf.org/rfc/rfc1918.txt),
47
 * RFC 2365 (http://www.ietf.org/rfc/rfc2365.txt)
48
 *
49
 * @author Michael Koch
50
 * @status Believed complete and correct.
51
 */
52
public final class Inet4Address extends InetAddress
53
{
54
  /**
55
   * For compatability with Sun's JDK 1.4.2 rev. 5
56
   */
57
  static final long serialVersionUID = 3286316764910316507L;
58
 
59
  /**
60
   * needed for serialization
61
   */
62
  private Object writeReplace() throws ObjectStreamException
63
  {
64
    return new InetAddress(addr, hostName);
65
  }
66
 
67
  /**
68
   * Initializes this object's addr instance variable from the passed in
69
   * byte array.  Note that this constructor is protected and is called
70
   * only by static methods in this class.
71
   *
72
   * @param addr The IP number of this address as an array of bytes
73
   * @param host The hostname of this IP address.
74
   */
75
  Inet4Address(byte[] addr, String host)
76
  {
77
    super(addr, host);
78
  }
79
 
80
  /**
81
   * Checks if the address is a multicast address
82
   *
83
   * @since 1.1
84
   */
85
  public boolean isMulticastAddress()
86
  {
87
    return super.isMulticastAddress();
88
  }
89
 
90
  /**
91
   * Checks if this address is a loopback address
92
   */
93
  public boolean isLoopbackAddress()
94
  {
95
    return super.isLoopbackAddress();
96
  }
97
 
98
  /**
99
   * Checks if this address is a wildcard address
100
   *
101
   * @since 1.4
102
   */
103
  public boolean isAnyLocalAddress()
104
  {
105
    return super.isAnyLocalAddress();
106
  }
107
 
108
  /**
109
   * Checks if this address is a link local address
110
   *
111
   * @since 1.4
112
   */
113
  public boolean isLinkLocalAddress()
114
  {
115
    return super.isLinkLocalAddress();
116
  }
117
 
118
  /**
119
   * Checks if this address is a site local address
120
   *
121
   * @since 1.4
122
   */
123
  public boolean isSiteLocalAddress()
124
  {
125
    return super.isSiteLocalAddress();
126
  }
127
 
128
  /**
129
   * Checks if this multicast address has global scope
130
   *
131
   * @since 1.4
132
   */
133
  public boolean isMCGlobal()
134
  {
135
    return super.isMCGlobal();
136
  }
137
 
138
  /**
139
   * Checks if this multicast address has node scope
140
   *
141
   * @since 1.4
142
   */
143
  public boolean isMCNodeLocal()
144
  {
145
    return super.isMCNodeLocal();
146
  }
147
 
148
  /**
149
   * Checks if this multicast address has link scope
150
   *
151
   * @since 1.4
152
   */
153
  public boolean isMCLinkLocal()
154
  {
155
    return super.isMCLinkLocal();
156
  }
157
 
158
  /**
159
   * Checks if this multicast address has site scope
160
   *
161
   * @since 1.4
162
   */
163
  public boolean isMCSiteLocal()
164
  {
165
    return super.isMCSiteLocal();
166
  }
167
 
168
  /**
169
   * Checks if this multicast address has organization scope
170
   *
171
   * @since 1.4
172
   */
173
  public boolean isMCOrgLocal()
174
  {
175
    return super.isMCOrgLocal();
176
  }
177
 
178
  /**
179
   * Returns the address of the current instance
180
   */
181
  public byte[] getAddress()
182
  {
183
    return (byte[]) addr.clone();
184
  }
185
 
186
  /**
187
   * Returns the address as string
188
   *
189
   * @since 1.0.2
190
   */
191
  public String getHostAddress()
192
  {
193
    return super.getHostAddress();
194
  }
195
 
196
  /**
197
   * Computes the hashcode of the instance
198
   */
199
  public int hashCode()
200
  {
201
    int hash = 0;
202
    int len = addr.length;
203
    int i = len > 4 ? len - 4 : 0;
204
 
205
    for (; i < len; i++)
206
      hash = (hash << 8) | (addr[i] & 0xFF);
207
 
208
    return hash;
209
  }
210
 
211
  /**
212
   * Compare the current Inet4Address instance with obj
213
   *
214
   * @param obj Object to compare with
215
   */
216
  public boolean equals(Object obj)
217
  {
218
    if (! (obj instanceof InetAddress))
219
      return false;
220
 
221
    byte[] addr1 = addr;
222
    byte[] addr2 = ((InetAddress) obj).addr;
223
 
224
    if (addr1.length != addr2.length)
225
      return false;
226
 
227
    for (int i = addr1.length; --i >= 0;)
228
      if (addr1[i] != addr2[i])
229
        return false;
230
 
231
    return true;
232
  }
233
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.