Commit 1b84b2039700a35af298144fb2ec02c2d3a68e67

Authored by bernard
0 parents

Initial import of iplocator-api project.

  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4 + <modelVersion>4.0.0</modelVersion>
  5 +
  6 + <groupId>pl.labno.bernard.geobytes</groupId>
  7 + <artifactId>iplocator-api</artifactId>
  8 + <version>1.0</version>
  9 +
  10 + <dependencies>
  11 + <dependency>
  12 + <groupId>junit</groupId>
  13 + <artifactId>junit</artifactId>
  14 + <version>4.5</version>
  15 + <scope>test</scope>
  16 + </dependency>
  17 + <dependency>
  18 + <groupId>net.sourceforge.yarfraw</groupId>
  19 + <artifactId>yarfraw</artifactId>
  20 + <version>0.92</version>
  21 + </dependency>
  22 + <dependency>
  23 + <groupId>commons-codec</groupId>
  24 + <artifactId>commons-codec</artifactId>
  25 + <version>1.4</version>
  26 + </dependency>
  27 + <dependency>
  28 + <groupId>commons-logging</groupId>
  29 + <artifactId>commons-logging-api</artifactId>
  30 + <version>1.1</version>
  31 + </dependency>
  32 + <dependency>
  33 + <groupId>javax.xml.bind</groupId>
  34 + <artifactId>jaxb-api</artifactId>
  35 + <version>2.1</version>
  36 + </dependency>
  37 + <dependency>
  38 + <groupId>com.sun.xml.bind</groupId>
  39 + <artifactId>jaxb-impl</artifactId>
  40 + <version>2.1</version>
  41 + <scope>test</scope>
  42 + </dependency>
  43 + </dependencies>
  44 +
  45 + <profiles>
  46 + <profile>
  47 + <id>generate-jaxb-artifacts</id>
  48 + <build>
  49 + <plugins>
  50 + <plugin>
  51 + <groupId>org.codehaus.mojo</groupId>
  52 + <artifactId>jaxb2-maven-plugin</artifactId>
  53 + <executions>
  54 + <execution>
  55 + <goals>
  56 + <goal>xjc</goal>
  57 + </goals>
  58 + </execution>
  59 + </executions>
  60 + <configuration>
  61 + <packageName>pl.labno.bernard.geobytes.iplocator.rest.generated</packageName>
  62 + <outputDirectory>${build.sourceDirectory}</outputDirectory>
  63 + <clearOutputDir>false</clearOutputDir>
  64 + <extension>false</extension>
  65 + </configuration>
  66 + </plugin>
  67 + </plugins>
  68 + </build>
  69 + </profile>
  70 + </profiles>
  71 +
  72 +
  73 + <build>
  74 + <plugins>
  75 + <plugin>
  76 + <groupId>org.apache.maven.plugins</groupId>
  77 + <artifactId>maven-surefire-plugin</artifactId>
  78 + <configuration>
  79 + <systemProperties>
  80 + <property>
  81 + <name>testOutputDirectory</name>
  82 + <value>${build.testOutputDirectory}</value>
  83 + </property>
  84 + </systemProperties>
  85 + </configuration>
  86 + </plugin>
  87 + <plugin>
  88 + <groupId>org.apache.maven.plugins</groupId>
  89 + <artifactId>maven-compiler-plugin</artifactId>
  90 + <configuration>
  91 + <source>1.5</source>
  92 + <target>1.5</target>
  93 + <encoding>${project.build.sourceEncoding}</encoding>
  94 + </configuration>
  95 + </plugin>
  96 + <plugin>
  97 + <groupId>org.apache.maven.plugins</groupId>
  98 + <artifactId>maven-source-plugin</artifactId>
  99 + <version>2.1.1</version>
  100 + <executions>
  101 + <execution>
  102 + <goals>
  103 + <goal>jar</goal>
  104 + </goals>
  105 + </execution>
  106 + </executions>
  107 + </plugin>
  108 + <plugin>
  109 + <groupId>org.apache.maven.plugins</groupId>
  110 + <artifactId>maven-resources-plugin</artifactId>
  111 + <version>2.2</version>
  112 + <configuration>
  113 + <encoding>${project.build.sourceEncoding}</encoding>
  114 + </configuration>
  115 + </plugin>
  116 +
  117 + </plugins>
  118 + </build>
  119 + <properties>
  120 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  121 + </properties>
  122 + <distributionManagement>
  123 + <repository>
  124 + <id>bernard.labno.pl</id>
  125 + <name>MyCo Internal Repository</name>
  126 + <url>http://bernard.labno.pl/artifactory/libs-release-local</url>
  127 + </repository>
  128 + </distributionManagement>
  129 +
  130 +</project><!--<?xml version="1.0" encoding="ISO-8859-1" ?>--><!--<info>--><!--<IP>87.207.25.131</IP>--><!--<countryid>197</countryid>--><!--<country>Poland</country>--><!--<fips>PL</fips>--><!--<iso2>PL</iso2>--><!--<iso3>POL</iso3>--><!--<ison>616</ison>--><!--<internet>PL</internet>-->
  131 +
  132 + <!--<comment></comment>--><!--<regionid>3275</regionid>--><!--<region>Kujawsko-Pomorskie</region>--><!--<code>KP</code>--><!--<adm>PL73</adm>--><!--<cityid>12699</cityid>--><!--<city>Bydgoszcz</city>--><!--<latitude>53.1500</latitude>--><!--<longitude>18.0000</longitude>-->
  133 +
  134 + <!--<timezone>+01:00</timezone>--><!--<dmaid></dmaid>--><!--<dma></dma>--><!--<market></market>--><!--<certainty>90</certainty>--><!--<locationcode>PLKPBYDG</locationcode>--><!--<ipaddress>87.207.25.131</ipaddress>--><!--</info>-->
  135 +
  136 +
