Top Description Fields Constructors Methods
org.jabref.model.entry

public Class BibEntry

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Annotations
@AllowedToUseLogic:because it needs access to parser and writers
Imports
java.util.ArrayList, .Collection, .Collections, .Comparator, .HashMap, .HashSet, .LinkedHashSet, .List, .Map, .Objects, .Optional, .SequencedSet, .Set, .TreeSet, java.util.concurrent.ConcurrentHashMap, java.util.function.BiFunction, .Predicate, java.util.stream.Collectors, javafx.beans.Observable, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, javafx.collections.FXCollections, .ObservableMap, org.jabref.architecture.AllowedToUseLogic, org.jabref.logic.bibtex.FileFieldWriter, org.jabref.logic.importer.util.FileFieldParser, org.jabref.model.FieldChange, org.jabref.model.database.BibDatabase, org.jabref.model.entry.event.EntriesEventSource, .FieldAddedOrRemovedEvent, .FieldChangedEvent, org.jabref.model.entry.field.Field, .InternalField, .OrFields, .StandardField, org.jabref.model.entry.identifier.DOI, .ISBN, org.jabref.model.entry.types.EntryType, .IEEETranEntryType, .StandardEntryType, org.jabref.model.strings.LatexToUnicodeAdapter, .StringUtil, org.jabref.model.util.MultiKeyMap, com.google.common.annotations.VisibleForTesting, com.google.common.eventbus.EventBus, com.tobiasdiez.easybind.EasyBind, com.tobiasdiez.easybind.optional.OptionalBinding, org.slf4j.Logger, .LoggerFactory

Represents a Bib(La)TeX entry, which can be BibTeX or BibLaTeX.

Example:

Some commment
@misc{key,
  fieldName = {fieldValue},
  otherFieldName = {otherFieldValue}
}

Then,

A BibTeX entry has following properties: In JabRef, this is modeled the following way:

In case you search for a builder as described in Item 2 of the book "Effective Java", you won't find one. Please use the methods withCitationKey(String) and withField(Field, String). All these methods set hasChanged() to false. In case changed, use withChanged(boolean).

Field Summary

Modifier and TypeField and Description
private boolean
changed

Marks whether the complete serialization, which was read from file, should be used.

private String
commentsBeforeEntry

The part before the start of the entry

public static final EntryType
private final EventBus
private ObservableMap<Field, String>
private final MultiKeyMap<StandardField, Character, KeywordList>
fieldsAsKeywords

Cache that stores the field as keyword lists (format <Field, Separator, Keyword list>)

private final Map<Field, Set<String>>
fieldsAsWords

Map to store the words in every field

private String
private final Map<Field, String>
latexFreeFields

Cache that stores latex free versions of fields.

private static final Logger
private String
parsedSerialization

Stores the text "rendering" of the entry as read by the BibTeX reader.

private final SharedBibEntryData
private final ObjectProperty<EntryType>

Constructor Summary

AccessConstructor and Description
public
BibEntry()

Constructs a new BibEntry.

public
BibEntry(String citationKey)

public
BibEntry(EntryType type)

Constructs a new BibEntry.

public
BibEntry(EntryType type, String citationKey)

Method Summary

Modifier and TypeMethod and Description
public Optional<FieldChange>
public Optional<FieldChange>
addFile(int index, LinkedFile file)

public void
addKeyword(String
Keyword to add
keyword
,
Character delimiter)

Check if a keyword already exists (case insensitive), if not: add it

public void
addKeyword(Keyword keyword, Character delimiter)

public void
addKeywords(Collection<String>
Keywords to add
keywords
,
Character delimiter)

Add multiple keywords to entry

public boolean

Returns:

true if all fields are set or could be resolved, false otherwise.
allFieldsPresent
(Collection<OrFields>
An array of field names to be checked.
fields
,
BibDatabase
The database in which to look up crossref'd entries, if any. This argument can be null, meaning that no attempt will be made to follow crossrefs.
database
)

