mirror of
https://github.com/lionsoul2014/ip2region.git
synced 2025-12-08 19:25:22 +00:00
add data_ptr return for datablock
This commit is contained in:
parent
72ca42f54f
commit
32ad842926
@ -9,7 +9,7 @@
|
||||
<property name="jars" value="${basedir}"/>
|
||||
<property name="sources" value="${basedir}/src"/>
|
||||
<property name="classes" value="${basedir}/classes"/>
|
||||
<property name="version" value="1.0"/>
|
||||
<property name="version" value="1.2"/>
|
||||
<property name="api" value="${basedir}/doc"/>
|
||||
<mkdir dir="${classes}"/>
|
||||
<mkdir dir="${api}"/>
|
||||
|
||||
@ -3,54 +3,84 @@ package org.lionsoul.ip2region;
|
||||
/**
|
||||
* data block class
|
||||
*
|
||||
* @author chenxin<chenxin619315@gmail.com>
|
||||
* @author chenxin<chenxin619315@gmail.com>
|
||||
*/
|
||||
public class DataBlock
|
||||
{
|
||||
/**
|
||||
* city id
|
||||
*/
|
||||
private int city_id;
|
||||
|
||||
/**
|
||||
* region address
|
||||
*/
|
||||
private String region;
|
||||
|
||||
public DataBlock( int city_id, String region )
|
||||
{
|
||||
this.city_id = city_id;
|
||||
this.region = region;
|
||||
}
|
||||
/**
|
||||
* city id
|
||||
*/
|
||||
private int city_id;
|
||||
|
||||
/**
|
||||
* region address
|
||||
*/
|
||||
private String region;
|
||||
|
||||
/**
|
||||
* region ptr in the db file
|
||||
*/
|
||||
private int dataPtr;
|
||||
|
||||
/**
|
||||
* construct method
|
||||
*
|
||||
* @param city_id
|
||||
* @param region region string
|
||||
* @param ptr data ptr
|
||||
*/
|
||||
public DataBlock( int city_id, String region, int dataPtr )
|
||||
{
|
||||
this.city_id = city_id;
|
||||
this.region = region;
|
||||
this.dataPtr = dataPtr;
|
||||
}
|
||||
|
||||
public DataBlock(int city_id, String region)
|
||||
{
|
||||
this(city_id, region, 0);
|
||||
}
|
||||
|
||||
public int getCityId()
|
||||
{
|
||||
return city_id;
|
||||
}
|
||||
public int getCityId()
|
||||
{
|
||||
return city_id;
|
||||
}
|
||||
|
||||
public DataBlock setCityId(int city_id)
|
||||
{
|
||||
this.city_id = city_id;
|
||||
return this;
|
||||
}
|
||||
public DataBlock setCityId(int city_id)
|
||||
{
|
||||
this.city_id = city_id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRegion()
|
||||
{
|
||||
return region;
|
||||
}
|
||||
public String getRegion()
|
||||
{
|
||||
return region;
|
||||
}
|
||||
|
||||
public DataBlock setRegion(String region)
|
||||
{
|
||||
this.region = region;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getDataPtr()
|
||||
{
|
||||
return dataPtr;
|
||||
}
|
||||
|
||||
public DataBlock setDataPtr(int dataPtr)
|
||||
{
|
||||
this.dataPtr = dataPtr;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append(city_id).append('|').append(region).append('|').append(dataPtr);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public DataBlock setRegion(String region)
|
||||
{
|
||||
this.region = region;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append(city_id).append('|').append(region);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ public class DbSearcher
|
||||
int city_id = (int)Util.getIntLong(data, 0);
|
||||
String region = new String(data, 4, data.length - 4, "UTF-8");
|
||||
|
||||
return new DataBlock(city_id, region);
|
||||
return new DataBlock(city_id, region, dataPtr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -204,7 +204,7 @@ public class DbSearcher
|
||||
int city_id = (int)Util.getIntLong(data, 0);
|
||||
String region = new String(data, 4, data.length - 4, "UTF-8");
|
||||
|
||||
return new DataBlock(city_id, region);
|
||||
return new DataBlock(city_id, region, dataPtr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -274,7 +274,7 @@ public class DbSearcher
|
||||
int city_id = (int)Util.getIntLong(data, 0);
|
||||
String region = new String(data, 4, data.length - 4, "UTF-8");
|
||||
|
||||
return new DataBlock(city_id, region);
|
||||
return new DataBlock(city_id, region, dataPtr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user