// x is a label for an item and y is the index in bibliography
public final boolean parseAuxFile(String filename)
{
// regular expressions
Pattern pattern ;
Matcher matcher ;
// while condition
boolean weiter = false ;
// return value -> default: no error
boolean back = true ;
// fileopen status
boolean loopFileOpen = false ;
// the important tag
pattern = Pattern.compile( "\\\\citation\\{.+\\}" ) ;
// input-file-buffer
BufferedReader br = null ;
// filelist, used for nested aux files
Vector<String> fileList = new Vector<String>(5) ;
fileList.add( filename );
// get the file path
File dummy = new File( filename ) ;
String path = dummy.getParent() ;
if (path != null)
path = path + File.separator ;
else
path = "" ;
nestedAuxCounter = -1 ; // count only the nested reads
// index of current file in list
int fileIndex = 0 ;
while (fileIndex < fileList.size())
{
String fName = fileList.elementAt( fileIndex ) ;
try
{
// System.out.println("read #"+fName +"#") ;
br = new BufferedReader( new FileReader( fName ) ) ;
weiter = true ;
loopFileOpen = true ;
}
catch ( FileNotFoundException fnfe )
{
System.out.println( "Cannot locate input file! " + fnfe.getMessage() ) ;
// System.exit( 0 ) ;
back = false ;
weiter = false ;
loopFileOpen = false ;
}
while ( weiter )
{
String line ;
try
{
if (br == null)
throw new IOException();
line = br.readLine() ;
}
catch ( IOException ioe )
{
line = null ;
weiter = false ;
}
if ( line != null )
{
matcher = pattern.matcher( line ) ;
while ( matcher.find() )
{
// extract the bibtex-key(s) XXX from \citation{XXX} string
int len = matcher.end() - matcher.start() ;