Determines whether this entry has all the given fields present.

public Optional<FieldChange>
public Optional<FieldChange>
clearField(Field
The field to clear.
field
)

Remove the mapping for the field name, and notify listeners about the change.

public Optional<FieldChange>
clearField(Field
the field to clear.
field
,
EntriesEventSource
the source a new FieldChangedEvent should be posten from.
eventSource
)

Remove the mapping for the field name, and notify listeners about the change including the EntriesEventSource.

public Object
clone()

Overrides java.lang.Object.clone.

Returns a clone of this entry.

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

private Optional<String>

Returns:

determined field value
genericGetFieldOrAlias
(Field
the field
field
,
BiFunction<BibEntry, Field, Optional<String>>
the method to get the value of a given field in a given entry
getFieldValue
)

Internal method used to get the content of a field (or its alias) Used by getFieldOrAlias(Field) and getFieldOrAliasLatexFree(Field)

private Optional<String>
public String

Returns:

A short textual description of the entry in the format: Author1, Author2: Title (Year)
getAuthorTitleYear
(int
The maximum number of characters (additional characters are replaced with "..."). Set to 0 to disable truncation.
maxCharacters
)

public Optional<String>
getCitationKey()

If not present, BibEntry#getAuthorTitleYear(int) can be used

public com.tobiasdiez.easybind.optional.OptionalBinding<String>
public Optional<DOI>
public Optional<String>
getField(Field field)

Returns the contents of the given field as an Optional.

public KeywordList
getFieldAsKeywords(Field field, Character keywordSeparator)

public Set<String>
public com.tobiasdiez.easybind.optional.OptionalBinding<String>
public Optional<String>
public Map<Field, String>
public Optional<String>
getFieldOrAlias(Field field)

Returns the contents of the given field or its alias as an Optional

The following aliases are considered (old bibtex <-> new biblatex) based on the biblatex documentation, chapter 2.2.5: address <-> location annote <-> annotation archiveprefix <-> eprinttype journal <-> journaltitle key <-> sortkey pdf <-> file primaryclass <-> eprintclass school <-> institution These work bidirectional.

public Optional<String>

Returns:

the stored latex-free content of the field (or its alias)
getFieldOrAliasLatexFree
(Field
the name of the field
name
)

Return the LaTeX-free contents of the given field or its alias an Optional

For details see also getFieldOrAlias(Field)

public SequencedSet<Field>
getFields()

Returns an unmodifiable sequence containing the names of all fields that are set for this particular entry.

public SequencedSet<Field>
getFields(Predicate<Field> selector)

Returns an unmodifiable sequence containing the names of all fields that are a) set for this particular entry and b) matching the given predicate

public ObservableMap<Field, String>
public Collection<String>
public List<LinkedFile>

Returns:

the list of linked files, is never null but can be empty. Changes to the underlying list will have no effect on the entry itself. Use addFile(LinkedFile).
getFiles
()

Gets a list of linked files.

public String
getId()

Returns this entry's ID. It is used internally to distinguish different BibTeX entries.

public Optional<ISBN>
public KeywordList
public Optional<Month>
public Observable[]
getObservables()

Returns a list of observables that represent the data of the entry.

public String
public Optional<Date>

Returns:

will return the publication date of the entry or null if no year was found.
getPublicationDate
()

Will return the publication date of the given bibtex entry conforming to ISO 8601, i.e. either YYYY or YYYY-MM.

public Optional<String>
public Optional<String>

Returns:

The resolved field value or null if not found.
getResolvedFieldOrAlias
(Field
The field to return the value of.
field
,
BibDatabase
maybenull The database of the bibtex entry.
database
)

Returns the text stored in the given field of the given bibtex entry which belongs to the given database.

public Optional<String>
public KeywordList
public SharedBibEntryData
private Optional<Field>

Returns:

