Class SCVal

java.lang.Object
org.stellar.sdk.xdr.SCVal
All Implemented Interfaces:
XdrElement

public class SCVal extends Object implements XdrElement
SCVal's original definition in the XDR file is:
 union SCVal switch (SCValType type)
 {

 case SCV_BOOL:
     bool b;
 case SCV_VOID:
     void;
 case SCV_ERROR:
     SCError error;

 case SCV_U32:
     uint32 u32;
 case SCV_I32:
     int32 i32;

 case SCV_U64:
     uint64 u64;
 case SCV_I64:
     int64 i64;
 case SCV_TIMEPOINT:
     TimePoint timepoint;
 case SCV_DURATION:
     Duration duration;

 case SCV_U128:
     UInt128Parts u128;
 case SCV_I128:
     Int128Parts i128;

 case SCV_U256:
     UInt256Parts u256;
 case SCV_I256:
     Int256Parts i256;

 case SCV_BYTES:
     SCBytes bytes;
 case SCV_STRING:
     SCString str;
 case SCV_SYMBOL:
     SCSymbol sym;

 // Vec and Map are recursive so need to live
 // behind an option, due to xdrpp limitations.
 case SCV_VEC:
     SCVec *vec;
 case SCV_MAP:
     SCMap *map;

 case SCV_ADDRESS:
     SCAddress address;

 // Special SCVals reserved for system-constructed contract-data
 // ledger keys, not generally usable elsewhere.
 case SCV_CONTRACT_INSTANCE:
     SCContractInstance instance;
 case SCV_LEDGER_KEY_CONTRACT_INSTANCE:
     void;
 case SCV_LEDGER_KEY_NONCE:
     SCNonceKey nonce_key;
 };
 
  • Constructor Details

    • SCVal

      public SCVal()
    • SCVal

      public SCVal(SCValType discriminant, Boolean b, SCError error, Uint32 u32, Int32 i32, Uint64 u64, Int64 i64, TimePoint timepoint, Duration duration, UInt128Parts u128, Int128Parts i128, UInt256Parts u256, Int256Parts i256, SCBytes bytes, SCString str, SCSymbol sym, SCVec vec, SCMap map, SCAddress address, SCContractInstance instance, SCNonceKey nonce_key)
      Creates a new SCVal instance.
      Parameters:
      discriminant - the discriminant field value
      b - the b field value
      error - the error field value
      u32 - the u32 field value
      i32 - the i32 field value
      u64 - the u64 field value
      i64 - the i64 field value
      timepoint - the timepoint field value
      duration - the duration field value
      u128 - the u128 field value
      i128 - the i128 field value
      u256 - the u256 field value
      i256 - the i256 field value
      bytes - the bytes field value
      str - the str field value
      sym - the sym field value
      vec - the vec field value
      map - the map field value
      address - the address field value
      instance - the instance field value
      nonce_key - the nonce_key field value
  • Method Details

    • encode

      public void encode(XdrDataOutputStream stream) throws IOException
      Description copied from interface: XdrElement
      Encodes this value to XDR and writes it to the provided stream.
      Specified by:
      encode in interface XdrElement
      Parameters:
      stream - the destination XDR output stream
      Throws:
      IOException - if an I/O error occurs while writing the value
    • decode

      public static SCVal decode(XdrDataInputStream stream, int maxDepth) throws IOException
      Throws:
      IOException
    • decode

      public static SCVal decode(XdrDataInputStream stream) throws IOException
      Throws:
      IOException
    • fromXdrBase64

      public static SCVal fromXdrBase64(String xdr) throws IOException
      Throws:
      IOException
    • fromXdrByteArray

      public static SCVal fromXdrByteArray(byte[] xdr) throws IOException
      Throws:
      IOException
    • toJson

      public String toJson()
      Description copied from interface: XdrElement
      Serializes this value to JSON.
      Specified by:
      toJson in interface XdrElement
      Returns:
      the JSON representation of this value
    • fromJson

      public static SCVal fromJson(String json)
    • builder

      public static SCVal.SCValBuilder builder()
    • toBuilder

      public SCVal.SCValBuilder toBuilder()
    • getDiscriminant

      public SCValType getDiscriminant()
      Value of the discriminant field.
      Returns:
      the discriminant field value
    • getB

      public Boolean getB()
      Value of the b field.
      Returns:
      the b field value
    • getError

      public SCError getError()
      Value of the error field.
      Returns:
      the error field value
    • getU32

      public Uint32 getU32()
      Value of the u32 field.
      Returns:
      the u32 field value
    • getI32

      public Int32 getI32()
      Value of the i32 field.
      Returns:
      the i32 field value
    • getU64

      public Uint64 getU64()
      Value of the u64 field.
      Returns:
      the u64 field value
    • getI64

      public Int64 getI64()
      Value of the i64 field.
      Returns:
      the i64 field value
    • getTimepoint

      public TimePoint getTimepoint()
      Value of the timepoint field.
      Returns:
      the timepoint field value
    • getDuration

      public Duration getDuration()
      Value of the duration field.
      Returns:
      the duration field value
    • getU128

      public UInt128Parts getU128()
      Value of the u128 field.
      Returns:
      the u128 field value
    • getI128

      public Int128Parts getI128()
      Value of the i128 field.
      Returns:
      the i128 field value
    • getU256

      public UInt256Parts getU256()
      Value of the u256 field.
      Returns:
      the u256 field value
    • getI256

      public Int256Parts getI256()
      Value of the i256 field.
      Returns:
      the i256 field value
    • getBytes

      public SCBytes getBytes()
      Value of the bytes field.
      Returns:
      the bytes field value
    • getStr

      public SCString getStr()
      Value of the str field.
      Returns:
      the str field value
    • getSym

      public SCSymbol getSym()
      Value of the sym field.
      Returns:
      the sym field value
    • getVec

      public SCVec getVec()
      Value of the vec field.
      Returns:
      the vec field value
    • getMap

      public SCMap getMap()
      Value of the map field.
      Returns:
      the map field value
    • getAddress

      public SCAddress getAddress()
      Value of the address field.
      Returns:
      the address field value
    • getInstance

      public SCContractInstance getInstance()
      Value of the instance field.
      Returns:
      the instance field value
    • getNonce_key

      public SCNonceKey getNonce_key()
      Value of the nonce_key field.
      Returns:
      the nonce_key field value
    • setDiscriminant

      public void setDiscriminant(SCValType discriminant)
      Value of the discriminant field.
      Parameters:
      discriminant - the discriminant field value
    • setB

      public void setB(Boolean b)
      Value of the b field.
      Parameters:
      b - the b field value
    • setError

      public void setError(SCError error)
      Value of the error field.
      Parameters:
      error - the error field value
    • setU32

      public void setU32(Uint32 u32)
      Value of the u32 field.
      Parameters:
      u32 - the u32 field value
    • setI32

      public void setI32(Int32 i32)
      Value of the i32 field.
      Parameters:
      i32 - the i32 field value
    • setU64

      public void setU64(Uint64 u64)
      Value of the u64 field.
      Parameters:
      u64 - the u64 field value
    • setI64

      public void setI64(Int64 i64)
      Value of the i64 field.
      Parameters:
      i64 - the i64 field value
    • setTimepoint

      public void setTimepoint(TimePoint timepoint)
      Value of the timepoint field.
      Parameters:
      timepoint - the timepoint field value
    • setDuration

      public void setDuration(Duration duration)
      Value of the duration field.
      Parameters:
      duration - the duration field value
    • setU128

      public void setU128(UInt128Parts u128)
      Value of the u128 field.
      Parameters:
      u128 - the u128 field value
    • setI128

      public void setI128(Int128Parts i128)
      Value of the i128 field.
      Parameters:
      i128 - the i128 field value
    • setU256

      public void setU256(UInt256Parts u256)
      Value of the u256 field.
      Parameters:
      u256 - the u256 field value
    • setI256

      public void setI256(Int256Parts i256)
      Value of the i256 field.
      Parameters:
      i256 - the i256 field value
    • setBytes

      public void setBytes(SCBytes bytes)
      Value of the bytes field.
      Parameters:
      bytes - the bytes field value
    • setStr

      public void setStr(SCString str)
      Value of the str field.
      Parameters:
      str - the str field value
    • setSym

      public void setSym(SCSymbol sym)
      Value of the sym field.
      Parameters:
      sym - the sym field value
    • setVec

      public void setVec(SCVec vec)
      Value of the vec field.
      Parameters:
      vec - the vec field value
    • setMap

      public void setMap(SCMap map)
      Value of the map field.
      Parameters:
      map - the map field value
    • setAddress

      public void setAddress(SCAddress address)
      Value of the address field.
      Parameters:
      address - the address field value
    • setInstance

      public void setInstance(SCContractInstance instance)
      Value of the instance field.
      Parameters:
      instance - the instance field value
    • setNonce_key

      public void setNonce_key(SCNonceKey nonce_key)
      Value of the nonce_key field.
      Parameters:
      nonce_key - the nonce_key field value
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object