當前位置: 首頁>>代碼示例>>Java>>正文


Java DbfReader類代碼示例

本文整理匯總了Java中org.jamel.dbf.DbfReader的典型用法代碼示例。如果您正苦於以下問題:Java DbfReader類的具體用法?Java DbfReader怎麽用?Java DbfReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DbfReader類屬於org.jamel.dbf包,在下文中一共展示了DbfReader類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: siFile

import org.jamel.dbf.DbfReader; //導入依賴的package包/類
private static ListMultimap<Long, SignPost> siFile(TomtomFolder folder) {
    ListMultimap<Long, SignPost> signs = ArrayListMultimap.create();
    File file = new File(folder.getFile("si.dbf"));
    if (!file.exists()) {
        return signs;
    }
    log.info("Reading SI {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            if (row.getInt("AMBIG") != 1) {
                SignPost sign = SignPost.fromRow(row);
                signs.put(sign.getId(), sign);
            }
        }
    }
    log.info("Loaded {} si", signs.size());
    return signs;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:20,代碼來源:SignPosts.java

示例2: spFile

import org.jamel.dbf.DbfReader; //導入依賴的package包/類
private static Multimap<Long, SignPostPath> spFile(TomtomFolder folder) {
    File file = new File(folder.getFile("sp.dbf"));
    Multimap<Long, SignPostPath> result = TreeMultimap.create();
    if (!file.exists()) {
        return result;
    }
    log.info("Reading SP {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            SignPostPath path = SignPostPath.fromRow(row);
            result.put(path.getId(), path);
        }
    }
    log.info("Loaded {} sign paths", result.size());
    return result;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:18,代碼來源:SignPosts.java

示例3: sgFile

import org.jamel.dbf.DbfReader; //導入依賴的package包/類
private static Map<Long, Long> sgFile(TomtomFolder folder) {
    File file = new File(folder.getFile("sg.dbf"));
    Map<Long, Long> speeds = newHashMap();
    if (!file.exists()) {
        return speeds;
    }

    log.info("Reading SG {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            speeds.put(row.getLong("ID"), row.getLong("JNCTID"));
        }
    }
    log.info("Loaded {} Sign posts junctions", speeds.size());
    return speeds;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:18,代碼來源:SignPosts.java

示例4: nwFile

import org.jamel.dbf.DbfReader; //導入依賴的package包/類
private static Map<Long, SignWay> nwFile(TomtomFolder folder) {
    File file = new File(folder.getFile("nw.dbf"));
    Map<Long, SignWay> speeds = newHashMap();
    if (!file.exists()) {
        return speeds;
    }

    log.info("Reading NW {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            speeds.put(row.getLong("ID"), new SignWay(row.getLong("ID"), row.getLong("F_JNCTID"), row.getLong("T_JNCTID")));
        }
    }
    log.info("Loaded {} road segment", speeds.size());
    return speeds;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:18,代碼來源:SignPosts.java

示例5: loadSpeedProfiles

import org.jamel.dbf.DbfReader; //導入依賴的package包/類
private static Map<Integer, PrecomputeSpeedProfile> loadSpeedProfiles(String filename) {
    File file = new File(filename);
    if (!file.exists()) {
        log.info("File not found : {}", file.getAbsolutePath());
        return newHashMap();
    }

    TreeMultimap<Integer, SpeedProfile> profilesMap = TreeMultimap.create();
    log.info("Reading HSPR {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            SpeedProfile profile = new SpeedProfile(row.getInt("PROFILE_ID"), row.getInt("TIME_SLOT"), row.getDouble("REL_SP"));
            profilesMap.put(profile.getId(), profile);
        }
    }
    log.info("Loaded {} hspr", profilesMap.size());

    return profilesMap.asMap().entrySet().stream().collect(toMap(Entry::getKey, e -> precomputeProfile(e.getValue())));
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:21,代碼來源:HsprDbf.java

示例6: loadHsnp

import org.jamel.dbf.DbfReader; //導入依賴的package包/類
private static ArrayListMultimap<Long, Speed> loadHsnp(String filename) {
    File file = new File(filename);
    ArrayListMultimap<Long, Speed> speeds = ArrayListMultimap.create();
    if (!file.exists()) {
        log.info("File not found : {}", file.getAbsolutePath());
        return speeds;
    }

    log.info("Reading HSNP {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            Speed speed = parse(row);
            speeds.put(speed.getId(), speed);
        }
    }
    log.info("Loaded {} speed profile", speeds.size());
    return speeds;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:20,代碼來源:HsnpDbf.java

示例7: ldFile

import org.jamel.dbf.DbfReader; //導入依賴的package包/類
private static Map<Long, List<String>> ldFile(TomtomFolder folder) {
    File file = new File(folder.getFile("ld.dbf"));
    if (!file.exists()) {
        return newHashMap();
    }
    ArrayListMultimap<Long, LaneDirection> directions = ArrayListMultimap.create();
    log.info("Reading LD {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            directions.put(row.getLong("ID"), LaneDirection.parse(row.getInt("DIRECTION"), row.getString("VALIDITY")));
        }
    }
    Map<Long, List<String>> tags = newHashMap();
    for (Long id : directions.keySet()) {
        tags.put(id, asText(directions.get(id)));
    }
    log.info("Loaded {} lane directions", directions.size());
    return tags;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:21,代碼來源:LdDbf.java

示例8: loadSpeedRestrictions

