Class ByteArrayArgument

  • All Implemented Interfaces:
    java.io.Serializable, Parameter

    public final class ByteArrayArgument
    extends TypedArgument
    Argument implementation for byte arrays.

    This implementation supports byte arrays up to length of the argument type.

    See Also:
    Serialized Form
    • Constructor Detail

      • ByteArrayArgument

        public ByteArrayArgument​(int type,
                                 ArgumentType argumentType,
                                 byte[] value)
        Initialises an instance of ByteArrayArgument.
        Parameters:
        type - parameter type
        argumentType - argument type
        value - byte array
        Throws:
        java.lang.IllegalArgumentException - if type is not valid for byte arrays, or if value is null
        LengthOverflowException - if the length of value exceeds ArgumentType.getMaxLength()
    • Method Detail

      • writeTo

        public void writeTo​(java.io.OutputStream outputStream)
                     throws java.io.IOException
        Description copied from class: Argument
        Writes the arguments to the supplied OutputStream in the XDR format of the type.
        Specified by:
        writeTo in class Argument
        Parameters:
        outputStream - OutputStream
        Throws:
        java.io.IOException - For errors writing to the OutputStream
      • getLength

        public int getLength()
        Specified by:
        getLength in class Argument
        Returns:
        Total length of the buffer item when written to the OutputStream by Argument.writeTo(java.io.OutputStream). This includes the item, the value and other items contributing to the total length (e.g. the length of the value).
      • getValueAsInt

        public int getValueAsInt()
        Description copied from interface: Parameter
        The value of the parameter as int.

        The implementation may throw a RuntimeException if the parameter isn't an int (or shouldn't be used as an int).

        Specified by:
        getValueAsInt in interface Parameter
        Overrides:
        getValueAsInt in class Argument
        Returns:
        The value as int
      • getValueAsBytes

        public byte[] getValueAsBytes()
      • copyTo

        public void copyTo​(ParameterBuffer buffer,
                           Encoding encoding)
        Description copied from interface: Parameter
        Copies this argument into the supplied buffer, uses the supplied Encoding for string arguments.

        An instance of Parameter should know how to copy itself into another buffer (eg an instance of StringArgument would know to call ParameterBuffer.addArgument(int, String, Encoding)).

        The parameter does not need to check if it is the right type of destination buffer (if someone tries to add a TPB argument to a DPB he is free to try that).

        Parameters:
        buffer - ParameterBuffer instance
        encoding - Encoding to use for string properties. A value of null can be used to signal that the original encoding should be used.
      • transformTo

        public ByteArrayArgument transformTo​(ParameterBufferMetaData parameterBufferMetaData)
        Description copied from class: Argument
        If needed, returns a new argument to transform to a suitable argument type, otherwise returns this instance.
        Specified by:
        transformTo in class Argument
        Parameters:
        parameterBufferMetaData - parameter buffer metadata (used to determine the needed argument type)
        Returns:
        either a new argument if transformation is needed, or this instance
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object