de.hpi.fgis.dude.datasource
Class BibtexSource

java.lang.Object
  extended by de.hpi.fgis.dude.util.AbstractCleanable
      extended by de.hpi.fgis.dude.datasource.AbstractDataSource<BibtexSource>
          extended by de.hpi.fgis.dude.datasource.BibtexSource
All Implemented Interfaces:
DataSource, Cleanable, AutoJsonable, Jsonable, JsonableReader<DuDeObject>, Closeable, Iterable<DuDeObject>

public class BibtexSource
extends AbstractDataSource<BibtexSource>
implements Jsonable

BibtexSource represents *.bib files containing BibTeX syntax.

Author:
Matthias Pohl

Nested Class Summary
protected  class BibtexSource.BibtexSourceIterator
          BibtexSourceIterator is used for generating DuDeObjects out of BibtexSources.
 
Nested classes/interfaces inherited from class de.hpi.fgis.dude.datasource.AbstractDataSource
AbstractDataSource.AbstractDataSourceIterator<T extends AbstractDataSource<?>>
 
Field Summary
static String ADDITIONAL_AUTHORS_EXISTS_ATTRIBUTE
          The name of the attribute for storing information, whether there is an explicit mention that not all authors are listed.
static String KEY_ATTRIBUTE
          The name of the attribute that stores the key.
static String PERSON_FIRST_NAME_ATTRIBUTE
          The name of the attribute that stores the first name of a person.
static String PERSON_LAST_NAME_ATTRIBUTE
          The name of the attribute that stores the last name of a person.
static String PERSON_LINEAGE_ATTRIBUTE
          The name of the attribute that stores the lineage (like 'jr' or 'sr') of a person.
static String PERSON_PRE_LAST_NAME_ATTRIBUTE
          The name of the attribute that stores the prefix of the person's last name.
static String TYPE_ATTRIBUTE
          The name of the attribute that stores the type.
 
Constructor Summary
protected BibtexSource()
          Internal constructor for Jsonable deserialization.
  BibtexSource(String identifier, File file)
          Initializes a BibtexSource.
  BibtexSource(String identifier, File file, boolean resolveCrossReferences)
          Initializes a BibtexSource object.
 
Method Summary
 void close()
           
 void disableRetainingUnresolvedMacroReferences()
          Disables retaining the macros, if their value cannot be resolved.
 void enableRetainingUnresolvedMacroReferences()
          Enables retaining the macros, if their value cannot be resolved.
 void fromJson(DuDeJsonParser<?> jsonParser)
          Initializes the current instance using the passed DuDeJsonParser.
protected  Iterator<BibtexAbstractEntry> getEntryIterator()
          Returns the entry iterator.
 Iterator<DuDeObject> iterator()
           
 boolean retainUnresolvedMacroReferences()
          Checks, whether unresolved macro references are retained.
 void toJson(DuDeJsonGenerator jsonGenerator)
          Generates the Json code using the passed DuDeJsonGenerator.
 
Methods inherited from class de.hpi.fgis.dude.datasource.AbstractDataSource
addIdAttributes, autoGeneratedIds, equals, getExtractedRecordCount, getIdAttributes, getIdentifier, hashCode, setExtractedRecordCount, toString, withIdAttributes
 
Methods inherited from class de.hpi.fgis.dude.util.AbstractCleanable
cleanUp, registerCleanable, registerCloseable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.hpi.fgis.dude.util.Cleanable
cleanUp, registerCleanable, registerCloseable
 

Field Detail

KEY_ATTRIBUTE

public static final String KEY_ATTRIBUTE
The name of the attribute that stores the key.

See Also:
Constant Field Values

TYPE_ATTRIBUTE

public static final String TYPE_ATTRIBUTE
The name of the attribute that stores the type.

See Also:
Constant Field Values

ADDITIONAL_AUTHORS_EXISTS_ATTRIBUTE

public static final String ADDITIONAL_AUTHORS_EXISTS_ATTRIBUTE
The name of the attribute for storing information, whether there is an explicit mention that not all authors are listed. ('others' keyword or something similar to that within the authors list)

See Also:
Constant Field Values

PERSON_FIRST_NAME_ATTRIBUTE

