Saxon.Api
Class TextResource
-
public class TextResource
- implements IResource
An implementation of IResource
that represents plain text
Constructor Summary |
|
---|---|
TextResource (string content, Uri systemId)
Create a |
|
TextResource (TextReader reader, Uri systemId)
Create a |
|
TextResource (Stream stream, Encoding encoding, Uri systemId)
Create a |
|
TextResource (Stream stream, Uri systemId)
Create a |
|
TextResource (Stream stream, Uri systemId, Encoding encoding)
Create a |
Property Summary |
|
---|---|
string | Content The content of the text resource, as a string |
string | ContentType
The content type of the resource: always |
Stream | InputStream
Get a |
Uri | ResourceUri The URI of the text resource |
TextReader | TextReader Get a TextReader for reading the content of this resource in character form |
Method Summary |
|
---|---|
XdmItem | GetXdmItem () Return the content of the resource as an item |
bool | hasReader ()
Ask whether the text resource has a known |
bool | hasStream ()
Ask whether the text resource has a known input |
Constructor Detail
TextResource
Create a TextResource
whose content is supplied as a constant string
Parameters:
content
- The plain text contentsystemId
- The base URI of the contentTextResource
Create a TextResource
whose content is delivered using a TextReader
Parameters:
reader
- The TextReader
used to deliver the contentsystemId
- The base URI of the contentTextResource
Create a TextResource
whose content is delivered using a Stream
,
with a specified encoding
Parameters:
stream
- The Stream
used to deliver the contentencoding
- The Encoding
used to decode the binary contents of the streamsystemId
- The base URI of the contentTextResource
Create a TextResource
whose content is delivered using a Stream
,
with an inferred encoding
Parameters:
stream
- The Stream
used to deliver the contentsystemId
- The base URI of the contentTextResource
Create a TextResource
whose content is delivered using a Stream
,
with an explicit encoding
Parameters:
stream
- The Stream
used to deliver the contentsystemId
- The resource URI of the content, also used as the base URIencoding
- The Encoding
used to decode the binary contents of the streamProperty Detail
Content
The content of the text resource, as a string
Reading this property may cause any contained TextReader
or Stream
to be consumed and closed. The value will be retained internally and can be accessed
repeatedly.
If the value needs to be obtained by reading a (binary) stream, the supplied encoding will be used if available; if not, the system attempts to infer an encoding from the content of the stream, for example by looking for a byte-order mark.
InputStream
Get a Stream
for reading the content of this resource in binary.
If an input stream is available, it is returned.
If a reader is available, or if the string content is available,
then the content is read and a MemoryStream
is returned delivering the content
in UTF-8 encoding.
TextReader
Get a TextReader for reading the content of this resource in character form
If an explicit TextReader
is already available, it is returned.
If the content of the resource is available as a string, then a StringReader
giving access to the content is returned.
If an input Stream
is available, then a TextReader
is constructed,
taking account of the encoding if known, or with an inferred encoding otherwise.
As a last resort, a StringReader
delivering a zero-length string is returned.
Method Detail
GetXdmItem
hasReader
Ask whether the text resource has a known TextReader
Returns:
TextReader
hasStream
Ask whether the text resource has a known input Stream
Returns:
Stream
Return the content of the resource as an item
Returns:
XdmAtomicValue
of typexs:string
holding the content of the resource