Qt Jambi Home

com.trolltech.qt.sql
Class QSqlRecord

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.sql.QSqlRecord
All Implemented Interfaces:
QtJambiInterface
Direct Known Subclasses:
QSqlIndex

public class QSqlRecord
extends QtJambiObject

The QSqlRecord class encapsulates a database record.

The QSqlRecord class encapsulates the functionality and characteristics of a database record (usually a row in a table or view within the database). QSqlRecord supports adding and removing fields as well as setting and retrieving field values.

The values of a record's fields' can be set by name or position with setValue; if you want to set a field to null use setNull. To find the position of a field by name use indexOf, and to find the name of a field at a particular position use fieldName. Use field to retrieve a QSqlField object for a given field. Use contains to see if the record contains a particular field name.

When queries are generated to be executed on the database only those fields for which isGenerated is true are included in the generated SQL.

A record can have fields added with append or insert, replaced with replace, and removed with remove. All the fields can be removed with clear. The number of fields is given by count; all their values can be cleared (to null) using clearValues.

See Also:
QSqlField, QSqlQuery::record

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Constructor Summary
QSqlRecord()
          Constructs an empty record.
QSqlRecord(QSqlRecord other)
          Constructs a copy of other.
 
Method Summary
 void append(QSqlField field)
          Append a copy of field field to the end of the record.
 void clear()
          Removes all the record's fields.
 void clearValues()
          Clears the value of all fields in the record and sets each field to null.
 boolean contains(java.lang.String name)
          Returns true if there is a field in the record called name; otherwise returns false.
 int count()
          Returns the number of fields in the record.
 boolean equals(java.lang.Object other)
          
 QSqlField field(int i)
          Returns the field at position i.
 QSqlField field(java.lang.String name)
          Returns the field called name.
 java.lang.String fieldName(int i)
          Returns the name of the field at position i.
static QSqlRecord fromNativePointer(QNativePointer nativePointer)
          This function returns the QSqlRecord instance pointed to by nativePointer
 int indexOf(java.lang.String name)
          Returns the position of the field called name within the record, or -1 if it cannot be found.
 void insert(int pos, QSqlField field)
          Inserts the field field at position pos in the record.
 boolean isEmpty()
          Returns true if there are no fields in the record; otherwise returns false.
 boolean isGenerated(int i)
          Returns true if the record has a field at position i and this field is to be generated (the default); otherwise returns false.
 boolean isGenerated(java.lang.String name)
          Returns true if the record has a field called name and this field is to be generated (the default); otherwise returns false.
 boolean isNull(int i)
          Returns true if the field i is null or if there is no field at position i; otherwise returns false.
 boolean isNull(java.lang.String name)
          Returns true if the field called name is null or if there is no field called name; otherwise returns false.
static QNativePointer nativePointerArray(QSqlRecord[] array)
          This function returns a QNativePointer that is pointing to the specified QSqlRecord array.
 void remove(int pos)
          Removes the field at position pos.
 void replace(int pos, QSqlField field)
          Replaces the field at position pos with the given field.
 void setGenerated(int i, boolean generated)
          Sets the generated flag for the field i to generated.
 void setGenerated(java.lang.String name, boolean generated)
          Sets the generated flag for the field called name to generated.
 void setNull(int i)
          Sets the value of field i to null.
 void setNull(java.lang.String name)
          Sets the value of the field called name to null.
 void setValue(int i, java.lang.Object val)
          Sets the value of the field at position i to val.
 void setValue(java.lang.String name, java.lang.Object val)
          Sets the value of the field called name to val.
 java.lang.Object value(int i)
          Returns the value of the field located at position i in the record.
 java.lang.Object value(java.lang.String name)
          Returns the value of the field called name in the record.
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QSqlRecord

public QSqlRecord()

Constructs an empty record.

See Also:
isEmpty, append, insert

QSqlRecord

public QSqlRecord(QSqlRecord other)

Constructs a copy of other.

QSqlRecord is implicitly shared. This means you can make copies of a record in constant time.

Method Detail

append

public void append(QSqlField field)

