Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.shared

public final Record DBMSConnectionUrl

extends Record
Class Inheritance
Annotations
@NullMarked
Record Components
type:DBMSType 
host:String 
port:int 
database:String 
user:Optional<String> 
password:Optional<String> 
useSSL:boolean 
query:String
the query part without user, password, ssl, and sslmode=require, which map to dedicated settings; empty if none
Imports
java.net.URI, .URISyntaxException, .URLDecoder, .URLEncoder, java.nio.charset.StandardCharsets, java.util.ArrayList, .List, .Locale, .Map, .Optional, .Set, java.util.regex.Matcher, .Pattern, org.jabref.logic.util.strings.StringUtil, org.jspecify.annotations.NullMarked, .Nullable

A PostgreSQL connection URL as handed out by hosting providers or used with JDBC, e.g. postgres://user:secret@host:5432/db?sslmode=require or jdbc:postgresql://host/db?user=me. Surrounding text is ignored, so a whole psql 'postgres://…' command line can be pasted as well, and so can libpq's keyword form (host=… port=… dbname=… user=… password=…).

Field Summary

Modifier and TypeField and Description
private final String
database

Record Component accessed by database().

private final String
host

Record Component accessed by host().

private final Optional<String>
password

Record Component accessed by password().

private final int
port

Record Component accessed by port().

private final String
query

Record Component accessed by query().

the query part without user, password, ssl, and sslmode=require, which map to dedicated settings; empty if none
private static final Set<String>
private final DBMSType
type

Record Component accessed by type().

private static final Pattern
private final Optional<String>
user

Record Component accessed by user().

private final boolean
useSSL

Record Component accessed by useSSL().

Constructor Summary

AccessConstructor and Description
public
DBMSConnectionUrl(DBMSType type, String host, int port, String database, Optional<String> user, Optional<String> password, boolean useSSL, String query)

Method Summary

Modifier and TypeMethod and Description
public String
database()

Record Component getter of database.

private static String
private static String
encode(String value)

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

private static DBMSConnectionUrl
fromParts(String host, Optional<Integer> port, String database, List<Map.Entry<String, String>> parameters)

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public String
host()

Record Component getter of host.

public static Optional<DBMSConnectionUrl>
private static Optional<DBMSConnectionUrl>
parseKeywords(String text)

libpq keyword form as shown by some providers: host=db.example.org port=5432 dbname=lib user=me password='p w'.

private static Optional<Integer>
private static Optional<DBMSConnectionUrl>
public Optional<String>
password()

Record Component getter of password.

public int
port()

Record Component getter of port.

public String
query()

Record Component getter of query.

Record Component the query part without user, password, ssl, and sslmode=require, which map to dedicated settings; empty if none

private static int
skipWhitespace(String text, int position)

public String
toJdbcUrl()

The URL for the JDBC driver, keeping every parameter JabRef has no dedicated setting for.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public DBMSType
type()

Record Component getter of type.

public Optional<String>
user()

Record Component getter of user.

public boolean
useSSL()

Record Component getter of useSSL.

Field Detail

databaseback to summary
private final String database

Record Component accessed by database().

hostback to summary
private final String host

Record Component accessed by host().

passwordback to summary
private final Optional<String> password

Record Component accessed by password().

portback to summary
private final int port

Record Component accessed by port().

queryback to summary
private final String query

Record Component accessed by query().

the query part without user, password, ssl, and sslmode=require, which map to dedicated settings; empty if none

SSL_MODES_REQUIRING_SSLback to summary
private static final Set<String> SSL_MODES_REQUIRING_SSL
typeback to summary
private final DBMSType type

Record Component accessed by type().

URL_IN_TEXTback to summary
private static final Pattern URL_IN_TEXT
userback to summary
private final Optional<String> user

Record Component accessed by user().

useSSLback to summary
private final boolean useSSL

Record Component accessed by useSSL().

Constructor Detail

DBMSConnectionUrlback to summary
public DBMSConnectionUrl(DBMSType type, String host, int port, String database, Optional<String> user, Optional<String> password, boolean useSSL, String query)

Method Detail

databaseback to summary
public String database()

Record Component getter of database.

decodeback to summary
private static String decode(String raw)
encodeback to summary
private static String encode(String value)
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).
fromPartsback to summary
private static DBMSConnectionUrl fromParts(String host, Optional<Integer> port, String database, List<Map.Entry<String, String>> parameters)
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.

hostback to summary
public String host()

Record Component getter of host.

parseback to summary
public static Optional<DBMSConnectionUrl> parse(@Nullable String text)
parseKeywordsback to summary
private static Optional<DBMSConnectionUrl> parseKeywords(String text)

libpq keyword form as shown by some providers: host=db.example.org port=5432 dbname=lib user=me password='p w'. Hand-written instead of a regex: a repeated alternation recurses per character in Java's regex engine and overflows the stack on long pastes.

parsePortback to summary
private static Optional<Integer> parsePort(String value)
parseUrlback to summary
private static Optional<DBMSConnectionUrl> parseUrl(String url)
passwordback to summary
public Optional<String> password()

Record Component getter of password.

portback to summary
public int port()

Record Component getter of port.

queryback to summary
public String query()

Record Component getter of query.

Record Component
the query part without user, password, ssl, and sslmode=require, which map to dedicated settings; empty if none
skipWhitespaceback to summary
private static int skipWhitespace(String text, int position)
toJdbcUrlback to summary
public String toJdbcUrl()

The URL for the JDBC driver, keeping every parameter JabRef has no dedicated setting for.

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.

typeback to summary
public DBMSType type()

Record Component getter of type.

userback to summary
public Optional<String> user()

Record Component getter of user.

useSSLback to summary
public boolean useSSL()

Record Component getter of useSSL.