Skip to content
/ GB2260.java Public

The Java implementation for looking up Chinese administrative divisions.

License

Notifications You must be signed in to change notification settings

cn/GB2260.java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GB2260.java

The Java implementation for looking up Chinese administrative divisions.

GB/T 2260

GB/T 2260 Build Status Coverage

The latest GB/T 2260 codes. Read the GB2260 Specification.

Build

Install with maven:

$ git submodule update --init
$ mvn clean package
$ mvn install:install-file -Dfile=target/GB2260-0.1.1.jar -DgroupId=cn.gb2260 -DartifactId=GB2260 -Dversion=0.1.1 -Dpackaging=jar

Update the pom.xml file in project

<dependencies>
    ...
    <dependency>
        <groupId>cn.gb2260</groupId>
        <artifactId>GB2260</artifactId>
        <version>0.1.1</version>
    </dependency>
    ...
</dependencies>

Usage

GB2260

GB2260 gb = new GB2260(); // with default revision 2014
GB2260 gb = new GB2260(Revision.V2002); // specify the revision

Interface for GB2260.

.getDivision(code)

Get division for the given code.

Division division = gb.getDivision("110105")
// 北京市 市辖区 朝阳区

division.getName()
// 朝阳区
division.getCode()
// 110105
division.getRevision()
// 2014

division.getProvince()
// 北京市
division.getPrefecture()
// 市辖区

division.toString()
// 北京市 市辖区 朝阳区

.getProvinces()

Return a list of provinces in Division data structure.

gb.getProvinces()

.getPrefectures(code)

Return a list of prefecture level cities in Division data structure.

gb.getPrefectures("110000")

.getCounties(code)

Return a list of counties in Division data structure.

gb.getCounties("110100")

revisions

Revision contains a list of available revisions.

Revision.V2014.getCode() // return 2014

License

MIT.

About

The Java implementation for looking up Chinese administrative divisions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages