Class Utils


  • public final class Utils
    extends Object
    Utility class for communication.
    • Field Detail

      • DEBUG_ENABLED

        protected static final boolean DEBUG_ENABLED
        Indicates if debug is enabled.
      • hexArray

        protected static final char[] hexArray
    • Method Detail

      • getMsgID

        public static String getMsgID​(ID id)
        Get string representation of ID
        Parameters:
        id - ID to get representation from
        Returns:
        String represation or null if id is null
      • getAccountID

        public static AccountID getAccountID​(String idMsg)
        Get AccountID ID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        AccountID
      • getContractID

        public static ContractID getContractID​(String idMsg)
        Get ContractID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        ContractID
      • getCredentialID

        public static CredentialID getCredentialID​(String idMsg)
        Get CredentialID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        CredentialID
      • getDataContractID

        public static DataContractID getDataContractID​(String idMsg)
        Get DataContractID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        DataContractID
      • getDataSetID

        public static DataSetID getDataSetID​(String idMsg)
        Get DataSetID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        DataSetID
      • getNamespaceID

        public static NamespaceID getNamespaceID​(String idMsg)
        Get NamespaceID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        NamespaceID
      • getECAID

        public static ECAID getECAID​(String idMsg)
        Get ECAID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        ECAID
      • getEventMessageID

        public static EventMessageID getEventMessageID​(String idMsg)
        Get EventMessageID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        EventMessageID
      • getEventObjsMeetConditionID

        public static EventObjsMeetConditionID getEventObjsMeetConditionID​(String idMsg)
        Get EventObjsMeetConditionID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        EventObjsMeetConditionID
      • getExecutionEnvironmentID

        public static ExecutionEnvironmentID getExecutionEnvironmentID​(String idMsg)
        Get ExecutionEnvironmentID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        ExecutionEnvironmentID
      • getImplementationID

        public static ImplementationID getImplementationID​(String idMsg)
        Get ImplementationID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        ImplementationID
      • getInterfaceID

        public static InterfaceID getInterfaceID​(String idMsg)
        Get InterfaceID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        InterfaceID
      • getMetaClassID

        public static MetaClassID getMetaClassID​(String idMsg)
        Get MetaClassID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        MetaClassID
      • getObjectID

        public static ObjectID getObjectID​(String idMsg)
        Get ObjectID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        ObjectID
      • getOperationID

        public static OperationID getOperationID​(String idMsg)
        Get OperationID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        OperationID
      • getPropertyID

        public static PropertyID getPropertyID​(String idMsg)
        Get PropertyID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        PropertyID
      • getQualitativeRegistryID

        public static QualitativeRegistryID getQualitativeRegistryID​(String idMsg)
        Get QualitativeRegistryID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        QualitativeRegistryID
      • getResourceID

        public static ResourceID getResourceID​(String idMsg)
        Get ResourceID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        ResourceID
      • getSessionID

        public static SessionID getSessionID​(String idMsg)
        Get SessionID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        SessionID
      • getStorageLocationID

        public static StorageLocationID getStorageLocationID​(String idMsg)
        Get StorageLocationID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        StorageLocationID
      • getDataClayInstanceID

        public static DataClayInstanceID getDataClayInstanceID​(String idMsg)
        Get DataClayID from Protobuf ID
        Parameters:
        idMsg - Message ID
        Returns:
        DataClayID
      • returnExceptionInfoMessage

        public static void returnExceptionInfoMessage​(io.grpc.stub.StreamObserver<CommonMessages.ExceptionInfo> responseObserver)
        Return ExceptionInfo message
        Parameters:
        responseObserver - Observer
      • getMetaDataInfo

        public static CommonMessages.MetaDataInfo getMetaDataInfo​(MetaDataInfo object)
        Return a message for GRPC call
        Parameters:
        object - object to convert
        Returns:
        the resulting message
      • getMetaDataInfo

        public static MetaDataInfo getMetaDataInfo​(CommonMessages.MetaDataInfo msg)
        Return an object FROM grpc message
        Parameters:
        msg - object to convert
        Returns:
        the resulting object
      • getDataClayInstance

        public static CommonMessages.DataClayInstance getDataClayInstance​(DataClayInstance dataClayInstance)
        Return a message for GRPC call
        Parameters:
        dataClayInstance - object to convert
        Returns:
        the resulting message
      • getDataClayInstance

        public static DataClayInstance getDataClayInstance​(CommonMessages.DataClayInstance dataClayInstanceMsg)
        Return an object FROM grpc message
        Parameters:
        dataClayInstanceMsg - object to convert
        Returns:
        the resulting message
      • getObjectWithDataParamOrReturn

        public static ObjectWithDataParamOrReturn getObjectWithDataParamOrReturn​(CommonMessages.ObjectWithDataParamOrReturn volParamOrRet)
        Obtain the object with data (parameter or return) from the specified message
        Parameters:
        volParamOrRet - a message containing an object with data (parameter or return)
        Returns:
        the instance of an object with data (parameter or return)
      • getLanguageParamOrReturn

        public static CommonMessages.LanguageParamOrReturn getLanguageParamOrReturn​(LanguageParamOrReturn paramOrRet)
        Return a message containing a language object (parameter or return)
        Parameters:
        paramOrRet - the language object
        Returns:
        the resulting message
      • getLanguageParamOrReturn

        public static LanguageParamOrReturn getLanguageParamOrReturn​(CommonMessages.LanguageParamOrReturn paramOrRet)
        Return an instance of language object included in the specified message
        Parameters:
        paramOrRet - the message containing the language objet
        Returns:
        the language object
      • getPersistentParamOrReturn

        public static CommonMessages.PersistentParamOrReturn getPersistentParamOrReturn​(PersistentParamOrReturn paramOrRet)
        Return a message including the specified param or return object
        Parameters:
        paramOrRet - the object to be included within the message
        Returns:
        the resulting message
      • bytesToHex

        public static Queue<String> bytesToHex​(byte[] bytes)
        Get bytes to hexadecimal Strings
        Parameters:
        bytes - Bytes
        Returns:
        Hexadecimal strings
      • getNumBytesNeededInVLQInt

        public static int getNumBytesNeededInVLQInt​(int numNextBytes)
        Get number of bytes needed for a GRPC tag
        Parameters:
        numNextBytes - Number of bytes to represent
        Returns:
        Number of bytes needed for a GRPC tag.
      • printBytesHeader

        public static void printBytesHeader​(Queue<String> byteStr,
                                            int byteIndex)
        Print bytes header
      • printMsg

        public static void printMsg​(com.google.protobuf.GeneratedMessageV3 msg)
        Print GRPC message (pretty)
        Parameters:
        msg - GRPC message
      • serializeException

        public static CommonMessages.ExceptionInfo serializeException​(Exception ex)
        Serialize Exception
        Parameters:
        ex - Exception to serialize
        Returns:
        Serialized exception
      • checkIsExc

        public static void checkIsExc​(CommonMessages.ExceptionInfo response)
        Verifies if response message isException and if this is the case print and raise it properly
        Parameters:
        response - ExceptionInfo response message