-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from tomaytotomato/2-binarise-data
2- Binarise location4j data
- Loading branch information
Showing
42 changed files
with
230 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.tomaytotomato</groupId> | ||
<artifactId>location4j</artifactId> | ||
<version>1.0.0</version> | ||
</parent> | ||
|
||
<artifactId>library</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>21</maven.compiler.source> | ||
<maven.compiler.target>21</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
</project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions
50
library/src/main/java/com/tomaytotomato/loader/DefaultCountriesDataLoaderImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.tomaytotomato.loader; | ||
|
||
import com.tomaytotomato.model.Country; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.ObjectInputStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class DefaultCountriesDataLoaderImpl implements CountriesDataLoader { | ||
|
||
private static final String DEFAULT_FILE = "location4j.bin"; | ||
private final List<Country> countries = new ArrayList<>(); | ||
|
||
/** | ||
* Loads a list of {@link Country} from the location4j.bin file. | ||
*/ | ||
public DefaultCountriesDataLoaderImpl() { | ||
var logger = Logger.getLogger(this.getClass().getName()); | ||
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(DEFAULT_FILE)) { | ||
logger.info("Attempting to load countries from " + DEFAULT_FILE); | ||
if (inputStream == null) { | ||
throw new IllegalArgumentException("File not found: " + DEFAULT_FILE); | ||
} | ||
|
||
loadLocationsFromBinary(inputStream, logger); | ||
} catch (IOException | ClassNotFoundException e) { | ||
logger.log(Level.SEVERE, "Failed to load countries file: " + e.getMessage(), e); | ||
} | ||
} | ||
|
||
private void loadLocationsFromBinary(InputStream inputStream, Logger logger) | ||
throws IOException, ClassNotFoundException { | ||
try (var objectInputStream = new ObjectInputStream(inputStream)) { | ||
// Read the list of countries from the binary file | ||
List<Country> loadedCountries = (List<Country>) objectInputStream.readObject(); | ||
this.countries.addAll(loadedCountries); | ||
logger.info("Successfully loaded countries binary file"); | ||
} catch (IOException | ClassNotFoundException e) { | ||
logger.log(Level.SEVERE, "Failed to parse countries file: " + e.getMessage(), e); | ||
} | ||
} | ||
|
||
@Override | ||
public List<Country> getCountries() { | ||
return countries; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
13 changes: 4 additions & 9 deletions
13
...in/java/com/tomaytotomato/model/City.java → ...in/java/com/tomaytotomato/model/City.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 4 additions & 9 deletions
13
...java/com/tomaytotomato/model/Country.java → ...java/com/tomaytotomato/model/Country.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 4 additions & 12 deletions
16
...n/java/com/tomaytotomato/model/State.java → ...n/java/com/tomaytotomato/model/State.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 6 additions & 5 deletions
11
...ava/com/tomaytotomato/model/TimeZone.java → ...ava/com/tomaytotomato/model/TimeZone.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
src/main/java/com/tomaytotomato/loader/DefaultCountriesDataLoaderImpl.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.