\ No newline at end of file
... ...
  1 +package pl.labno.bernard.geobytes.iplocator;
  2 +
  3 +import pl.labno.bernard.geobytes.iplocator.rest.InfoUnmarshaller;
  4 +import pl.labno.bernard.geobytes.iplocator.rest.generated.IpInfo;
  5 +import yarfraw.core.datamodel.YarfrawException;
  6 +
  7 +import javax.xml.bind.JAXBException;
  8 +import java.io.IOException;
  9 +import java.net.InetAddress;
  10 +
  11 +public class Service {
  12 + private String serviceURL = "http://www.geobytes.com/IpLocator.htm?GetLocation&template=xml.txt&IpAddress=";
  13 +
  14 + public String getServiceURL() {
  15 + return serviceURL;
  16 + }
  17 +
  18 + public void setServiceURL(String serviceURL) {
  19 + this.serviceURL = serviceURL;
  20 + }
  21 +
  22 + public IpInfo getInfo(InetAddress address) throws IOException, YarfrawException, JAXBException {
  23 + return InfoUnmarshaller.unmarshal(serviceURL + address.getHostAddress());
  24 + }
  25 +
  26 +}
... ...
  1 +package pl.labno.bernard.geobytes.iplocator.rest;
  2 +
  3 +import org.apache.commons.io.IOUtils;
  4 +import org.apache.commons.logging.Log;
  5 +import org.apache.commons.logging.LogFactory;
  6 +import pl.labno.bernard.geobytes.iplocator.rest.generated.IpInfo;
  7 +
  8 +import javax.xml.bind.JAXBContext;
  9 +import javax.xml.bind.JAXBException;
  10 +import java.io.IOException;
  11 +import java.io.InputStream;
  12 +import java.io.InputStreamReader;
  13 +import java.io.Reader;
  14 +import java.io.StringReader;
  15 +import java.net.URL;
  16 +
  17 +public class InfoUnmarshaller {
  18 +
  19 + private static final Log LOG = LogFactory.getLog(InfoUnmarshaller.class);
  20 +
  21 + public static IpInfo unmarshal(String url) throws JAXBException, IOException {
  22 + return unmarshal(new URL(url).openStream());
  23 + }
  24 +
  25 + public static IpInfo unmarshal(InputStream stream) throws JAXBException, IOException {
  26 + return unmarshal(new InputStreamReader(stream));
  27 + }
  28 +
  29 + public static IpInfo unmarshal(Reader reader) throws JAXBException, IOException {
  30 + String content = IOUtils.toString(reader);
  31 + try {
  32 + JAXBContext jaxbContext = JAXBContext.newInstance(IpInfo.class.getPackage().getName());
  33 + return (IpInfo) jaxbContext.createUnmarshaller().unmarshal(new StringReader(content));
  34 + } catch (JAXBException e) {
  35 + LOG.error("Cannot unmarshal input stream.\n" + content, e);
  36 + throw e;
  37 + }
  38 + }
  39 +
  40 +}