the mapped field or null if there is no valid mapping available
getSourceField
(Field
field name of the BibEntry
targetField
,
EntryType
type of the BibEntry
targetEntry
,
EntryType
type of the cross-referenced BibEntry
sourceEntry
)

Map an (empty) field of a BibEntry to a field of a cross-referenced entry.

public Optional<String>

Returns:

an Optional containing the title of a BibTeX entry in case it exists, otherwise return an empty Optional.
getTitle
()

Returns the title of the given BibTeX entry as an Optional.

public EntryType
getType()

Returns this entry's type.

public String
public boolean
public boolean
public boolean
hasField(Field field)

Returns true if the entry has the given field, or false if it is not set.

public int
hashCode()

Overrides java.lang.Object.hashCode.

On purpose, this hashes the "content" of the BibEntry, not the sharedBibEntryData.

private void
public boolean
public void
mergeWith(BibEntry
another BibEntry from which fields are sourced from
other
)

Merge this entry's fields with another BibEntry.

public void
mergeWith(BibEntry
another BibEntry from which fields are sourced from
other
,
Set<Field>
collection of Fields in which 'other' has a priority into final result
otherPrioritizedFields
)

Merge this entry's fields with another BibEntry.

public Optional<FieldChange>
putKeywords(List<String> keywords, Character delimiter)

public Optional<FieldChange>
putKeywords(KeywordList keywords, Character delimiter)

public void
public Optional<FieldChange>
removeKeywords(KeywordList keywordsToRemove, Character keywordDelimiter)

public void
replaceDownloadedFile(String
the link to the file, which was downloaded
linkToDownloadedFile
,
LinkedFile
the path to be added to the entry
downloadedFile
)

Helper method to add a downloaded file to the entry.

public Optional<FieldChange>
replaceKeywords(KeywordList keywordsToReplace, Keyword newValue, Character keywordDelimiter)

public void
setChanged(boolean changed)

public Optional<FieldChange>
setCitationKey(String
The cite key to set. Must not be null; use clearCiteKey() to remove the cite key.
newKey
)

Sets the citation key.

public void
public void
setDate(Date date)

public void
setField(Map<Field, String> fields)

Sets a number of fields simultaneously.

public Optional<FieldChange>
setField(Field
The field to set
field
,
String
The value to set
value
,
EntriesEventSource
Source the event is sent from
eventSource
)

Set a field, and notify listeners about the change.

public Optional<FieldChange>
setField(Field
The field to set.
field
,
String
The value to set.
value
)

Set a field, and notify listeners about the change.

public Optional<FieldChange>
public void
setId(String
The ID to be used
id
)

Sets this entry's identifier (ID).

public Optional<FieldChange>
setMonth(Month parsedMonth)

public void
setParsedSerialization(String parsedSerialization)

public Optional<FieldChange>
setType(EntryType type)

Sets this entry's type.

public Optional<FieldChange>
setType(EntryType newType, EntriesEventSource eventSource)

Sets this entry's type and sets the changed flag to true If the new entry type equals the old entry type no changed flag is set.

public String
toString()

Overrides java.lang.Object.toString.

This returns a canonical BibTeX serialization.

public ObjectProperty<EntryType>
public void
public BibEntry
withChanged(boolean changed)

Required to trigger new serialization of the entry.

public BibEntry
public BibEntry
withDate(Date date)

public BibEntry
withField(Field field, String value)

public BibEntry
withFields(Map<Field, String> content)

A copy is made of the parameter

public BibEntry
public BibEntry
withMonth(Month parsedMonth)

public BibEntry
withSharedBibEntryData(int sharedId, int version)

public BibEntry
public BibEntry
withUserComments(String commentsBeforeEntry)

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

changedback to summary
private boolean changed

Marks whether the complete serialization, which was read from file, should be used.

Is set to true, if parts of the entry changed. This causes the entry to be serialized based on the internal state (and not based on the old serialization)

commentsBeforeEntryback to summary
private String commentsBeforeEntry

The part before the start of the entry

