Qt Jambi Home

com.trolltech.qt.xml
Class QXmlStreamAttributes

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.xml.QXmlStreamAttributes
All Implemented Interfaces:
QtJambiInterface

public class QXmlStreamAttributes
extends QtJambiObject

The QXmlStreamAttributes class represents a vector of QXmlStreamAttribute.

Attributes are returned by a QXmlStreamReader in attributes() when the reader reports a start element. The class can also be used with a QXmlStreamWriter as an argument to writeAttributes().

The convenience function value loops over the vector and returns an attribute value for a given namespaceUri and an attribute's name.

New attributes can be added with append.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
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
QXmlStreamAttributes()
          Creates a new QXmlStreamAttributes object.
 
Method Summary
 void append(QXmlStreamAttribute attribute)
          Appends the given attribute to the end of the vector.
 void append(java.lang.String qualifiedName, java.lang.String value)
          Appends a new attribute with qualified name qualifiedName and value value.
 void append(java.lang.String namespaceUri, java.lang.String name, java.lang.String value)
          Appends a new attribute with name in the namespace described with namespaceUri, and value value.
 QXmlStreamAttribute at(int i)
          Returns the item at index position i in the vector.
 int capacity()
          Returns the maximum number of items that can be stored in the vector without forcing a reallocation.
 void clear()
          Removes all the elements from the vector.
 boolean contains(QXmlStreamAttribute t)
          Returns true if the vector contains an occurrence of t; otherwise returns false.
 int count()
          Same as size.
 int count(QXmlStreamAttribute t)
          Returns the number of occurrences of t in the vector.
 boolean empty()
          This function is provided for STL compatibility.
 boolean equals(java.lang.Object other)
          
 java.util.List<QXmlStreamAttribute> fill(QXmlStreamAttribute t, int size)
          Assigns t to all items in the vector.
 QXmlStreamAttribute first()
          
static java.util.List<QXmlStreamAttribute> fromList(java.util.List<QXmlStreamAttribute> list)
          Returns a QVector object with the data contained in list.
static QXmlStreamAttributes fromNativePointer(QNativePointer nativePointer)
          This function returns the QXmlStreamAttributes instance pointed to by nativePointer
 int indexOf(QXmlStreamAttribute t, int from)
          Returns the index position of the first occurrence of t in the vector, searching forward from index position from.
 boolean isEmpty()
          Returns true if the vector has size 0; otherwise returns false.
 QXmlStreamAttribute last()
          
 int lastIndexOf(QXmlStreamAttribute t, int from)
          Returns the index position of the last occurrence of the value t in the vector, searching backward from index position from.
 java.util.List<QXmlStreamAttribute> mid(int pos, int length)
          Returns a vector whose elements are copied from this vector, starting at position pos.
static QNativePointer nativePointerArray(QXmlStreamAttributes[] array)
          This function returns a QNativePointer that is pointing to the specified QXmlStreamAttributes array.
 void prepend(QXmlStreamAttribute t)
          Inserts t at the beginning of the vector.
 void remove(int i)
          Removes the element at index position i.
 void remove(int i, int n)
          Removes n elements from the middle of the vector, starting at index position i.
 void replace(int i, QXmlStreamAttribute t)
          Replaces the item at index position i with t.
 void reserve(int size)
          Attempts to allocate memory for at least size elements.
 void resize(int size)
          Sets the size of the vector to size.
 void setSharable(boolean sharable)
          
 int size()
          Returns the number of items in the vector.
 void squeeze()
          Releases any memory not required to store the items.
 java.util.List<QXmlStreamAttribute> toList()
          Returns a QList object with the data contained in this QVector.
 java.lang.String value(java.lang.String qualifiedName)
          Returns the value of the attribute with qualified name qualifiedName , or an empty string reference if the attribute is not defined.
 java.lang.String value(java.lang.String namespaceUri, java.lang.String name)
          Returns the value of the attribute name in the namespace described with namespaceUri, or an empty string reference if the attribute is not defined.
 
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