... ...
  1 +//
  2 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
  3 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
  4 +// Any modifications to this file will be lost upon recompilation of the source schema.
  5 +// Generated on: 2011.05.17 at 03:13:16 PM GMT
  6 +//
  7 +
  8 +
  9 +package pl.labno.bernard.geobytes.iplocator.rest.generated;
  10 +
  11 +import javax.xml.bind.annotation.XmlAccessType;
  12 +import javax.xml.bind.annotation.XmlAccessorType;
  13 +import javax.xml.bind.annotation.XmlElement;
  14 +import javax.xml.bind.annotation.XmlRootElement;
  15 +import javax.xml.bind.annotation.XmlType;
  16 +
  17 +
  18 +/**
  19 + * <p>Java class for info element declaration.
  20 + *
  21 + * <p>The following schema fragment specifies the expected content contained within this class.
  22 + *
  23 + * <pre>
  24 + * &lt;element name="info">
  25 + * &lt;complexType>
  26 + * &lt;complexContent>
  27 + * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
  28 + * &lt;sequence>
  29 + * &lt;element name="IP" type="{http://www.w3.org/2001/XMLSchema}string"/>
  30 + * &lt;element name="countryid" type="{http://www.w3.org/2001/XMLSchema}short"/>
  31 + * &lt;element name="country" type="{http://www.w3.org/2001/XMLSchema}string"/>
  32 + * &lt;element name="fips" type="{http://www.w3.org/2001/XMLSchema}string"/>
  33 + * &lt;element name="iso2" type="{http://www.w3.org/2001/XMLSchema}string"/>
  34 + * &lt;element name="iso3" type="{http://www.w3.org/2001/XMLSchema}string"/>
  35 + * &lt;element name="ison" type="{http://www.w3.org/2001/XMLSchema}short"/>
  36 + * &lt;element name="internet" type="{http://www.w3.org/2001/XMLSchema}string"/>
  37 + * &lt;element name="comment" type="{http://www.w3.org/2001/XMLSchema}string"/>
  38 + * &lt;element name="regionid" type="{http://www.w3.org/2001/XMLSchema}short"/>
  39 + * &lt;element name="region" type="{http://www.w3.org/2001/XMLSchema}string"/>
  40 + * &lt;element name="code" type="{http://www.w3.org/2001/XMLSchema}string"/>
  41 + * &lt;element name="adm" type="{http://www.w3.org/2001/XMLSchema}string"/>
  42 + * &lt;element name="cityid" type="{http://www.w3.org/2001/XMLSchema}short"/>
  43 + * &lt;element name="city" type="{http://www.w3.org/2001/XMLSchema}string"/>
  44 + * &lt;element name="latitude" type="{http://www.w3.org/2001/XMLSchema}float"/>
  45 + * &lt;element name="longitude" type="{http://www.w3.org/2001/XMLSchema}float"/>
  46 + * &lt;element name="timezone" type="{http://www.w3.org/2001/XMLSchema}string"/>
  47 + * &lt;element name="dmaid" type="{http://www.w3.org/2001/XMLSchema}string"/>
  48 + * &lt;element name="dma" type="{http://www.w3.org/2001/XMLSchema}string"/>
  49 + * &lt;element name="market" type="{http://www.w3.org/2001/XMLSchema}string"/>
  50 + * &lt;element name="certainty" type="{http://www.w3.org/2001/XMLSchema}byte"/>
  51 + * &lt;element name="locationcode" type="{http://www.w3.org/2001/XMLSchema}string"/>
  52 + * &lt;element name="ipaddress" type="{http://www.w3.org/2001/XMLSchema}string"/>
  53 + * &lt;/sequence>
  54 + * &lt;/restriction>
  55 + * &lt;/complexContent>
  56 + * &lt;/complexType>
  57 + * &lt;/element>
  58 + * </pre>
  59 + *
  60 + *
  61 + */
  62 +@XmlAccessorType(XmlAccessType.FIELD)
  63 +@XmlType(name = "", propOrder = {
  64 + "ip",
  65 + "countryid",
  66 + "country",
  67 + "fips",
  68 + "iso2",
  69 + "iso3",
  70 + "ison",
  71 + "internet",
  72 + "comment",
  73 + "regionid",
  74 + "region",
  75 + "code",
  76 + "adm",
  77 + "cityid",
  78 + "city",
  79 + "latitude",
  80 + "longitude",
  81 + "timezone",
  82 + "dmaid",
  83 + "dma",
  84 + "market",
  85 + "certainty",
  86 + "locationcode",
  87 + "ipaddress"
  88 +})
  89 +@XmlRootElement(name = "info")
  90 +public class IpInfo {
  91 +
  92 + @XmlElement(name = "IP", required = true)
  93 + protected String ip;
  94 + protected short countryid;
  95 + @XmlElement(required = true)
  96 + protected String country;
  97 + @XmlElement(required = true)
  98 + protected String fips;
  99 + @XmlElement(required = true)
  100 + protected String iso2;
  101 + @XmlElement(required = true)
  102 + protected String iso3;
  103 + protected short ison;
  104 + @XmlElement(required = true)
  105 + protected String internet;
  106 + @XmlElement(required = true)
  107 + protected String comment;
  108 + protected short regionid;
  109 + @XmlElement(required = true)
  110 + protected String region;
  111 + @XmlElement(required = true)
  112 + protected String code;
  113 + @XmlElement(required = true)
  114 + protected String adm;
  115 + protected short cityid;
  116 + @XmlElement(required = true)
  117 + protected String city;
  118 + protected float latitude;
  119 + protected float longitude;
  120 + @XmlElement(required = true)
  121 + protected String timezone;
  122 + @XmlElement(required = true)
  123 + protected String dmaid;
  124 + @XmlElement(required = true)
  125 + protected String dma;
  126 + @XmlElement(required = true)
  127 + protected String market;
  128 + protected byte certainty;
  129 + @XmlElement(required = true)
  130 + protected String locationcode;
  131 + @XmlElement(required = true)
  132 + protected String ipaddress;
  133 +
  134 + /**
  135 + * Gets the value of the ip property.
  136 + *
  137 + * @return
  138 + * possible object is
  139 + * {@link String }
  140 + *
  141 + */
  142 + public String getIP() {
  143 + return ip;
  144 + }
  145 +
  146 + /**
  147 + * Sets the value of the ip property.
  148 + *
  149 + * @param value
  150 + * allowed object is
  151 + * {@link String }
  152 + *
  153 + */
  154 + public void setIP(String value) {
  155 + this.ip = value;
  156 + }
  157 +
  158 + /**
  159 + * Gets the value of the countryid property.
  160 + *
  161 + */
  162 + public short getCountryid() {
  163 + return countryid;
  164 + }
  165 +
  166 + /**
  167 + * Sets the value of the countryid property.
  168 + *
  169 + */
  170 + public void setCountryid(short value) {
  171 + this.countryid = value;
  172 + }
  173 +
  174 + /**
  175 + * Gets the value of the country property.
  176 + *
  177 + * @return
  178 + * possible object is
  179 + * {@link String }
  180 + *
  181 + */
  182 + public String getCountry() {
  183 + return country;
  184 + }
  185 +
  186 + /**
  187 + * Sets the value of the country property.
  188 + *
  189 + * @param value
  190 + * allowed object is
  191 + * {@link String }
  192 + *
  193 + */
  194 + public void setCountry(String value) {
  195 + this.country = value;
  196 + }
  197 +
  198 + /**
  199 + * Gets the value of the fips property.
  200 + *
  201 + * @return
  202 + * possible object is
  203 + * {@link String }
  204 + *
  205 + */
  206 + public String getFips() {
  207 + return fips;
  208 + }
  209 +
  210 + /**
  211 + * Sets the value of the fips property.
  212 + *
  213 + * @param value
  214 + * allowed object is
  215 + * {@link String }
  216 + *
  217 + */
  218 + public void setFips(String value) {
  219 + this.fips = value;
  220 + }
  221 +
  222 + /**
  223 + * Gets the value of the iso2 property.
  224 + *
  225 + * @return
  226 + * possible object is
  227 + * {@link String }
  228 + *
  229 + */
  230 + public String getIso2() {
  231 + return iso2;
  232 + }
  233 +
  234 + /**
  235 + * Sets the value of the iso2 property.
  236 + *
  237 + * @param value
  238 + * allowed object is
  239 + * {@link String }
  240 + *
  241 + */
  242 + public void setIso2(String value) {
  243 + this.iso2 = value;
  244 + }
  245 +
  246 + /**
  247 + * Gets the value of the iso3 property.
  248 + *
  249 + * @return
  250 + * possible object is
  251 + * {@link String }
  252 + *
  253 + */
  254 + public String getIso3() {
  255 + return iso3;
  256 + }
  257 +
  258 + /**
  259 + * Sets the value of the iso3 property.
  260 + *
  261 + * @param value
  262 + * allowed object is
  263 + * {@link String }
  264 + *
  265 + */
  266 + public void setIso3(String value) {
  267 + this.iso3 = value;
  268 + }
  269 +
  270 + /**
  271 + * Gets the value of the ison property.
  272 + *
  273 + */
  274 + public short getIson() {
  275 + return ison;
  276 + }
  277 +
  278 + /**
  279 + * Sets the value of the ison property.
  280 + *
  281 + */
  282 + public void setIson(short value) {
  283 + this.ison = value;
  284 + }
  285 +
  286 + /**
  287 + * Gets the value of the internet property.
  288 + *
  289 + * @return
  290 + * possible object is
  291 + * {@link String }
  292 + *
  293 + */
  294 + public String getInternet() {
  295 + return internet;
  296 + }
  297 +
  298 + /**
  299 + * Sets the value of the internet property.
  300 + *
  301 + * @param value
  302 + * allowed object is
  303 + * {@link String }
  304 + *
  305 + */
  306 + public void setInternet(String value) {
  307 + this.internet = value;
  308 + }
  309 +
  310 + /**
  311 + * Gets the value of the comment property.
  312 + *
  313 + * @return
  314 + * possible object is
  315 + * {@link String }
  316 + *
  317 + */
  318 + public String getComment() {
  319 + return comment;
  320 + }
  321 +
  322 + /**
  323 + * Sets the value of the comment property.
  324 + *
  325 + * @param value
  326 + * allowed object is
  327 + * {@link String }
  328 + *
  329 + */
  330 + public void setComment(String value) {
  331 + this.comment = value;
  332 + }
  333 +
  334 + /**
  335 + * Gets the value of the regionid property.
  336 + *
  337 + */
  338 + public short getRegionid() {
  339 + return regionid;
  340 + }
  341 +
  342 + /**
  343 + * Sets the value of the regionid property.
  344 + *
  345 + */
  346 + public void setRegionid(short value) {
  347 + this.regionid = value;
  348 + }
  349 +
  350 + /**
  351 + * Gets the value of the region property.
  352 + *
  353 + * @return
  354 + * possible object is
  355 + * {@link String }
  356 + *
  357 + */
  358 + public String getRegion() {
  359 + return region;
  360 + }
  361 +
  362 + /**
  363 + * Sets the value of the region property.
  364 + *
  365 + * @param value
  366 + * allowed object is
  367 + * {@link String }
  368 + *
  369 + */
  370 + public void setRegion(String value) {
  371 + this.region = value;
  372 + }
  373 +
  374 + /**
  375 + * Gets the value of the code property.
  376 + *
  377 + * @return
  378 + * possible object is
  379 + * {@link String }
  380 + *
  381 + */
  382 + public String getCode() {
  383 + return code;
  384 + }
  385 +
  386 + /**
  387 + * Sets the value of the code property.
  388 + *
  389 + * @param value
  390 + * allowed object is
  391 + * {@link String }
  392 + *
  393 + */
  394 + public void setCode(String value) {
  395 + this.code = value;
  396 + }
  397 +
  398 + /**
  399 + * Gets the value of the adm property.
  400 + *
  401 + * @return
  402 + * possible object is
  403 + * {@link String }
  404 + *
  405 + */
  406 + public String getAdm() {
  407 + return adm;
  408 + }
  409 +
  410 + /**
  411 + * Sets the value of the adm property.
  412 + *
  413 + * @param value
  414 + * allowed object is
  415 + * {@link String }
  416 + *
  417 + */
  418 + public void setAdm(String value) {
  419 + this.adm = value;
  420 + }
  421 +
  422 + /**
  423 + * Gets the value of the cityid property.
  424 + *
  425 + */
  426 + public short getCityid() {
  427 + return cityid;
  428 + }
  429 +
  430 + /**
  431 + * Sets the value of the cityid property.
  432 + *
  433 + */
  434 + public void setCityid(short value) {
  435 + this.cityid = value;
  436 + }
  437 +
  438 + /**
  439 + * Gets the value of the city property.
  440 + *
  441 + * @return
  442 + * possible object is
  443 + * {@link String }
  444 + *
  445 + */
  446 + public String getCity() {
  447 + return city;
  448 + }
  449 +
  450 + /**
  451 + * Sets the value of the city property.
  452 + *
  453 + * @param value
  454 + * allowed object is
  455 + * {@link String }
  456 + *
  457 + */
  458 + public void setCity(String value) {
  459 + this.city = value;
  460 + }
  461 +
  462 + /**
  463 + * Gets the value of the latitude property.
  464 + *
  465 + */
  466 + public float getLatitude() {
  467 + return latitude;
  468 + }
  469 +
  470 + /**
  471 + * Sets the value of the latitude property.
  472 + *
  473 + */
  474 + public void setLatitude(float value) {
  475 + this.latitude = value;
  476 + }
  477 +
  478 + /**
  479 + * Gets the value of the longitude property.
  480 + *
  481 + */
  482 + public float getLongitude() {
  483 + return longitude;
  484 + }
  485 +
  486 + /**
  487 + * Sets the value of the longitude property.
  488 + *
  489 + */
  490 + public void setLongitude(float value) {
  491 + this.longitude = value;
  492 + }
  493 +
  494 + /**
  495 + * Gets the value of the timezone property.
  496 + *
  497 + * @return
  498 + * possible object is
  499 + * {@link String }
  500 + *
  501 + */
  502 + public String getTimezone() {
  503 + return timezone;
  504 + }
  505 +
  506 + /**
  507 + * Sets the value of the timezone property.
  508 + *
  509 + * @param value
  510 + * allowed object is
  511 + * {@link String }
  512 + *
  513 + */
  514 + public void setTimezone(String value) {
  515 + this.timezone = value;
  516 + }
  517 +
  518 + /**
  519 + * Gets the value of the dmaid property.
  520 + *
  521 + * @return
  522 + * possible object is
  523 + * {@link String }
  524 + *
  525 + */
  526 + public String getDmaid() {
  527 + return dmaid;
  528 + }
  529 +
  530 + /**
  531 + * Sets the value of the dmaid property.
  532 + *
  533 + * @param value
  534 + * allowed object is
  535 + * {@link String }
  536 + *
  537 + */
  538 + public void setDmaid(String value) {
  539 + this.dmaid = value;
  540 + }
  541 +
  542 + /**
  543 + * Gets the value of the dma property.
  544 + *
  545 + * @return
  546 + * possible object is
  547 + * {@link String }
  548 + *
  549 + */
  550 + public String getDma() {
  551 + return dma;
  552 + }
  553 +
  554 + /**
  555 + * Sets the value of the dma property.
  556 + *
  557 + * @param value
  558 + * allowed object is
  559 + * {@link String }
  560 + *
  561 + */
  562 + public void setDma(String value) {
  563 + this.dma = value;
  564 + }
  565 +
  566 + /**
  567 + * Gets the value of the market property.
  568 + *
  569 + * @return
  570 + * possible object is
  571 + * {@link String }
  572 + *
  573 + */
  574 + public String getMarket() {
  575 + return market;
  576 + }
  577 +
  578 + /**
  579 + * Sets the value of the market property.
  580 + *
  581 + * @param value
  582 + * allowed object is
  583 + * {@link String }
  584 + *
  585 + */
  586 + public void setMarket(String value) {
  587 + this.market = value;
  588 + }
  589 +
  590 + /**
  591 + * Gets the value of the certainty property.
  592 + *
  593 + */
  594 + public byte getCertainty() {
  595 + return certainty;
  596 + }
  597 +
  598 + /**
  599 + * Sets the value of the certainty property.
  600 + *
  601 + */
  602 + public void setCertainty(byte value) {
  603 + this.certainty = value;
  604 + }
  605 +
  606 + /**
  607 + * Gets the value of the locationcode property.
  608 + *
  609 + * @return
  610 + * possible object is
  611 + * {@link String }
  612 + *
  613 + */
  614 + public String getLocationcode() {
  615 + return locationcode;
  616 + }
  617 +
  618 + /**
  619 + * Sets the value of the locationcode property.
  620 + *
  621 + * @param value
  622 + * allowed object is
  623 + * {@link String }
  624 + *
  625 + */
  626 + public void setLocationcode(String value) {
  627 + this.locationcode = value;
  628 + }
  629 +
  630 + /**
  631 + * Gets the value of the ipaddress property.
  632 + *
  633 + * @return
  634 + * possible object is
  635 + * {@link String }
  636 + *
  637 + */
  638 + public String getIpaddress() {
  639 + return ipaddress;
  640 + }
  641 +
  642 + /**
  643 + * Sets the value of the ipaddress property.
  644 + *
  645 + * @param value
  646 + * allowed object is
  647 + * {@link String }
  648 + *
  649 + */
  650 + public void setIpaddress(String value) {
  651 + this.ipaddress = value;
  652 + }
  653 +
  654 +}