DEFAULT_TYPEback to summary
public static final EntryType DEFAULT_TYPE
eventBusback to summary
private final EventBus eventBus
fieldsback to summary
private ObservableMap<Field, String> fields
fieldsAsKeywordsback to summary
private final MultiKeyMap<StandardField, Character, KeywordList> fieldsAsKeywords

Cache that stores the field as keyword lists (format <Field, Separator, Keyword list>)

fieldsAsWordsback to summary
private final Map<Field, Set<String>> fieldsAsWords

Map to store the words in every field

idback to summary
private String id
latexFreeFieldsback to summary
private final Map<Field, String> latexFreeFields

Cache that stores latex free versions of fields.

LOGGERback to summary
private static final Logger LOGGER
parsedSerializationback to summary
private String parsedSerialization

Stores the text "rendering" of the entry as read by the BibTeX reader. Includes comments.

sharedBibEntryDataback to summary
private final SharedBibEntryData sharedBibEntryData
typeback to summary
private final ObjectProperty<EntryType> type

Constructor Detail

BibEntryback to summary
public BibEntry()

Constructs a new BibEntry. The internal ID is set to IdGenerator.next()

BibEntryback to summary
public BibEntry(String citationKey)
BibEntryback to summary
public BibEntry(EntryType type)

Constructs a new BibEntry. The internal ID is set to IdGenerator.next()

BibEntryback to summary
public BibEntry(EntryType type, String citationKey)

Method Detail

addFileback to summary
public Optional<FieldChange> addFile(LinkedFile file)
addFileback to summary
public Optional<FieldChange> addFile(int index, LinkedFile file)
addKeywordback to summary
public void addKeyword(String keyword, Character delimiter)

Check if a keyword already exists (case insensitive), if not: add it

Parameters
keyword:String

Keyword to add

addKeywordback to summary
public void addKeyword(Keyword keyword, Character delimiter)
addKeywordsback to summary
public void addKeywords(Collection<String> keywords, Character delimiter)

Add multiple keywords to entry

Parameters
keywords:Collection<String>

Keywords to add

allFieldsPresentback to summary
public boolean allFieldsPresent(Collection<OrFields> fields, BibDatabase database)

Determines whether this entry has all the given fields present. If a non-null database argument is given, this method will try to look up missing fields in entries linked by the "crossref" field, if any.

Parameters
fields:Collection<OrFields>

An array of field names to be checked.

database:BibDatabase

The database in which to look up crossref'd entries, if any. This argument can be null, meaning that no attempt will be made to follow crossrefs.

Returns:boolean

true if all fields are set or could be resolved, false otherwise.

clearCiteKeyback to summary
public Optional<FieldChange> clearCiteKey()
clearFieldback to summary
public Optional<FieldChange> clearField(Field field)

Remove the mapping for the field name, and notify listeners about the change.

Parameters
field:Field

The field to clear.

clearFieldback to summary
public Optional<FieldChange> clearField(Field field, EntriesEventSource eventSource)

Remove the mapping for the field name, and notify listeners about the change including the EntriesEventSource.

Parameters
field:Field

the field to clear.

eventSource:EntriesEventSource

the source a new FieldChangedEvent should be posten from.

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Returns a clone of this entry. Useful for copying. This will set a new ID for the cloned entry to be able to distinguish both copies. Does not port the listeners.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
genericGetFieldOrAliasback to summary
private Optional<String> genericGetFieldOrAlias(Field field, BiFunction<BibEntry, Field, Optional<String>> getFieldValue)

Internal method used to get the content of a field (or its alias) Used by getFieldOrAlias(Field) and getFieldOrAliasLatexFree(Field)

Parameters
field:Field

the field

getFieldValue:BiFunction<BibEntry, Field, Optional<String>>

the method to get the value of a given field in a given entry

Returns:Optional<String>

determined field value

