Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.gisgraphy.importer
Class ImporterHelper

    java.lang.Object
      com.gisgraphy.importer.ImporterHelper

    public class ImporterHelper

extends Object

Useful methods for importer

Author:
  David Masclet

Field Summary
`static String` | `ALLCOUTRY_FILENAME` the all country dump file name
`static FileFilter` | `alternatenamesGeonamesSplitedFileFilter`
`static FileFilter` | `countryFileFilter`
`static FileFilter` | `countryGeonamesSplitedFileFilter`
`static FileFilter` | `countryOpenstreetMapSplitedFileFilter`
`static String` | `EXCLUDED_README_FILENAME` The readme filename (it must not be processed)
`static String` | `GEONAMES_COUNTRY_FILE_ACCEPT_REGEX_STRING` The regexp that every country file dump matches
`protected static org.slf4j.Logger` | `logger`
`static String` | `OPENSTREETMAP_US_FILE_ACCEPT_REGEX_STRING`
`static String` | `SPLITED_ALLCOUNTRIES_FILE_ACCEPT_REGEX_STRING`
`static String` | `SPLITED_FILE_ACCEPT_REGEX_STRING`
`static String` | `SPLITED_GEONAMES_ALTERNATENAMES_FILE_ACCEPT_REGEX_STRING`
`static String` | `SPLITED_GEONAMES_US_FILE_ACCEPT_REGEX_STRING`
`static String` | `SPLITED_OPENSTREETMAP_FILE_ACCEPT_REGEX_STRING`
`static String` | `SPLITED_OPENSTREETMAP_US_FILE_ACCEPT_REGEX_STRING`
`static String` | `TAR_BZ2_FILE_ACCEPT_REGEX_STRING`
`static String` | `ZIP_FILE_ACCEPT_REGEX_STRING` The regexp that every zipped country file dump matches

Constructor Summary
`ImporterHelper()`

