public class AbbreviationManager extends Object implements Serializable
The AbbreviationManager takes care about abbreviations: parse source file, lookup and save. Abbreviations are used in output, where you want a short (numeric) entry instead of a long text. So for example if the source record contain the value "Bavarian State Library", and we map number 5 to it the project will output 5 instead of the longer string.
It can read two types of files. For plain files the abbreviatable entry will be the full line, and the abbreviated value will be the line number. For comma separated files the first field will be the abbreviated value, and the rest of the line will be the key to abbreviate.
Example for plain fileNational Library of France Österreichische Nationalbibliothek - Austrian National Library National Library of the NetherlandsExample for comma separated file:
1;National Library of France 2;Österreichische Nationalbibliothek - Austrian National Library 3;National Library of the Netherlands
Constructor and Description |
---|
AbbreviationManager() |
Modifier and Type | Method and Description |
---|---|
Map<String,Integer> |
getData() |
protected void |
initialize(String pFileName) |
protected void |
initialize(String pFileName,
boolean parse)
Initialize abbreviations.
|
Integer |
lookup(String entry)
Looking for the abbreviated value of a text.
|
void |
processLine(String line,
int i,
boolean parse) |
void |
save(String fileName)
Save the abbreviations into a file.
|
String |
searchById(Integer id) |
protected void initialize(String pFileName)
protected void initialize(String pFileName, boolean parse)
pFileName
- The name of input fileparse
- Whether parse the file to extract the abbreviation or use line number as the abbreviated valuepublic void processLine(String line, int i, boolean parse) throws NumberFormatException
NumberFormatException
public Integer lookup(String entry)
entry
- A key to abbreviatepublic void save(String fileName) throws FileNotFoundException, UnsupportedEncodingException
fileName
- The file name.FileNotFoundException
UnsupportedEncodingException
Copyright © 2020. All rights reserved.