import org.jamel.dbf.DbfReader; //導入依賴的package包/類
private static ArrayListMultimap<Long, SpeedRestriction> loadSpeedRestrictions(String filename) {
    ArrayListMultimap<Long, SpeedRestriction> restrictions = ArrayListMultimap.create();
    File file = new File(filename);
    if (!file.exists()) {
        log.info("File not found : {}", file.getAbsolutePath());
        return restrictions;
    }
    log.info("Reading SR {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            SpeedRestriction restriction = new SpeedRestriction(row.getLong("ID"), row.getInt("SPEED"), Validity.values()[row.getInt("VALDIR") - 1]);
            restrictions.put(restriction.getId(), restriction);
        }
    }
    log.info("Loaded {} speed restrictions", restrictions.size());

    return restrictions;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:20,代碼來源:SrDbf.java

示例9: readFile

import org.jamel.dbf.DbfReader; //導入依賴的package包/類
private Map<Long, List<AlternativeName>> readFile(String filename, String alternativeParamName, boolean hasSideName) {
    Map<Long, List<AlternativeName>> alternates = newHashMap();

    File file = new File(folder.getFile(filename));
    if (file.exists()) {
        log.info("Reading {}", file);
        try (DbfReader reader = new DbfReader(file)) {
            DbfRow row;
            Stopwatch stopwatch = Stopwatch.createStarted();
            int counter = 0;

            while ((row = reader.nextRow()) != null) {
                AlternativeName altName = AlternativeName.fromDbf(row, alternativeParamName, hasSideName);
                List<AlternativeName> altNames = alternates.containsKey(altName.getId()) ? alternates.get(altName.getId()) : newArrayList();
                altNames.add(altName);
                alternates.put(altName.getId(), altNames);
                counter++;
            }
            long time = stopwatch.elapsed(MILLISECONDS);
            stopwatch.stop();
            log.info("Added {} object(s){}", counter, counter > 0 ? " in " + time + " ms at rate " + String.format("%.2f", counter * 1.0 / time) + " obj/ms" : "");
        }

    } else {
        log.info("File not found : {}", file.getAbsolutePath());
    }

    return alternates;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:30,代碼來源:NameProvider.java

示例10: loadData

import org.jamel.dbf.DbfReader; //導入依賴的package包/類
/**
 * 
 * @param <T> Output type
 * @param inputStream Input stream
 * @param rowMapper Row mapper
 * @return Mapped rows
 * @throws DbfException 
 */
public static <T> List<T> loadData(InputStream inputStream, DbfRowMapper<T> rowMapper) throws DbfException
{
     try (DbfReader reader = new DbfReader(inputStream)) {
        List<T> result = new ArrayList<>(reader.getRecordCount());
        Object[] row;
        while ((row = reader.nextRecord()) != null) {
            result.add(rowMapper.mapRow(row));
        }

        return result;
    }
}
 
開發者ID:jamel,項目名稱:dbf,代碼行數:21,代碼來源:DbfProcessor.java

示例11: processDbf

import org.jamel.dbf.DbfReader; //導入依賴的package包/類
public static void processDbf(File dbf, DbfRowProcessor rowProcessor) throws DbfException {
    try (DbfReader reader = new DbfReader(dbf)) {
        Object[] row;
        while ((row = reader.nextRecord()) != null) {
            rowProcessor.processRow(row);
        }
    }
}
 
開發者ID:jamel,項目名稱:dbf,代碼行數:9,代碼來源:DbfProcessor.java

示例12: parse

import org.jamel.dbf.DbfReader; //導入依賴的package包/類
@Override
public void parse(File inFile) throws DPUException, ParseFailed {
    final String encoding;
    if (config.encoding == null || config.encoding.isEmpty()) {
        // parse from DBF file
        encoding = "UTF-8";
    } else {
        encoding = config.encoding;
    }
    if (!Charset.isSupported(encoding)) {
        throw new ParseFailed("Charset '" + encoding + "' is not supported.");
    }
    final DbfReader reader = new DbfReader(inFile);
    //
    // get header
    //        
    final List<String> header;
    final DbfHeader dbfHeader = reader.getHeader();
    header = new ArrayList<>(dbfHeader.getFieldsCount());
    for (int i = 0; i < dbfHeader.getFieldsCount(); ++i) {
        final DbfField field = dbfHeader.getField(i);
        header.add(field.getName());
    }
    //
    // prase other rows
    //

    // set if for first time or if we use static row counter
    if (!config.checkStaticRowCounter || rowNumber == 0) {
       rowNumber = 1;
    }
    int rowNumPerFile = 0;
    Object[] row = reader.nextRecord();
    List<Object> stringRow = new ArrayList(row.length);
    // configure parser
    TableToRdfConfigurator.configure(tableToRdf, header, Arrays.asList(row), 0);
    // go ...
    if (config.rowLimit == null) {
        LOG.debug("Row limit: not used");
    } else {
        LOG.debug("Row limit: {}", config.rowLimit);
    }
    while (row != null &&
            (config.rowLimit == null || rowNumPerFile < config.rowLimit) &&
            !context.canceled()) {            
        // convert
        for (Object item : row) {
            if (item instanceof byte[]) {
                try {
                    final String newString = new String((byte [])item, config.encoding);
                    stringRow.add(newString);
                } catch (UnsupportedEncodingException ex) {
                    // terminate DPU as this can not be handled
                    throw new RuntimeException(ex);
                }
            } else {
                stringRow.add(item);
            }
        }
        // process
        tableToRdf.paserRow(stringRow, rowNumber);
        // read next row
        rowNumber++;
        rowNumPerFile++;
        row = reader.nextRecord();
        stringRow.clear();
        // log
        if ((rowNumPerFile % 1000) == 0) {
            LOG.debug("Row number {} processed.", rowNumPerFile);
        }
    }
}
 
開發者ID:UnifiedViews,項目名稱:Plugins,代碼行數:73,代碼來源:ParserDbf.java


注:本文中的org.jamel.dbf.DbfReader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。