genericGetResolvedFieldOrAliasback to summary
private Optional<String> genericGetResolvedFieldOrAlias(Field field, BibDatabase database, BiFunction<BibEntry, Field, Optional<String>> getFieldOrAlias)
getAuthorTitleYearback to summary
public String getAuthorTitleYear(int maxCharacters)
Parameters
maxCharacters:int

The maximum number of characters (additional characters are replaced with "..."). Set to 0 to disable truncation.

Returns:String

A short textual description of the entry in the format: Author1, Author2: Title (Year)

getCitationKeyback to summary
public Optional<String> getCitationKey()

If not present, BibEntry#getAuthorTitleYear(int) can be used

getCiteKeyBindingback to summary
public com.tobiasdiez.easybind.optional.OptionalBinding<String> getCiteKeyBinding()
getDOIback to summary
public Optional<DOI> getDOI()
getFieldback to summary
public Optional<String> getField(Field field)

Returns the contents of the given field as an Optional.

getFieldAsKeywordsback to summary
public KeywordList getFieldAsKeywords(Field field, Character keywordSeparator)
getFieldAsWordsback to summary
public Set<String> getFieldAsWords(Field field)
getFieldBindingback to summary
public com.tobiasdiez.easybind.optional.OptionalBinding<String> getFieldBinding(Field field)
getFieldLatexFreeback to summary
public Optional<String> getFieldLatexFree(Field field)
getFieldMapback to summary
public Map<Field, String> getFieldMap()
getFieldOrAliasback to summary
public Optional<String> getFieldOrAlias(Field field)

Returns the contents of the given field or its alias as an Optional

The following aliases are considered (old bibtex <-> new biblatex) based on the biblatex documentation, chapter 2.2.5:
address <-> location
annote <-> annotation
archiveprefix <-> eprinttype
journal <-> journaltitle
key <-> sortkey
pdf <-> file
primaryclass <-> eprintclass
school <-> institution
These work bidirectional.

Special attention is paid to dates: (see the biblatex documentation, chapter 2.3.8) The fields 'year' and 'month' are used if the 'date' field is empty. Conversely, getFieldOrAlias("year") also tries to extract the year from the 'date' field (analogously for 'month').

getFieldOrAliasLatexFreeback to summary
public Optional<String> getFieldOrAliasLatexFree(Field name)

Return the LaTeX-free contents of the given field or its alias an Optional

For details see also getFieldOrAlias(Field)

Parameters
name:Field

the name of the field

Returns:Optional<String>

the stored latex-free content of the field (or its alias)

getFieldsback to summary
public SequencedSet<Field> getFields()

Returns an unmodifiable sequence containing the names of all fields that are set for this particular entry.

getFieldsback to summary
public SequencedSet<Field> getFields(Predicate<Field> selector)

Returns an unmodifiable sequence containing the names of all fields that are a) set for this particular entry and b) matching the given predicate

getFieldsObservableback to summary
public ObservableMap<Field, String> getFieldsObservable()
getFieldValuesback to summary
public Collection<String> getFieldValues()
getFilesback to summary
public List<LinkedFile> getFiles()

Gets a list of linked files.

Returns:List<LinkedFile>

the list of linked files, is never null but can be empty. Changes to the underlying list will have no effect on the entry itself. Use addFile(LinkedFile).

getIdback to summary
public String getId()

Returns this entry's ID. It is used internally to distinguish different BibTeX entries.