QXmlStreamAttributes

public QXmlStreamAttributes()
Creates a new QXmlStreamAttributes object.

Method Detail

append

public final void append(java.lang.String namespaceUri,
                         java.lang.String name,
                         java.lang.String value)

Appends a new attribute with name in the namespace described with namespaceUri, and value value. The namespaceUri can be empty.


append

public final void append(java.lang.String qualifiedName,
                         java.lang.String value)

Appends a new attribute with qualified name qualifiedName and value value.


append

public final void append(QXmlStreamAttribute attribute)

Appends the given attribute to the end of the vector.

See Also:
QVector::append

at

public final QXmlStreamAttribute at(int i)

Returns the item at index position i in the vector.

i must be a valid index position in the vector (i.e., 0 <= i < size).

See Also:
value, operator[]

capacity

public final int capacity()

Returns the maximum number of items that can be stored in the vector without forcing a reallocation.

The sole purpose of this function is to provide a means of fine tuning QVector's memory usage. In general, you will rarely ever need to call this function. If you want to know how many items are in the vector, call size.

See Also:
reserve, squeeze

clear

public final void clear()

Removes all the elements from the vector.

Same as resize(0).


contains

public final boolean contains(QXmlStreamAttribute t)

Returns true if the vector contains an occurrence of t; otherwise returns false.

This function requires the value type to have an implementation of operator==().

See Also:
indexOf, count

count

public final int count(QXmlStreamAttribute t)

Returns the number of occurrences of t in the vector.

This function requires the value type to have an implementation of operator==().

See Also:
contains, indexOf

count

public final int count()

Same as size.


empty

public final boolean empty()

This function is provided for STL compatibility. It is equivalent to isEmpty, returning true if the vector is empty; otherwise returns false.


fill

public final java.util.List<QXmlStreamAttribute> fill(QXmlStreamAttribute t,
                                                      int size)

Assigns t to all items in the vector. If size is different from -1 (the default), the vector is resized to size size beforehand.

Example:

    QVector<QString> vector(3);
    vector.fill("Yes");
    // vector: ["Yes", "Yes", "Yes"]

    vector.fill("oh", 5);
    // vector: ["oh", "oh", "oh", "oh", "oh"]

See Also:
resize

first

public final QXmlStreamAttribute first()


indexOf

public final int indexOf(QXmlStreamAttribute t,
                         int from)

Returns the index position of the first occurrence of t in the vector, searching forward from index position from. Returns -1 if no item matched.

Example:

    QVector<QString> vector;
    vector << "A" << "B" << "C" << "B" << "A";
    vector.indexOf("B");            // returns 1
    vector.indexOf("B", 1);         // returns 1
    vector.indexOf("B", 2);         // returns 3
    vector.indexOf("X");            // returns -1

This function requires the value type to have an implementation of operator==().

See Also:
lastIndexOf, contains

isEmpty

public final boolean isEmpty()

Returns true if the vector has size 0; otherwise returns false.

See Also:
size, resize

last

public final QXmlStreamAttribute last()


lastIndexOf

public final int lastIndexOf(QXmlStreamAttribute t,
                             int from)

Returns the index position of the last occurrence of the value t in the vector, searching backward from index position from. If from is -1 (the default), the search starts at the last item. Returns -1 if no item matched.

Example:

    QList<QString> vector;
    vector << "A" << "B" << "C" << "B" << "A";
    vector.lastIndexOf("B");        // returns 3
    vector.lastIndexOf("B", 3);     // returns 3
    vector.lastIndexOf("B", 2);     // returns 1
    vector.lastIndexOf("X");        // returns -1

This function requires the value type to have an implementation of operator==().

See Also:
indexOf

mid

public final java.util.List<QXmlStreamAttribute> mid(int pos,
                                                     int length)