... ...
  1 +//
  2 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
  3 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
  4 +// Any modifications to this file will be lost upon recompilation of the source schema.
  5 +// Generated on: 2011.05.17 at 03:13:16 PM GMT
  6 +//
  7 +
  8 +
  9 +package pl.labno.bernard.geobytes.iplocator.rest.generated;
  10 +
  11 +import javax.xml.bind.annotation.XmlRegistry;
  12 +
  13 +
  14 +/**
  15 + * This object contains factory methods for each
  16 + * Java content interface and Java element interface
  17 + * generated in the pl.labno.bernard.geobytes.iplocator.rest.generated package.
  18 + * <p>An ObjectFactory allows you to programatically
  19 + * construct new instances of the Java representation
  20 + * for XML content. The Java representation of XML
  21 + * content can consist of schema derived interfaces
  22 + * and classes representing the binding of schema
  23 + * type definitions, element declarations and model
  24 + * groups. Factory methods for each of these are
  25 + * provided in this class.
  26 + *
  27 + */
  28 +@XmlRegistry
  29 +public class ObjectFactory {
  30 +
  31 +
  32 + /**
  33 + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: pl.labno.bernard.geobytes.iplocator.rest.generated
  34 + *
  35 + */
  36 + public ObjectFactory() {
  37 + }
  38 +
  39 + /**
  40 + * Create an instance of {@link IpInfo }
  41 + *
  42 + */
  43 + public IpInfo createIpInfo() {
  44 + return new IpInfo();
  45 + }
  46 +
  47 +}