It is not the citation key (which is stored in the InternalField#KEY_FIELD and also known as BibTeX key).

getISBNback to summary
public Optional<ISBN> getISBN()
getKeywordsback to summary
public KeywordList getKeywords(Character delimiter)
getMonthback to summary
public Optional<Month> getMonth()
getObservablesback to summary
public Observable[] getObservables()

Returns a list of observables that represent the data of the entry.

getParsedSerializationback to summary
public String getParsedSerialization()
getPublicationDateback to summary
public Optional<Date> getPublicationDate()

Will return the publication date of the given bibtex entry conforming to ISO 8601, i.e. either YYYY or YYYY-MM.

Returns:Optional<Date>

will return the publication date of the entry or null if no year was found.

getResolvedFieldOrAliasback to summary
public Optional<String> getResolvedFieldOrAlias(OrFields fields, BibDatabase database)
getResolvedFieldOrAliasback to summary
public Optional<String> getResolvedFieldOrAlias(Field field, BibDatabase database)

Returns the text stored in the given field of the given bibtex entry which belongs to the given database.

If a database is given, this function will try to resolve any string references in the field-value. Also, if a database is given, this function will try to find values for unset fields in the entry linked by the "crossref" field, if any.

Parameters
field:Field

The field to return the value of.

database:BibDatabase

maybenull The database of the bibtex entry.

Returns:Optional<String>

The resolved field value or null if not found.

getResolvedFieldOrAliasLatexFreeback to summary
public Optional<String> getResolvedFieldOrAliasLatexFree(Field field, BibDatabase database)
getResolvedKeywordsback to summary
public KeywordList getResolvedKeywords(Character delimiter, BibDatabase database)
getSharedBibEntryDataback to summary
public SharedBibEntryData getSharedBibEntryData()
getSourceFieldback to summary
private Optional<Field> getSourceField(Field targetField, EntryType targetEntry, EntryType sourceEntry)

Map an (empty) field of a BibEntry to a field of a cross-referenced entry.

Parameters
targetField:Field

field name of the BibEntry

targetEntry:EntryType

type of the BibEntry

sourceEntry:EntryType

type of the cross-referenced BibEntry

Returns:Optional<Field>

the mapped field or null if there is no valid mapping available

getTitleback to summary
public Optional<String> getTitle()

Returns the title of the given BibTeX entry as an Optional.

Returns:Optional<String>

an Optional containing the title of a BibTeX entry in case it exists, otherwise return an empty Optional.

getTypeback to summary
public EntryType getType()

Returns this entry's type.

getUserCommentsback to summary
public String getUserComments()
hasChangedback to summary
public boolean hasChanged()
hasCitationKeyback to summary
public boolean hasCitationKey()
hasFieldback to summary
public boolean hasField(Field field)

Returns true if the entry has the given field, or false if it is not set.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

On purpose, this hashes the "content" of the BibEntry, not the sharedBibEntryData. The content is

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

Annotations
@Override
invalidateFieldCacheback to summary
private void invalidateFieldCache(Field field)
isEmptyback to summary
public boolean isEmpty()
mergeWithback to summary
public void mergeWith(BibEntry other)

Merge this entry's fields with another BibEntry. Non-intersecting fields will be automatically merged. In cases of intersection, priority is given to THIS entry's field value.

Parameters
other:BibEntry

another BibEntry from which fields are sourced from

mergeWithback to summary
public void mergeWith(BibEntry other, Set<Field> otherPrioritizedFields)

Merge this entry's fields with another BibEntry. Non-intersecting fields will be automatically merged. In cases of intersection, priority is given to THIS entry's field value, UNLESS specified otherwise in the arguments.

Parameters
other:BibEntry

another BibEntry from which fields are sourced from

otherPrioritizedFields:Set<Field>

collection of Fields in which 'other' has a priority into final result

putKeywordsback to summary
public Optional<FieldChange> putKeywords(List<String> keywords, Character delimiter)
putKeywordsback to summary
public Optional<FieldChange> putKeywords(KeywordList keywords, Character delimiter)
registerListenerback to summary
public void registerListener(Object object)
removeKeywordsback to summary
public Optional<FieldChange> removeKeywords(KeywordList keywordsToRemove, Character keywordDelimiter)
replaceDownloadedFileback to summary
public void replaceDownloadedFile(String linkToDownloadedFile, LinkedFile downloadedFile)

Helper method to add a downloaded file to the entry.

Use-case: URL is contained in the file, the file is downloaded and should then replace the url. This method. adds the given path (as file) to the entry and removes the url.

Parameters
linkToDownloadedFile:String

the link to the file, which was downloaded

downloadedFile:LinkedFile

the path to be added to the entry

replaceKeywordsback to summary
public Optional<FieldChange> replaceKeywords(KeywordList keywordsToReplace, Keyword newValue, Character keywordDelimiter)
setChangedback to summary
public void setChanged(boolean changed)
setCitationKeyback to summary
public Optional<FieldChange> setCitationKey(String newKey)

Sets the citation key.

Note

This is not the internal Id of this entry. The internal Id is always present, whereas the citation key might not be present.

Parameters
newKey:String

The cite key to set. Must not be null; use clearCiteKey() to remove the cite key.

setCommentsBeforeEntryback to summary
public void setCommentsBeforeEntry(String parsedComments)
setDateback to summary
public void setDate(Date date)
setFieldback to summary
public void setField(Map<Field, String> fields)

Sets a number of fields simultaneously. The given HashMap contains field names as keys, each mapped to the value to set.

setFieldback to summary
public Optional<FieldChange> setField(Field field, String value, EntriesEventSource eventSource)

Set a field, and notify listeners about the change.

Parameters
field:Field

The field to set

value:String

The value to set

eventSource:EntriesEventSource

Source the event is sent from

setFieldback to summary
public Optional<FieldChange> setField(Field field, String value)

Set a field, and notify listeners about the change.

Parameters
field:Field

The field to set.

value:String

The value to set.

setFilesback to summary
public Optional<FieldChange> setFiles(List<LinkedFile> files)
setIdback to summary
public void setId(String id)

Sets this entry's identifier (ID).

The entry is also updated in the shared database - provided the database containing it doesn't veto the change.

Parameters
id:String

The ID to be used

Annotations
@VisibleForTesting
setMonthback to summary
public Optional<FieldChange> setMonth(Month parsedMonth)
setParsedSerializationback to summary
public void setParsedSerialization(String parsedSerialization)
setTypeback to summary
public Optional<FieldChange> setType(EntryType type)

Sets this entry's type.

setTypeback to summary
public Optional<FieldChange> setType(EntryType newType, EntriesEventSource eventSource)

Sets this entry's type and sets the changed flag to true
If the new entry type equals the old entry type no changed flag is set.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

This returns a canonical BibTeX serialization. Special characters such as "{" or "&" are NOT escaped, but written as is. In case the JabRef "hack" for distinguishing "field = value" and "field = {value}" (in .bib files) is used, it is output as "field = {#value#}", which may cause headaches in debugging. We nevertheless do it this way to a) enable debugging the internal representation and b) save time at this method.