Method Summary
`static List<Pattern>` | `compileRegex(String regexpSemiColumnSeparated)`
`static String[]` | `correctLastAdmCodeIfPossible(String[] fields)`
`static void` | `download(String address, String localFileName)`
`static String` | `formatSeconds(long secsIn)`
`static long` | `getHttpFileSize(String URL)`
`static File[]` | `listCountryFilesToImport(String directoryPath)`
`static File[]` | `listGeonamesSplitedFilesToImport(String directoryPath)`
`static File[]` | `listOpenstreetmapSplitedFilesToImport(String directoryPath)`
`static File[]` | `listTarFiles(String directoryPath)`
`static File[]` | `listZipFiles(String directoryPath)`
`static void` | `unzipFile(File file)` unzip a file in the same directory as the zipped file
`static String[]` | `virtualizeADMD(String[] fields)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### EXCLUDED_README_FILENAME

    public static final String EXCLUDED_README_FILENAME

  The readme filename (it must not be processed)

  See Also:
    Constant Field Values

### ALLCOUTRY_FILENAME

    public static final String ALLCOUTRY_FILENAME

  the all country dump file name

  See Also:
    Constant Field Values

### GEONAMES_COUNTRY_FILE_ACCEPT_REGEX_STRING

    public static final String GEONAMES_COUNTRY_FILE_ACCEPT_REGEX_STRING

  The regexp that every country file dump matches

  See Also:
    Constant Field Values

### OPENSTREETMAP_US_FILE_ACCEPT_REGEX_STRING

    public static final String OPENSTREETMAP_US_FILE_ACCEPT_REGEX_STRING

See Also:
  Constant Field Values

### SPLITED_FILE_ACCEPT_REGEX_STRING

    public static final String SPLITED_FILE_ACCEPT_REGEX_STRING

See Also:
  Constant Field Values

### SPLITED_OPENSTREETMAP_FILE_ACCEPT_REGEX_STRING

    public static final String SPLITED_OPENSTREETMAP_FILE_ACCEPT_REGEX_STRING

See Also:
  Constant Field Values

### SPLITED_OPENSTREETMAP_US_FILE_ACCEPT_REGEX_STRING

    public static final String SPLITED_OPENSTREETMAP_US_FILE_ACCEPT_REGEX_STRING

See Also:
  Constant Field Values

### SPLITED_GEONAMES_US_FILE_ACCEPT_REGEX_STRING

    public static final String SPLITED_GEONAMES_US_FILE_ACCEPT_REGEX_STRING

See Also:
  Constant Field Values

### SPLITED_GEONAMES_ALTERNATENAMES_FILE_ACCEPT_REGEX_STRING

    public static final String SPLITED_GEONAMES_ALTERNATENAMES_FILE_ACCEPT_REGEX_STRING

See Also:
  Constant Field Values

### SPLITED_ALLCOUNTRIES_FILE_ACCEPT_REGEX_STRING

    public static final String SPLITED_ALLCOUNTRIES_FILE_ACCEPT_REGEX_STRING

See Also:
  Constant Field Values

### ZIP_FILE_ACCEPT_REGEX_STRING

    public static final String ZIP_FILE_ACCEPT_REGEX_STRING

  The regexp that every zipped country file dump matches

  See Also:
    Constant Field Values

### TAR_BZ2_FILE_ACCEPT_REGEX_STRING

    public static final String TAR_BZ2_FILE_ACCEPT_REGEX_STRING

See Also:
  Constant Field Values

### logger

    protected static final org.slf4j.Logger logger

### countryFileFilter

    public static FileFilter countryFileFilter

### countryGeonamesSplitedFileFilter

    public static FileFilter countryGeonamesSplitedFileFilter

### alternatenamesGeonamesSplitedFileFilter

    public static FileFilter alternatenamesGeonamesSplitedFileFilter

### countryOpenstreetMapSplitedFileFilter

    public static FileFilter countryOpenstreetMapSplitedFileFilter

Constructor Detail

### ImporterHelper

    public ImporterHelper()

Method Detail

### listCountryFilesToImport

    public static File[] listCountryFilesToImport(String directoryPath)

  Parameters:
    `directoryPath` - The directory where files are
  Returns:
    the allcountries.txt (@see ALLCOUTRY_FILENAME file if present or the list of country file to Import or an empty array if there is no file
  See Also:
    `GEONAMES_COUNTRY_FILE_ACCEPT_REGEX_STRING`

### listGeonamesSplitedFilesToImport

    public static File[] listGeonamesSplitedFilesToImport(String directoryPath)

  Parameters:
    `directoryPath` - The directory where splited files are
  Returns:
    the allcountries.XX.txt (@see ALLCOUTRY_FILENAME file if present or the list of country file to Import or an empty array if there is no file
  See Also:
    `GEONAMES_COUNTRY_FILE_ACCEPT_REGEX_STRING`

### listOpenstreetmapSplitedFilesToImport

    public static File[] listOpenstreetmapSplitedFilesToImport(String directoryPath)

  Parameters:
    `directoryPath` - The directory where splited files are
  Returns:
    the allcountries.XX.txt (@see ALLCOUTRY_FILENAME file if present or the list of country file to Import or an empty array if there is no file
  See Also:
    `GEONAMES_COUNTRY_FILE_ACCEPT_REGEX_STRING`

### listZipFiles

    public static File[] listZipFiles(String directoryPath)

  Parameters:
    `directoryPath` - The directory where Geonames files are to be downloaded in order to be processed
  Returns:
    all the zip files present in the specified directory or an empty array if there is no file
  See Also:
    `ZIP_FILE_ACCEPT_REGEX_STRING`

### listTarFiles

    public static File[] listTarFiles(String directoryPath)

  Parameters:
    `directoryPath` - The directory where openstreetmap files are to be downloaded in order to be processed
  Returns:
    all the zip files present in the specified directory or an empty array if there is no file
  See Also:
    `TAR_BZ2_FILE_ACCEPT_REGEX_STRING`

### getHttpFileSize

    public static long getHttpFileSize(String URL)

  Parameters:
    `URL` - the HTTP URL
  Returns:
    The size of the HTTP file using HTTP head method or -1 if error or the file doesn't exists

### download

    public static void download(String address,
                                String localFileName)
                         throws FileNotFoundException

  Parameters:
    `address` - the address of the file to be downloaded
    `localFileName` - the local file name (with absolute path)
  Throws:
    `FileNotFoundException`

### unzipFile

    public static void unzipFile(File file)

  unzip a file in the same directory as the zipped file

  Parameters:
    `file` - The file to unzip

### virtualizeADMD

    public static String[] virtualizeADMD(String[] fields)

  Parameters:
    `fields` - the fields corresponding to a split line of the csv geonames file
  Returns:
    the modified fields whith the feature code change to ADM1,ADM2,ADM3,ADM4 according to the ADMcodes. e.g id adm1code and Adm2 code are not null : the feature code will be change to ADM2.

### correctLastAdmCodeIfPossible

    public static String[] correctLastAdmCodeIfPossible(String[] fields)

### compileRegex

    public static List<Pattern> compileRegex(String regexpSemiColumnSeparated)

  Parameters:
    `regexpSemiColumnSeparated` - a string with multiple reqgexp separated by ';'
  Returns:
    A list of `Pattern` or null if a regexp are not corrects

### formatSeconds

    public static String formatSeconds(long secsIn)

  Parameters:
    `secsIn` - the number of seconds
  Returns:
    a human reading strings. example :1 hour 6 minuts 40 seconds.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012. All Rights Reserved.