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

public Class BstVM

extends Object
Class Inheritance
Annotations
@NullMarked
Imports
java.io.IOException, java.nio.file.Path, java.util.List, java.util.stream.Collectors, org.jabref.model.database.BibDatabase, org.jabref.model.entry.BibEntry, com.google.common.annotations.VisibleForTesting, org.antlr.v4.runtime.BailErrorStrategy, .BaseErrorListener, .CharStream, .CharStreams, .CommonTokenStream, .RecognitionException, .Recognizer, org.antlr.v4.runtime.misc.ParseCancellationException, org.antlr.v4.runtime.tree.ParseTree, org.jspecify.annotations.NullMarked, .Nullable

Parsed executable program of one specific .bst file.

BstVM cannot be used as a static, style-agnostic machine because each instance holds the parse tree of one concrete .bst program. It also keeps the latest execution context for testing/debugging, so callers should treat it as style-specific runtime state rather than a global utility.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
protected static final Integer
private @Nullable BstVMContext
private @Nullable Path
protected final ParseTree
protected static final Integer

Constructor Summary

AccessConstructor and Description
public
BstVM(Path path)

public
protected
private

Method Summary

Modifier and TypeMethod and Description
private static ParseTree
private boolean
pack-priv BstVMContext
public boolean
public String

Returns:

list of references in plain text form
render
(List<BibEntry>
list of entries to convert
bibEntries
,
BibDatabase
the bibDatabase used for resolving strings / crossref
bibDatabase
)

Transforms the given list of BibEntries to a rendered list of references using the parsed bst program

public String
render(List<BibEntry> bibEntries)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FALSEback to summary
protected static final Integer FALSE
latestContextback to summary
private @Nullable BstVMContext latestContext
pathback to summary
private @Nullable Path path
treeback to summary
protected final ParseTree tree
TRUEback to summary
protected static final Integer TRUE

Constructor Detail

BstVMback to summary
public BstVM(Path path) throws RecognitionException, IOException
BstVMback to summary
public BstVM(String s) throws RecognitionException
BstVMback to summary
protected BstVM(CharStream bst) throws RecognitionException
BstVMback to summary
private BstVM(ParseTree tree)

Method Detail

charStream2CommonTreeback to summary
private static ParseTree charStream2CommonTree(CharStream query)
containsSortCommandback to summary
private boolean containsSortCommand(ParseTree parseTree)
getContextback to summary
pack-priv BstVMContext getContext()
Annotations
@VisibleForTesting
hasSortCommandback to summary
public boolean hasSortCommand()
renderback to summary
public String render(List<BibEntry> bibEntries, BibDatabase bibDatabase)

Transforms the given list of BibEntries to a rendered list of references using the parsed bst program

Parameters
bibEntries:List<BibEntry>

list of entries to convert

bibDatabase:BibDatabase

the bibDatabase used for resolving strings / crossref

Returns:String

list of references in plain text form

renderback to summary
public String render(List<BibEntry> bibEntries)
org.jabref.logic.bst back to summary

private Class BstVM.ThrowingErrorListener

extends BaseErrorListener
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final BstVM.ThrowingErrorListener

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e)

Overrides org.antlr.v4.runtime.BaseErrorListener.syntaxError.

Implements org.antlr.v4.runtime.ANTLRErrorListener.syntaxError.

Upon syntax error, notify any interested parties.

Inherited from org.antlr.v4.runtime.BaseErrorListener:
reportAmbiguityreportAttemptingFullContextreportContextSensitivity

Field Detail

INSTANCEback to summary
public static final BstVM.ThrowingErrorListener INSTANCE

Constructor Detail

ThrowingErrorListenerback to summary
private ThrowingErrorListener()

Method Detail

syntaxErrorback to summary
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) throws ParseCancellationException

Overrides org.antlr.v4.runtime.BaseErrorListener.syntaxError.

Implements org.antlr.v4.runtime.ANTLRErrorListener.syntaxError.

Doc from org.antlr.v4.runtime.ANTLRErrorListener.syntaxError.

Upon syntax error, notify any interested parties. This is not how to recover from errors or compute error messages. ANTLRErrorStrategy specifies how to recover from syntax errors and how to compute error messages. This listener's job is simply to emit a computed message, though it has enough information to create its own message in many cases.

The RecognitionException is non-null for all syntax errors except when we discover mismatched token errors that we can recover from in-line, without returning from the surrounding rule (via the single token insertion and deletion mechanism).

Annotations
@Override