Package com.aoindustries.aoserv.client
Class AOServObject<K,T extends AOServObject<K,T>>
- java.lang.Object
-
- com.aoindustries.aoserv.client.AOServObject<K,T>
-
- All Implemented Interfaces:
Streamable,StreamReadable,StreamWritable,Row,AOServReadable,AOServStreamable,AOServWritable
- Direct Known Subclasses:
BackupReport,BankTransaction,CachedObject,FileReplicationLog,FilesystemCachedObject,GlobalObject,Process,ServerStat,SpamMessage
public abstract class AOServObject<K,T extends AOServObject<K,T>> extends Object implements Row, AOServStreamable
AnAOServObjectis the lowest level object for all data in the system. EachAOServObjectbelongs to aAOServTable, and each table containsAOServObjects.- Author:
- AO Industries, Inc.
- See Also:
AOServTable
-
-
Field Summary
Fields Modifier and Type Field Description static booleanUSE_ARRAY_OF_DOMAINEnables the use of arrays of domains.static booleanUSE_SQL_DATAEnables the use ofSQLData.static booleanUSE_SQL_DATA_WRITEEnables the use ofSQLDataon writeObject.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAOServObject()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static intcompare(int i1, int i2)Deprecated.This method moved toComparatorUtils.compare(int, int)static intcompare(long l1, long l2)Deprecated.This method moved toComparatorUtils.compare(long, long)static intcompare(short s1, short s2)Deprecated.This method moved toComparatorUtils.compare(short, short)static <T extends Comparable<T>>
intcompare(T obj1, T obj2)Compares two objects allowing for nulls, sorts non-null before null.static intcompareIgnoreCaseConsistentWithEquals(String s1, String s2)Deprecated.intcompareTo(AOServConnector conn, AOServObject<?,?> other, SQLExpression[] sortExpressions, boolean[] sortOrders)intcompareTo(AOServConnector conn, Comparable<?> value, SQLExpression[] sortExpressions, boolean[] sortOrders)intcompareTo(AOServConnector conn, Object[] OA, SQLExpression[] sortExpressions, boolean[] sortOrders)booleanequals(Object O)protected static Account.NamegetAccountingCode(AccountName accounting)null-safe accounting code conversion.ObjectgetColumn(int i)protected abstract ObjectgetColumnImpl(int i)List<Object>getColumns(AOServConnector connector)intgetColumns(AOServConnector connector, List<Object> buff)protected static DomainLabelgetDomainLabel(DomainLabel domainLabel)null-safe domain label conversion.protected static DomainLabelsgetDomainLabels(DomainLabels domainLabels)null-safe domain labels conversion.protected static DomainNamegetDomainName(DomainName domainName)null-safe domain name conversion.protected static <B> BgetDto(DtoFactory<B> dtoFactory)null-safe getDto.protected static EmailgetEmail(Email email)null-safe email conversion.protected static User.GecosgetGecos(Gecos gecos)null-safe GECOS conversion.protected static Group.NamegetGroupId(LinuxGroupName gid)null-safe group id conversion.protected static HashedKeygetHashedKey(HashedKey hashedKey)null-safe hashed key conversion.protected static HashedPasswordgetHashedPassword(HashedPassword hashedPassword)null-safe hashed password conversion.protected static HostAddressgetHostname(HostAddress hostname)null-safe hostname conversion.protected static InetAddressgetInetAddress(InetAddress inetAddress)null-safe inet address conversion.abstract KgetKey()protected static LinuxIdgetLinuxID(LinuxId lid)null-safe Linux id conversion.protected static User.NamegetLinuxUserName(LinuxUserName linuxUserName)null-safe Linux user name conversion.protected static MacAddressgetMacAddress(MacAddress macAddress)null-safe MAC address conversion.protected static Database.NamegetMySQLDatabaseName(MySQLDatabaseName databaseName)null-safe MySQL database name conversion.protected static Server.NamegetMySQLServerName(MySQLServerName serverName)null-safe MySQL server name conversion.protected static User.NamegetMysqlUserName(MySQLUserName mysqlUserId)null-safe MySQL user name conversion.protected static PortgetPort(Port port)null-safe port conversion.protected static Database.NamegetPostgresDatabaseName(PostgresDatabaseName databaseName)null-safe PostgreSQL database name conversion.protected static Server.NamegetPostgresServerName(PostgresServerName serverName)null-safe PostgreSQL server name conversion.protected static User.NamegetPostgresUserId(PostgresUserName postgresUserId)null-safe PostgreSQL user id conversion.abstract Table.TableIDgetTableID()TablegetTableSchema(AOServConnector connector)protected static LonggetTimeMillis(Calendar datetime)null-safe conversion from Calendar to Long.protected static LonggetTimeMillis(Date date)null-safe conversion from Date to Long.protected static PosixPathgetUnixPath(PosixPath unixPath)null-safe Unix path conversion.protected static User.NamegetUserId(UserName userId)null-safe user id conversion.inthashCode()abstract voidinit(ResultSet results)Initializes this object from the raw database contents.abstract voidread(StreamableInput in, AoservProtocol.Version protocolVersion)voidread(StreamableInput in, String protocolVersion)Deprecated.This is maintained only for compatibility with theStreamableinterface.StringtoString()StringtoStringImpl()toString()implementation that is allowed to throw exceptions.abstract voidwrite(StreamableOutput out, AoservProtocol.Version protocolVersion)voidwrite(StreamableOutput out, String protocolVersion)Deprecated.This is maintained only for compatibility with theStreamableinterface.
-
-
-
Field Detail
-
USE_SQL_DATA
public static final boolean USE_SQL_DATA
Enables the use ofSQLData. This currently requires our forked PostgreSQL JDBC driver to function correctly. See Issue #641 for more details.- See Also:
- Constant Field Values
-
USE_SQL_DATA_WRITE
public static final boolean USE_SQL_DATA_WRITE
Enables the use ofSQLDataon writeObject. This currently requires our forked PostgreSQL JDBC driver to function correctly. See Pull request #1377 for more details.- See Also:
- Constant Field Values
-
USE_ARRAY_OF_DOMAIN
public static final boolean USE_ARRAY_OF_DOMAIN
Enables the use of arrays of domains. This is currently not supported by PostgreSQL.- See Also:
- Constant Field Values
-
-
Method Detail
-
compareIgnoreCaseConsistentWithEquals
@Deprecated public static int compareIgnoreCaseConsistentWithEquals(String s1, String s2)
Deprecated.
-
compare
@Deprecated public static int compare(int i1, int i2)
Deprecated.This method moved toComparatorUtils.compare(int, int)
-
compare
@Deprecated public static int compare(short s1, short s2)
Deprecated.This method moved toComparatorUtils.compare(short, short)
-
compare
@Deprecated public static int compare(long l1, long l2)
Deprecated.This method moved toComparatorUtils.compare(long, long)
-
compare
public static <T extends Comparable<T>> int compare(T obj1, T obj2)
Compares two objects allowing for nulls, sorts non-null before null.
-
compareTo
public final int compareTo(AOServConnector conn, AOServObject<?,?> other, SQLExpression[] sortExpressions, boolean[] sortOrders) throws IllegalArgumentException, SQLException, UnknownHostException, IOException
-
compareTo
public final int compareTo(AOServConnector conn, Comparable<?> value, SQLExpression[] sortExpressions, boolean[] sortOrders) throws IllegalArgumentException, SQLException, UnknownHostException, IOException
-
compareTo
public final int compareTo(AOServConnector conn, Object[] OA, SQLExpression[] sortExpressions, boolean[] sortOrders) throws IllegalArgumentException, SQLException, UnknownHostException, IOException
-
getDto
protected static <B> B getDto(DtoFactory<B> dtoFactory)
null-safe getDto.
-
getAccountingCode
protected static Account.Name getAccountingCode(AccountName accounting) throws ValidationException
null-safe accounting code conversion.- Throws:
ValidationException
-
getDomainLabel
protected static DomainLabel getDomainLabel(DomainLabel domainLabel) throws ValidationException
null-safe domain label conversion.- Throws:
ValidationException
-
getDomainLabels
protected static DomainLabels getDomainLabels(DomainLabels domainLabels) throws ValidationException
null-safe domain labels conversion.- Throws:
ValidationException
-
getDomainName
protected static DomainName getDomainName(DomainName domainName) throws ValidationException
null-safe domain name conversion.- Throws:
ValidationException
-
getEmail
protected static Email getEmail(Email email) throws ValidationException
null-safe email conversion.- Throws:
ValidationException
-
getGecos
protected static User.Gecos getGecos(Gecos gecos) throws ValidationException
null-safe GECOS conversion.- Throws:
ValidationException
-
getGroupId
protected static Group.Name getGroupId(LinuxGroupName gid) throws ValidationException
null-safe group id conversion.- Throws:
ValidationException
-
getHashedKey
protected static HashedKey getHashedKey(HashedKey hashedKey) throws ValidationException
null-safe hashed key conversion.- Throws:
ValidationException
-
getHashedPassword
protected static HashedPassword getHashedPassword(HashedPassword hashedPassword) throws ValidationException
null-safe hashed password conversion.- Throws:
ValidationException
-
getHostname
protected static HostAddress getHostname(HostAddress hostname) throws ValidationException
null-safe hostname conversion.- Throws:
ValidationException
-
getInetAddress
protected static InetAddress getInetAddress(InetAddress inetAddress) throws ValidationException
null-safe inet address conversion.- Throws:
ValidationException
-
getLinuxID
protected static LinuxId getLinuxID(LinuxId lid) throws ValidationException
null-safe Linux id conversion.- Throws:
ValidationException
-
getLinuxUserName
protected static User.Name getLinuxUserName(LinuxUserName linuxUserName) throws ValidationException
null-safe Linux user name conversion.- Throws:
ValidationException
-
getMacAddress
protected static MacAddress getMacAddress(MacAddress macAddress) throws ValidationException
null-safe MAC address conversion.- Throws:
ValidationException
-
getMySQLDatabaseName
protected static Database.Name getMySQLDatabaseName(MySQLDatabaseName databaseName) throws ValidationException
null-safe MySQL database name conversion.- Throws:
ValidationException
-
getMySQLServerName
protected static Server.Name getMySQLServerName(MySQLServerName serverName) throws ValidationException
null-safe MySQL server name conversion.- Throws:
ValidationException
-
getMysqlUserName
protected static User.Name getMysqlUserName(MySQLUserName mysqlUserId) throws ValidationException
null-safe MySQL user name conversion.- Throws:
ValidationException
-
getPort
protected static Port getPort(Port port) throws ValidationException
null-safe port conversion.- Throws:
ValidationException
-
getPostgresDatabaseName
protected static Database.Name getPostgresDatabaseName(PostgresDatabaseName databaseName) throws ValidationException
null-safe PostgreSQL database name conversion.- Throws:
ValidationException
-
getPostgresServerName
protected static Server.Name getPostgresServerName(PostgresServerName serverName) throws ValidationException
null-safe PostgreSQL server name conversion.- Throws:
ValidationException
-
getPostgresUserId
protected static User.Name getPostgresUserId(PostgresUserName postgresUserId) throws ValidationException
null-safe PostgreSQL user id conversion.- Throws:
ValidationException
-
getTimeMillis
protected static Long getTimeMillis(Date date)
null-safe conversion from Date to Long.
-
getTimeMillis
protected static Long getTimeMillis(Calendar datetime)
null-safe conversion from Calendar to Long.
-
getUnixPath
protected static PosixPath getUnixPath(PosixPath unixPath) throws ValidationException
null-safe Unix path conversion.- Throws:
ValidationException
-
getUserId
protected static User.Name getUserId(UserName userId) throws ValidationException
null-safe user id conversion.- Throws:
ValidationException
-
equals
public boolean equals(Object O)
Implementation Note:
This default implementation considers the object equal when it is the same class (viaObject.getClass()and has equal keys (viagetKey()).
-
getColumnImpl
protected abstract Object getColumnImpl(int i) throws IOException, SQLException
- Throws:
IOExceptionSQLException
-
getColumns
public final List<Object> getColumns(AOServConnector connector) throws IOException, SQLException
- Throws:
IOExceptionSQLException
-
getColumns
public final int getColumns(AOServConnector connector, List<Object> buff) throws IOException, SQLException
- Throws:
IOExceptionSQLException
-
getKey
public abstract K getKey()
-
getTableID
public abstract Table.TableID getTableID()
-
getTableSchema
public final Table getTableSchema(AOServConnector connector) throws IOException, SQLException
- Throws:
IOExceptionSQLException
-
hashCode
public int hashCode()
Implementation Note:
This default implementation callshashCode()on the key (fromgetKey()).
-
init
public abstract void init(ResultSet results) throws SQLException
Initializes this object from the raw database contents.- Parameters:
results- theResultSetcontaining the row to copy into this object- Throws:
SQLException
-
read
@Deprecated public final void read(StreamableInput in, String protocolVersion) throws IOException
Deprecated.This is maintained only for compatibility with theStreamableinterface.- Specified by:
readin interfaceAOServStreamable- Specified by:
readin interfaceStreamable- Specified by:
readin interfaceStreamReadable- Throws:
IOException- See Also:
read(StreamableInput,com.aoindustries.aoserv.client.schema.AoservProtocol.Version)
-
read
public abstract void read(StreamableInput in, AoservProtocol.Version protocolVersion) throws IOException
- Specified by:
readin interfaceAOServReadable- Specified by:
readin interfaceAOServStreamable- Throws:
IOException
-
toString
public final String toString()
Implementation Note:
This default implementation callstoStringImpl(), which is allowed to throw exceptions.- Overrides:
toStringin classObject- Throws:
WrappedException- whentoStringImpl()throws an exception- See Also:
toStringImpl()
-
toStringImpl
public String toStringImpl() throws IOException, SQLException
toString()implementation that is allowed to throw exceptions.Implementation Note:
This default implementation callstoString()on the key (fromgetKey()). When the key isnull, uses the default implementation fromObject.toString().- Throws:
IOExceptionSQLException
-
write
@Deprecated public final void write(StreamableOutput out, String protocolVersion) throws IOException
Deprecated.This is maintained only for compatibility with theStreamableinterface.- Specified by:
writein interfaceAOServStreamable- Specified by:
writein interfaceStreamable- Specified by:
writein interfaceStreamWritable- Throws:
IOException- See Also:
write(StreamableOutput,com.aoindustries.aoserv.client.schema.AoservProtocol.Version)
-
write
public abstract void write(StreamableOutput out, AoservProtocol.Version protocolVersion) throws IOException
- Specified by:
writein interfaceAOServStreamable- Specified by:
writein interfaceAOServWritable- Throws:
IOException
-
-