... ...
  1 +<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  2 + <jxb:bindings schemaLocation="../xsd/response.xsd" node="/xs:schema">
  3 +
  4 + <jxb:globalBindings localScoping="toplevel"/>
  5 +
  6 + <jxb:bindings node="//xs:element[@name='info']">
  7 +
  8 + <jxb:class name="IpInfo"/>
  9 +
  10 + </jxb:bindings>
  11 +
  12 + </jxb:bindings>
  13 +</jxb:bindings>
\ No newline at end of file
... ...
  1 +<?xml version="1.0" encoding="ISO-8859-1" ?><!--This is sample response to generate response.xsd from-->
  2 +<info>
  3 + <IP>87.207.25.131</IP>
  4 + <countryid>197</countryid>
  5 + <country>Poland</country>
  6 + <fips>PL</fips>
  7 + <iso2>PL</iso2>
  8 + <iso3>POL</iso3>
  9 + <ison>616</ison>
  10 + <internet>PL</internet>
  11 +
  12 + <comment></comment>
  13 + <regionid>3275</regionid>
  14 + <region>Kujawsko-Pomorskie</region>
  15 + <code>KP</code>
  16 + <adm>PL73</adm>
  17 + <cityid>12699</cityid>
  18 + <city>Bydgoszcz</city>
  19 + <latitude>53.1500</latitude>
  20 + <longitude>18.0000</longitude>
  21 +
  22 + <timezone>+01:00</timezone>
  23 + <dmaid></dmaid>
  24 + <dma></dma>
  25 + <market></market>
  26 + <certainty>90</certainty>
  27 + <locationcode>PLKPBYDG</locationcode>
  28 + <ipaddress>87.207.25.131</ipaddress>
  29 +</info>
  30 +
