public final class Database
extends java.lang.Object
implements java.io.Serializable
null
.
Instances of this class are used extensively in the persistence framework as tokens to access additional information that is database specific.
Modifier and Type | Class and Description |
---|---|
static class |
Database.Type
Type/purpose of database
|
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
id
Unique ID of database, based on physical name
|
private java.lang.Boolean |
local
Is this database managed by the local P2J server instance?
|
private java.lang.String |
name
Physical name of database
|
private java.net.InetSocketAddress |
socketAddress
Socket address of P2J server which is authoritative for database
|
private Database.Type |
type
Database type/purpose
|
Constructor and Description |
---|
Database(Database database,
Database.Type type)
Convenience constructor which copies an existing instance, but applies a new type.
|
Database(java.lang.String name)
Constructor which accepts the physical database name and assumes a type of primary.
|
Database(java.lang.String name,
Database.Type type)
Constructor which accepts the physical database name and a type.
|
Database(java.lang.String name,
Database.Type type,
boolean local)
Package-private constructor which accepts the physical database name
and an indication as to whether this database is locally managed.
|
Database(java.lang.String name,
Database.Type type,
java.lang.String host,
int port)
Constructor which accepts the physical database name, type, host name/address, and port
number.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o)
Test this object for equality (equivalence) with the given object.
|
java.lang.String |
getId()
Get the unique id of this database.
|
java.lang.String |
getName()
Get the physical database name.
|
java.net.InetSocketAddress |
getSocketAddress()
Get the host address (including port number) of the P2J server instance
which is authoritative for the database instance represented by this
object.
|
Database.Type |
getType()
Get the type/purpose of this database.
|
int |
hashCode()
Calculate a hash code for this object.
|
boolean |
isDirty()
Get the dirty status of this database.
|
boolean |
isLocal()
Indicate whether the current P2J server instance is authoritative for
the database instance represented by this object.
|
boolean |
isMeta()
Get the dirty status of this database.
|
boolean |
isPrimary()
Get the primary status of this database.
|
java.lang.String |
toString()
Produce a string representation of the internal state of this object.
|
private final java.lang.String name
private final java.lang.String id
private final Database.Type type
private java.net.InetSocketAddress socketAddress
private java.lang.Boolean local
public Database(java.lang.String name)
name
- Physical name of database. May not be null
.public Database(java.lang.String name, Database.Type type)
name
- Physical name of database. May not be null
.type
- Type/purpose of the database.public Database(Database database, Database.Type type)
database
- Database to be copied. May not be null
.type
- Type/purpose of the copy database.public Database(java.lang.String name, Database.Type type, java.lang.String host, int port)
name
- Physical name of database. May not be null
.type
- Type/purpose of the database.host
- Host name or address of P2J server which is authoritative for
database. null
indicates host is not relevant.port
- Port of P2J server which is authoritative for database.
-1 indicates port is unknown. May not be less than -1 or
greater than 65535.Database(java.lang.String name, Database.Type type, boolean local)
This constructor is intended for use by other framework classes which
must ensure that the determination of whether this class is locally
managed is not deferred until lazily initialized by the isLocal()
method.
name
- Physical name of database. May not be null
.local
- true
to indicate database is locally managed, else
false
.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- Object to test.true
if this object is the same instance as the
given object, or it is considered equivalent to the given
object. Database
instances are equivalent if
they contain the same database name and P2J server address.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getName()
public java.lang.String getId()
public java.net.InetSocketAddress getSocketAddress()
public boolean isLocal()
true
if the current P2J server instance is
authoritative; false
if this database is
controlled by a remote P2J server instance. Note that "remote"
and "local" are logical concepts and have nothing to do with
the physical location of the database or P2J server instance.public Database.Type getType()
public boolean isPrimary()
public boolean isDirty()
public boolean isMeta()