Verified Owner
Top Description Inners Fields Constructors Methods
org.jabref.logic.pseudonymization

public Class Pseudonymization

extends Object
Class Inheritance
Annotations
@NullMarked
Imports
java.util.ArrayList, .HashMap, .List, .Locale, .Map, .Optional, org.jabref.model.database.BibDatabase, .BibDatabaseContext, org.jabref.model.entry.BibEntry, .Keyword, .KeywordList, org.jabref.model.entry.field.Field, .StandardField, org.jabref.model.groups.AbstractGroup, .GroupTreeNode, org.jspecify.annotations.NullMarked

This class is used to anonymize a library. It is required to make private libraries available for public use.

For "just" generating large .bib files, scripts/bib-file-generator.py can be used.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record
public static record

Field Summary

Modifier and TypeField and Description
private static final String
private final Character

Constructor Summary

AccessConstructor and Description
public
Pseudonymization(Character keywordSeparator)

Method Summary

Modifier and TypeMethod and Description
private List<BibEntry>
pseudonymizeEntries(BibDatabaseContext bibDatabaseContext, Map<Field, Map<String, Integer>>
map containing the mapping from field to value to id, will be filled by this method
fieldToValueToIdMap
,
Map<String, String> groupNameMapping, Map<String, String> valueMapping)

private String
pseudonymizeGroupsField(String fieldContent, Map<String, String> groupNameMapping, Map<String, String> valueMapping)

Pseudonymizes the StandardField#GROUPS field content.

private static Pseudonymization.GroupTreeResult
pseudonymizeGroupTree(GroupTreeNode node, Map<String, String> valueMapping, Map<String, String> groupNameMapping, int counter)

public Pseudonymization.Result
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

GROUP_PREFIXback to summary
private static final String GROUP_PREFIX
keywordSeparatorback to summary
private final Character keywordSeparator

Constructor Detail

Pseudonymizationback to summary
public Pseudonymization(Character keywordSeparator)

Method Detail

pseudonymizeEntriesback to summary
private List<BibEntry> pseudonymizeEntries(BibDatabaseContext bibDatabaseContext, Map<Field, Map<String, Integer>> fieldToValueToIdMap, Map<String, String> groupNameMapping, Map<String, String> valueMapping)
Parameters
fieldToValueToIdMap:Map<Field, Map<String, Integer>>

map containing the mapping from field to value to id, will be filled by this method

pseudonymizeGroupsFieldback to summary
private String pseudonymizeGroupsField(String fieldContent, Map<String, String> groupNameMapping, Map<String, String> valueMapping)

Pseudonymizes the StandardField#GROUPS field content. Groups not present in the group tree are also pseudonymized.

pseudonymizeGroupTreeback to summary
private static Pseudonymization.GroupTreeResult pseudonymizeGroupTree(GroupTreeNode node, Map<String, String> valueMapping, Map<String, String> groupNameMapping, int counter)
pseudonymizeLibraryback to summary
public Pseudonymization.Result pseudonymizeLibrary(BibDatabaseContext bibDatabaseContext)
org.jabref.logic.pseudonymization back to summary

private final Record Pseudonymization.GroupTreeResult

extends Record
Class Inheritance
Record Components
node:GroupTreeNode 
counter:int 

Field Summary

Modifier and TypeField and Description
private final int
counter

Record Component accessed by counter().

private final GroupTreeNode
node

Record Component accessed by node().

Constructor Summary

AccessConstructor and Description
private
GroupTreeResult(GroupTreeNode node, int counter)

Method Summary

Modifier and TypeMethod and Description
public int
counter()

Record Component getter of counter.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public GroupTreeNode
node()

Record Component getter of node.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

counterback to summary
private final int counter

Record Component accessed by counter().

nodeback to summary
private final GroupTreeNode node

Record Component accessed by node().

Constructor Detail

GroupTreeResultback to summary
private GroupTreeResult(GroupTreeNode node, int counter)

Method Detail

counterback to summary
public int counter()

Record Component getter of counter.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

nodeback to summary
public GroupTreeNode node()

Record Component getter of node.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

org.jabref.logic.pseudonymization back to summary

public final Record Pseudonymization.Result

extends Record
Class Inheritance
Record Components
bibDatabaseContext:BibDatabaseContext 
valueMapping:Map<String, String> 

Field Summary

Modifier and TypeField and Description
private final BibDatabaseContext
bibDatabaseContext

Record Component accessed by bibDatabaseContext().

private final Map<String, String>
valueMapping

Record Component accessed by valueMapping().

Constructor Summary

AccessConstructor and Description
public
Result(BibDatabaseContext bibDatabaseContext, Map<String, String> valueMapping)

Method Summary

Modifier and TypeMethod and Description
public BibDatabaseContext
bibDatabaseContext()

Record Component getter of bibDatabaseContext.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public Map<String, String>
valueMapping()

Record Component getter of valueMapping.

Field Detail

bibDatabaseContextback to summary
private final BibDatabaseContext bibDatabaseContext

Record Component accessed by bibDatabaseContext().

valueMappingback to summary
private final Map<String, String> valueMapping

Record Component accessed by valueMapping().

Constructor Detail

Resultback to summary
public Result(BibDatabaseContext bibDatabaseContext, Map<String, String> valueMapping)

Method Detail

bibDatabaseContextback to summary
public BibDatabaseContext bibDatabaseContext()

Record Component getter of bibDatabaseContext.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

valueMappingback to summary
public Map<String, String> valueMapping()

Record Component getter of valueMapping.