|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.xml.QXmlInputSource
public class QXmlInputSource
The QXmlInputSource
class provides the input data for the QXmlReader
subclasses. All subclasses of QXmlReader
read the input XML document from this class.
This class recognizes the encoding of the data by reading the encoding declaration in the XML file if it finds one, and reading the data using the corresponding encoding. If it does not find an encoding declaration, then it assumes that the data is either in UTF-8 or UTF-16, depending on whether it can find a byte-order mark.
There are two ways to populate the input source with data: you can construct it with a QIODevice
* so that the input source reads the data from that device. Or you can set the data explicitly with one of the setData()
functions.
Usually you either construct a QXmlInputSource
that works on a QIODevice
* or you construct an empty QXmlInputSource
and set the data with setData()
. There are only rare occasions where you would want to mix both methods.
The QXmlReader
subclasses use the next()
function to read the input character by character. If you want to start from the beginning again, use reset()
.
The functions data()
and fetchData()
are useful if you want to do something with the data other than parsing, e.g. displaying the raw XML file. The benefit of using the QXmlInputClass
in such cases is that it tries to use the correct encoding.
QXmlReader
, and QXmlSimpleReader
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Constructor Summary | |
---|---|
QXmlInputSource()
Constructs an input source which contains no data. |
|
QXmlInputSource(QIODevice dev)
Constructs an input source and gets the data from device dev. |
Method Summary | |
---|---|
java.lang.String |
data()
Returns the data the input source contains or an empty string if the input source does not contain any data. |
static char |
EndOfData()
Returns true if the end of the available data has been met. |
static char |
EndOfDocument()
Returns true if the end of the XML document has been reached. |
void |
fetchData()
This function reads more data from the device that was set during construction. |
static QXmlInputSource |
fromNativePointer(QNativePointer nativePointer)
|
protected java.lang.String |
fromRawData(QByteArray data)
This function reads the XML file from data and tries to recognize the encoding. |
protected java.lang.String |
fromRawData(QByteArray data,
boolean beginning)
This function reads the XML file from data and tries to recognize the encoding. |
char |
next()
Returns the next character of the input source. |
void |
reset()
This function sets the position used by next() to the beginning of the data returned by data() . |
void |
setData(QByteArray dat)
The data dat is passed through the correct text-codec, before it is set. |
void |
setData(java.lang.String dat)
Sets the data of the input source to dat. |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, 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 |
---|
public QXmlInputSource()
setData()
.
public QXmlInputSource(QIODevice dev)
setData()
, fetchData()
, and QIODevice
.
Method Detail |
---|
public java.lang.String data()
setData()
, QXmlInputSource(), and fetchData()
.
public void fetchData()
This object contains no data after a call to this function if the object was constructed without a device to read data from or if this function was not able to get more data from the device.
There are two occasions where a fetch is done implicitly by another function call: during construction (so that the object starts out with some initial data where available), and during a call to next()
(if the data had run out).
You don't normally need to use this function if you use next()
.
data()
, next()
, and QXmlInputSource().
protected final java.lang.String fromRawData(QByteArray data)
If beginning is true, this function assumes that the data starts at the beginning of a new XML document and looks for an encoding declaration. If beginning is false, it converts the raw data using the encoding determined from prior calls.
protected java.lang.String fromRawData(QByteArray data, boolean beginning)
If beginning is true, this function assumes that the data starts at the beginning of a new XML document and looks for an encoding declaration. If beginning is false, it converts the raw data using the encoding determined from prior calls.
public char next()
next()
after that, it tries to fetch more data by calling fetchData()
. If the fetchData()
call results in new data, this function returns the first character of that data; otherwise it returns QXmlInputSource::EndOfDocument. Readers, such as QXmlSimpleReader
, will assume that the end of the XML document has been reached if the this function returns QXmlInputSource::EndOfDocument, and will check that the supplied input is well-formed. Therefore, when reimplementing this function, it is important to ensure that this behavior is duplicated.
reset()
, fetchData()
, QXmlSimpleReader::parse()
, and QXmlSimpleReader::parseContinue()
.
public void reset()
next()
to the beginning of the data returned by data()
. This is useful if you want to use the input source for more than one parse. Note: In the case that the underlying data source is a QIODevice
, the current position in the device is not automatically set to the start of input. Call QIODevice::seek
(0) on the device to do this.
next()
.
public void setData(QByteArray dat)
public void setData(java.lang.String dat)
If the input source already contains data, this function deletes that data first.
data()
.
public static char EndOfData()
public static char EndOfDocument()
public static QXmlInputSource fromNativePointer(QNativePointer nativePointer)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |