|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.javainetlocator.InetAddressLocator
public class InetAddressLocator
This class discovers geographical location from IP addresses.
Copyright 2002/03 Nigel Wetters Gourlay, Paul Hastings. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or(at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
InetAddress
,
Locale
Method Summary | |
---|---|
static Locale |
getLocale(byte[] ip)
When passed a byte array representing an IP address, will return a Locale object corresponding to the country
where the address was allocated. |
static Locale |
getLocale(InetAddress address)
When passed an InetAddress object,
will return a Locale object corresponding to the country
where the address was allocated. |
static Locale |
getLocale(String host)
When passed an String containing a hostname, will
return a Locale object corresponding to the country where
the host was allocated. |
static void |
main(String[] args)
Runs testsuite, benchmarks, and then enters interactive mode, where the user can query the country of individual IP addresses or hostnames from the console. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Locale getLocale(byte[] ip) throws InetAddressLocatorException
When passed a byte array representing an IP address,
will return a Locale
object corresponding to the country
where the address was allocated.
The country of the Locale (retrieved by
Locale.getCountry()
) is set to the
international
two-letter code for the country where the
Internet address was allocated (e.g. NZ for New Zealand).
If the Internet address cannot be found within the database, the country and language of the returned Locale are set to empty Strings.
Three country values can be returned that do not exist within the international standard (ISO 3166). These are EU (for a nonspecific European address), AP (for a nonspecific Asia-Pacific address) and ** (an Internet address reserved for private use, for example on a corporate network not available from the public Internet).
The language of the returned Locale (retrieved by
Locale.getLanguage()
is set to the
international
two-letter code for the official language of the country
where the Internet address was allocated.
Where a country has more than one official language, the language is set to that which has the majority of native speakers. For example, the language for Canada is set to English (en) rather than French (fr).
Nonspecific addresses (EU and AP), private Internet addresses (**), and addresses not found within the database, all return an empty string for language.
ip
- Internet address to be located
InetAddressLocatorException
- if the database is corruptpublic static Locale getLocale(InetAddress address) throws InetAddressLocatorException
When passed an InetAddress
object,
will return a Locale
object corresponding to the country
where the address was allocated.
The country of the Locale (retrieved by
Locale.getCountry()
) is set to the
international
two-letter code for the country where the
Internet address was allocated (e.g. NZ for New Zealand).
If the Internet address cannot be found within the database, the country and language of the returned Locale are set to empty Strings.
Three country values can be returned that do not exist within the international standard (ISO 3166). These are EU (for a nonspecific European address), AP (for a nonspecific Asia-Pacific address) and ** (an Internet address reserved for private use, for example on a corporate network not available from the public Internet).
The language of the returned Locale (retrieved by
Locale.getLanguage()
is set to the
international
two-letter code for the official language of the country
where the Internet address was allocated.
Where a country has more than one official language, the language is set to that which has the majority of native speakers. For example, the language for Canada is set to English (en) rather than French (fr).
Nonspecific addresses (EU and AP), private Internet addresses (**), and addresses not found within the database, all return an empty string for language.
address
- Internet address to be located
InetAddressLocatorException
- if the database is corruptpublic static Locale getLocale(String host) throws InetAddressLocatorException
When passed an String
containing a hostname, will
return a Locale
object corresponding to the country where
the host was allocated.
The country of the Locale (retrieved by
Locale.getCountry()
) is set to the
international
two-letter code for the country where the
Internet address was allocated (e.g. NZ for New Zealand).
If the Internet address cannot be found within the database, the country and language of the returned Locale are set to empty Strings.
Three country values can be returned that do not exist within the international standard (ISO 3166). These are EU (for a nonspecific European address), AP (for a nonspecific Asia-Pacific address) and ** (an Internet address reserved for private use, for example on a corporate network not available from the public Internet).
The language of the returned Locale (retrieved by
Locale.getLanguage()
is set to the
international
two-letter code for the official language of the country
where the Internet address was allocated.
Where a country has more than one official language, the language is set to that which has the majority of native speakers. For example, the language for Canada is set to English (en) rather than French (fr).
Nonspecific addresses (EU and AP), private Internet addresses (**), and addresses not found within the database, all return an empty string for language.
host
- Internet address to be located
InetAddressLocatorException
- if the database is corruptpublic static void main(String[] args) throws InetAddressLocatorException
args
- command-line arguments currently have no effect
InetAddressLocatorException
- errors occuring during tests and benchmarks
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |