Package org.stellar.sdk.xdr
Class XdrString
java.lang.Object
org.stellar.sdk.xdr.XdrString
- All Implemented Interfaces:
XdrElement
Represents XDR string data.
-
Field Summary
Fields inherited from interface org.stellar.sdk.xdr.XdrElement
gson -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic XdrStringdecode(XdrDataInputStream stream, int maxSize) Decodes anXdrStringfrom the provided stream using the default maximum depth.static XdrStringdecode(XdrDataInputStream stream, int maxDepth, int maxSize) Decodes anXdrStringfrom the provided stream.voidencode(XdrDataOutputStream stream) Encodes this string to XDR.booleanstatic XdrStringParses anXdrStringfrom JSON.static XdrStringfromXdrBase64(String xdr) Decodes anXdrStringfrom a base64-encoded XDR string.static XdrStringfromXdrBase64(String xdr, int maxSize) Decodes anXdrStringfrom a base64-encoded XDR string.static XdrStringfromXdrByteArray(byte[] xdr) Decodes anXdrStringfrom raw XDR bytes.static XdrStringfromXdrByteArray(byte[] xdr, int maxSize) Decodes anXdrStringfrom raw XDR bytes.byte[]getBytes()Raw bytes of the XDR string value.inthashCode()toJson()Serializes this value to JSON.toString()Returns this value decoded as a UTF-8 string.Methods inherited from interface org.stellar.sdk.xdr.XdrElement
toXdrBase64, toXdrByteArray
-
Constructor Details
-
Method Details
-
encode
Encodes this string to XDR.- Specified by:
encodein interfaceXdrElement- Parameters:
stream- the destination XDR output stream- Throws:
IOException- if an I/O error occurs while writing the value
-
decode
public static XdrString decode(XdrDataInputStream stream, int maxDepth, int maxSize) throws IOException Decodes anXdrStringfrom the provided stream.- Parameters:
stream- the source XDR input streammaxDepth- the maximum decoding depth, ignored for this leaf typemaxSize- the maximum allowed string size in bytes- Returns:
- the decoded
XdrString - Throws:
IOException- if the encoded size is invalid or an I/O error occurs
-
decode
Decodes anXdrStringfrom the provided stream using the default maximum depth.- Parameters:
stream- the source XDR input streammaxSize- the maximum allowed string size in bytes- Returns:
- the decoded
XdrString - Throws:
IOException- if the encoded size is invalid or an I/O error occurs
-
fromXdrBase64
Decodes anXdrStringfrom a base64-encoded XDR string.- Parameters:
xdr- the base64-encoded XDR stringmaxSize- the maximum allowed string size in bytes- Returns:
- the decoded
XdrString - Throws:
IOException- if the input is invalid or cannot be decoded
-
fromXdrBase64
Decodes anXdrStringfrom a base64-encoded XDR string.- Parameters:
xdr- the base64-encoded XDR string- Returns:
- the decoded
XdrString - Throws:
IOException- if the input is invalid or cannot be decoded
-
fromXdrByteArray
Decodes anXdrStringfrom raw XDR bytes.- Parameters:
xdr- the raw XDR bytesmaxSize- the maximum allowed string size in bytes- Returns:
- the decoded
XdrString - Throws:
IOException- if the input is invalid or cannot be decoded
-
fromXdrByteArray
Decodes anXdrStringfrom raw XDR bytes.- Parameters:
xdr- the raw XDR bytes- Returns:
- the decoded
XdrString - Throws:
IOException- if the input is invalid or cannot be decoded
-
toJson
Serializes this value to JSON.- Specified by:
toJsonin interfaceXdrElement- Returns:
- the JSON representation of this string
-
fromJson
Parses anXdrStringfrom JSON.- Parameters:
json- the JSON representation- Returns:
- the parsed
XdrString, ornullif the input isnull
-
toString
Returns this value decoded as a UTF-8 string. -
getBytes
public byte[] getBytes()Raw bytes of the XDR string value.- Returns:
- the encoded string bytes
-
equals
-
hashCode
public int hashCode()
-