本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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())));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
}
}