Serializes all fields, even the JabRef internal ones. Does NOT serialize "KEY_FIELD" as field, but as key.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override
typePropertyback to summary
public ObjectProperty<EntryType> typeProperty()
unregisterListenerback to summary
public void unregisterListener(Object object)
withChangedback to summary
public BibEntry withChanged(boolean changed)

Required to trigger new serialization of the entry. Reason: We don't have a build() command, we don't want to create a new serialization at each call, we need to construct a BibEntry with changed=false (which is the default) and thus we need a workaround.

withCitationKeyback to summary
public BibEntry withCitationKey(String newKey)
withDateback to summary
public BibEntry withDate(Date date)
withFieldback to summary
public BibEntry withField(Field field, String value)
withFieldsback to summary
public BibEntry withFields(Map<Field, String> content)

A copy is made of the parameter

withFilesback to summary
public BibEntry withFiles(List<LinkedFile> files)
withMonthback to summary
public BibEntry withMonth(Month parsedMonth)
withSharedBibEntryDataback to summary
public BibEntry withSharedBibEntryData(int sharedId, int version)
withSharedBibEntryDataback to summary
public BibEntry withSharedBibEntryData(SharedBibEntryData sharedBibEntryData)
withUserCommentsback to summary
public BibEntry withUserComments(String commentsBeforeEntry)