Append a copy of field field to the end of the record.

See Also:
insert, replace, remove

clear

public final void clear()

Removes all the record's fields.

See Also:
clearValues, isEmpty

clearValues

public final void clearValues()

Clears the value of all fields in the record and sets each field to null.

See Also:
setValue

contains

public final boolean contains(java.lang.String name)

Returns true if there is a field in the record called name; otherwise returns false.


count

public final int count()

Returns the number of fields in the record.

See Also:
isEmpty

field

public final QSqlField field(int i)

Returns the field at position i. If the position is out of range, an empty field is returned.


field

public final QSqlField field(java.lang.String name)

Returns the field called name.


fieldName

public final java.lang.String fieldName(int i)

Returns the name of the field at position i. If the field does not exist, an empty string is returned.

See Also:
indexOf

indexOf

public final int indexOf(java.lang.String name)

Returns the position of the field called name within the record, or -1 if it cannot be found. Field names are not case-sensitive. If more than one field matches, the first one is returned.

See Also:
fieldName

insert

public final void insert(int pos,
                         QSqlField field)

Inserts the field field at position pos in the record.

See Also:
append, replace, remove

isEmpty

public final boolean isEmpty()

Returns true if there are no fields in the record; otherwise returns false.

See Also:
append, insert, clear

isGenerated

public final boolean isGenerated(java.lang.String name)

Returns true if the record has a field called name and this field is to be generated (the default); otherwise returns false.

See Also:
setGenerated

isGenerated

public final boolean isGenerated(int i)

Returns true if the record has a field at position i and this field is to be generated (the default); otherwise returns false.

See Also:
setGenerated

isNull

public final boolean isNull(java.lang.String name)

Returns true if the field called name is null or if there is no field called name; otherwise returns false.

See Also:
setNull

isNull

public final boolean isNull(int i)

Returns true if the field i is null or if there is no field at position i; otherwise returns false.


remove

public final void remove(int pos)

Removes the field at position pos. If pos is out of range, nothing happens.

See Also:
append, insert, replace

replace

public final void replace(int pos,
                          QSqlField field)

Replaces the field at position pos with the given field. If pos is out of range, nothing happens.

See Also:
append, insert, remove

setGenerated

public final void setGenerated(int i,
                               boolean generated)

Sets the generated flag for the field i to generated.

See Also:
isGenerated

setGenerated

public final void setGenerated(java.lang.String name,
                               boolean generated)

Sets the generated flag for the field called name to generated. If the field does not exist, nothing happens. Only fields that have generated set to true are included in the SQL that is generated by QSqlQueryModel for example.

See Also:
isGenerated

setNull

public final void setNull(int i)

Sets the value of field i to null. If the field does not exist, nothing happens.

See Also:
setValue

setNull

public final void setNull(java.lang.String name)

Sets the value of the field called name to null. If the field does not exist, nothing happens.

See Also:
isNull

setValue

public final void setValue(int i,
                           java.lang.Object val)

Sets the value of the field at position i to val. If the field does not exist, nothing happens.

See Also:
setNull

setValue

public final void setValue(java.lang.String name,
                           java.lang.Object val)

Sets the value of the field called name to val. If the field does not exist, nothing happens.

See Also:
value

value

public final java.lang.Object value(int i)

Returns the value of the field located at position i in the record. If i is out of bounds, an invalid QVariant is returned.

See Also:
fieldName, isNull

value

public final java.lang.Object value(java.lang.String name)

Returns the value of the field called name in the record. If field name does not exist an invalid variant is returned.

See Also:
setValue, indexOf

fromNativePointer

public static QSqlRecord fromNativePointer(QNativePointer nativePointer)
This function returns the QSqlRecord instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

nativePointerArray

public static QNativePointer nativePointerArray(QSqlRecord[] array)
This function returns a QNativePointer that is pointing to the specified QSqlRecord array.

Parameters:
array - the array that the returned pointer will point to.
Returns:
a QNativePointer that is pointing to the specified array.

equals

public boolean equals(java.lang.Object other)

Overrides:
equals in class java.lang.Object

Qt Jambi Home