Returns a vector whose elements are copied from this vector, starting at position pos. If length is -1 (the default), all elements after pos are copied; otherwise length elements (or all remaining elements if there are less than length elements) are copied.


prepend

public final void prepend(QXmlStreamAttribute t)

Inserts t at the beginning of the vector.

Example:

    QVector<QString> vector;
    vector.prepend("one");
    vector.prepend("two");
    vector.prepend("three");
    // vector: ["three", "two", "one"]

This is the same as vector.insert(0, t).

For large vectors, this operation can be slow (linear time), because it requires moving all the items in the vector by one position further in memory. If you want a container class that provides a fast prepend function, use QList or QLinkedList instead.

See Also:
append, insert

remove

public final void remove(int i,
                         int n)

Removes n elements from the middle of the vector, starting at index position i.

See Also:
insert, replace, fill

remove

public final void remove(int i)

Removes the element at index position i.

See Also:
insert, replace, fill

replace

public final void replace(int i,
                          QXmlStreamAttribute t)

Replaces the item at index position i with t.

i must be a valid index position in the vector (i.e., 0 <= i < size).

See Also:
operator[], remove

reserve

public final void reserve(int size)

Attempts to allocate memory for at least size elements. If you know in advance how large the vector will be, you can call this function, and if you call resize often you are likely to get better performance. If size is an underestimate, the worst that will happen is that the QVector will be a bit slower.

The sole purpose of this function is to provide a means of fine tuning QVector's memory usage. In general, you will rarely ever need to call this function. If you want to change the size of the vector, call resize.

See Also:
squeeze, capacity

resize

public final void resize(int size)

Sets the size of the vector to size. If size is greater than the current size, elements are added to the end; the new elements are initialized with a default-constructed value. If size is less than the current size, elements are removed from the end.

See Also:
size

setSharable

public final void setSharable(boolean sharable)


size

public final int size()

Returns the number of items in the vector.

See Also:
isEmpty, resize

squeeze

public final void squeeze()

Releases any memory not required to store the items.

The sole purpose of this function is to provide a means of fine tuning QVector's memory usage. In general, you will rarely ever need to call this function.

See Also:
reserve, capacity

toList

public final java.util.List<QXmlStreamAttribute> toList()

Returns a QList object with the data contained in this QVector.

Example:

    QVector<double> vect;
    vect << "red" << "green" << "blue" << "black";

    QList<double> list = vect.toList();
    // list: ["red", "green", "blue", "black"]

See Also:
fromList, QList::fromVector

value

public final java.lang.String value(java.lang.String qualifiedName)

Returns the value of the attribute with qualified name qualifiedName , or an empty string reference if the attribute is not defined. A qualified name is the raw name of an attribute in the XML data. It consists of the namespace prefix, followed by colon, followed by the attribute's local name. Since the namespace prefix is not unique (the same prefix can point to different namespaces and different prefixes can point to the same namespace), you shouldn't use qualified names, but a resolved namespaceUri and the attribute's local name.


value

public final java.lang.String value(java.lang.String namespaceUri,
                                    java.lang.String name)

Returns the value of the attribute name in the namespace described with namespaceUri, or an empty string reference if the attribute is not defined. The namespaceUri can be empty.


fromList

public static java.util.List<QXmlStreamAttribute> fromList(java.util.List<QXmlStreamAttribute> list)

Returns a QVector object with the data contained in list.

Example:

    QStringList list;
    list << "Sven" << "Kim" << "Ola";

    QVector<QString> vect = QVector<QString>::fromList(list);
    // vect: ["Sven", "Kim", "Ola"]

See Also:
toList, QList::toVector

fromNativePointer

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

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

nativePointerArray

public static QNativePointer nativePointerArray(QXmlStreamAttributes[] array)
This function returns a QNativePointer that is pointing to the specified QXmlStreamAttributes 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