... ...
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  3 + <xs:element name="info">
  4 + <xs:complexType>
  5 + <xs:sequence>
  6 + <xs:element type="xs:string" name="IP"/>
  7 + <xs:element type="xs:short" name="countryid"/>
  8 + <xs:element type="xs:string" name="country"/>
  9 + <xs:element type="xs:string" name="fips"/>
  10 + <xs:element type="xs:string" name="iso2"/>
  11 + <xs:element type="xs:string" name="iso3"/>
  12 + <xs:element type="xs:short" name="ison"/>
  13 + <xs:element type="xs:string" name="internet"/>
  14 + <xs:element type="xs:string" name="comment"/>
  15 + <xs:element type="xs:short" name="regionid"/>
  16 + <xs:element type="xs:string" name="region"/>
  17 + <xs:element type="xs:string" name="code"/>
  18 + <xs:element type="xs:string" name="adm"/>
  19 + <xs:element type="xs:short" name="cityid"/>
  20 + <xs:element type="xs:string" name="city"/>
  21 + <xs:element type="xs:float" name="latitude"/>
  22 + <xs:element type="xs:float" name="longitude"/>
  23 + <xs:element type="xs:string" name="timezone"/>
  24 + <xs:element type="xs:string" name="dmaid"/>
  25 + <xs:element type="xs:string" name="dma"/>
  26 + <xs:element type="xs:string" name="market"/>
  27 + <xs:element type="xs:byte" name="certainty"/>
  28 + <xs:element type="xs:string" name="locationcode"/>
  29 + <xs:element type="xs:string" name="ipaddress"/>
  30 + </xs:sequence>
  31 + </xs:complexType>
  32 + </xs:element>
  33 +</xs:schema>
\ No newline at end of file
... ...
  1 +package pl.labno.bernard.geobytes.iplocator;
  2 +
  3 +import org.junit.Assert;
  4 +import org.junit.Test;
  5 +import pl.labno.bernard.geobytes.iplocator.rest.generated.IpInfo;
  6 +import yarfraw.core.datamodel.YarfrawException;
  7 +
  8 +import javax.xml.bind.JAXBException;
  9 +import java.io.IOException;
  10 +import java.net.Inet4Address;
  11 +
  12 +public class ServiceTest {
  13 +
  14 + @Test
  15 + public void testGetRecentExchangeTable() throws YarfrawException, IOException, JAXBException {
  16 + final Service service = new Service();
  17 + IpInfo info = service.getInfo(Inet4Address.getByAddress(new byte[]{87, (byte) 207, 25, (byte) 131}));
  18 + Assert.assertNotNull(info);
  19 + Assert.assertEquals(197, info.getCountryid());
  20 + info = service.getInfo(Inet4Address.getByAddress(new byte[]{(byte) 165, 69, 10, 27}));
  21 + Assert.assertNotNull(info);
  22 + Assert.assertEquals(14, info.getCountryid());
  23 + }
  24 +}
... ...
Please register or login to post a comment