public static final String PERSON_FIRST_NAME_ATTRIBUTE
The name of the attribute that stores the first name of a person.

See Also:
Constant Field Values

PERSON_PRE_LAST_NAME_ATTRIBUTE

public static final String PERSON_PRE_LAST_NAME_ATTRIBUTE
The name of the attribute that stores the prefix of the person's last name.

See Also:
Constant Field Values

PERSON_LAST_NAME_ATTRIBUTE

public static final String PERSON_LAST_NAME_ATTRIBUTE
The name of the attribute that stores the last name of a person.

See Also:
Constant Field Values

PERSON_LINEAGE_ATTRIBUTE

public static final String PERSON_LINEAGE_ATTRIBUTE
The name of the attribute that stores the lineage (like 'jr' or 'sr') of a person.

See Also:
Constant Field Values
Constructor Detail

BibtexSource

protected BibtexSource()
Internal constructor for Jsonable deserialization.


BibtexSource

public BibtexSource(String identifier,
                    File file)
             throws FileNotFoundException,
                    IOException,
                    ExpansionException,
                    ParseException
Initializes a BibtexSource.

Parameters:
identifier - The identifier of the DataSource instance.
file - The file of which the data will be extracted.
Throws:
FileNotFoundException - If the passed file was not found on the file system.
IOException - If an error occurs while reading the file.
ExpansionException - If an error occurred while resolving cross references, macros, etc.
ParseException - If the BibTeX syntax of the passed file is invalid.

BibtexSource

public BibtexSource(String identifier,
                    File file,
                    boolean resolveCrossReferences)
             throws FileNotFoundException,
                    IOException,
                    ExpansionException,
                    ParseException
Initializes a BibtexSource object.

Parameters:
identifier - The identifier of the DataSource instance.
file - The File object, from which the data will be extracted.
resolveCrossReferences - Determines whether cross references shall be resolved or not.
Throws:
FileNotFoundException - If the passed file was not found on the file system.
IOException - If an error occurs while reading the file.
ExpansionException - If an error occurred while resolving cross references, macros, etc.
ParseException - If the BibTeX syntax of the passed file is invalid.
Method Detail

enableRetainingUnresolvedMacroReferences

public void enableRetainingUnresolvedMacroReferences()
Enables retaining the macros, if their value cannot be resolved. This option is disabled by default.


disableRetainingUnresolvedMacroReferences

public void disableRetainingUnresolvedMacroReferences()
Disables retaining the macros, if their value cannot be resolved. This option is disabled by default.


retainUnresolvedMacroReferences

public boolean retainUnresolvedMacroReferences()
Checks, whether unresolved macro references are retained. This option is disabled by default.

Returns:
true, if unresolved macro references will be retained; otherwise false.

getEntryIterator

protected Iterator<BibtexAbstractEntry> getEntryIterator()
Returns the entry iterator.

Returns:
An iterator returning all entries of the parsed file.

close

public void close()
Specified by:
close in interface Closeable
Overrides:
close in class AbstractDataSource<BibtexSource>

iterator

public Iterator<DuDeObject> iterator()
Specified by:
iterator in interface Iterable<DuDeObject>
Specified by:
iterator in class AbstractDataSource<BibtexSource>

toJson

public void toJson(DuDeJsonGenerator jsonGenerator)
            throws org.codehaus.jackson.JsonGenerationException,
                   IOException
Description copied from interface: Jsonable
Generates the Json code using the passed DuDeJsonGenerator.

Specified by:
toJson in interface Jsonable
Parameters:
jsonGenerator - The DuDeJsonGenerator that is used internally.
Throws:
org.codehaus.jackson.JsonGenerationException - If an error occurs while generating the Json syntax.
IOException - If an error occurs while writing to the output.

fromJson

public void fromJson(DuDeJsonParser<?> jsonParser)
              throws org.codehaus.jackson.JsonParseException,
                     IOException
Description copied from interface: Jsonable
Initializes the current instance using the passed DuDeJsonParser.

Specified by:
fromJson in interface Jsonable
Parameters:
jsonParser - The parser that is used for extracting the data out of the Json.
Throws:
org.codehaus.jackson.JsonParseException - If an error occurs while parsing the Json.
IOException - If an error occurs while reading from the stream.


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.