Package yapion.packet

Class YAPIONInputStream


  • public final class YAPIONInputStream
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      YAPIONInputStream​(java.io.InputStream inputStream)
      Creates a YAPIONInputStream from an InputStream.
    • Method Summary

      Modifier and Type Method Description
      int available()
      Returns an estimate of bytes to be able to read.
      void close()
      Closes this InputStream and tries to close the handler Thread
      YAPIONObject read()
      Read and parses the next YAPIONObject.
      java.lang.Object readObject()
      Read, parses and deserialized the next YAPIONObject.
      void setTypeReMapper​(@NonNull TypeReMapper typeReMapper)
      Set a TypeReMapper to use for the deserialize call.
      void setYAPIONPacketReceiver​(YAPIONPacketReceiver yapionPacketReceiver)
      Set a direct receiver for data from this InputStream.
      void setYAPIONPacketReceiver​(YAPIONPacketReceiver yapionPacketReceiver, int time)
      Set a direct receiver for data from this InputStream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • YAPIONInputStream

        public YAPIONInputStream​(java.io.InputStream inputStream)
        Creates a YAPIONInputStream from an InputStream.
        Parameters:
        inputStream - the InputStream
    • Method Detail

      • setYAPIONPacketReceiver

        public void setYAPIONPacketReceiver​(YAPIONPacketReceiver yapionPacketReceiver)
        Set a direct receiver for data from this InputStream. If an exception was thrown while reading, parsing, or handling the received Packet an Exception packet will be raised and handled by the same YAPIONPacketReceiver.
        Parameters:
        yapionPacketReceiver - the receiver
      • setYAPIONPacketReceiver

        public void setYAPIONPacketReceiver​(YAPIONPacketReceiver yapionPacketReceiver,
                                            int time)
        Set a direct receiver for data from this InputStream. If an exception was thrown while reading, parsing, or handling the received Packet an Exception packet will be raised and handled by the same YAPIONPacketReceiver.
        Parameters:
        yapionPacketReceiver - the receiver
        time - the wait time of the internal receiver loop this time should be between 1 and 1000 ms and will be bounded to a value between it when outside values are given if -1 is given the default will be selected
      • setTypeReMapper

        public void setTypeReMapper​(@NonNull
                                    @NonNull TypeReMapper typeReMapper)
        Set a TypeReMapper to use for the deserialize call. This is useful to change Package.toString() or Class.getTypeName() to another value.
        Parameters:
        typeReMapper - the TypeReMapper to use
      • available

        public int available()
                      throws java.io.IOException
        Returns an estimate of bytes to be able to read.
        Returns:
        the estimated byte count
        Throws:
        java.io.IOException - YAPIONPacketReceiver not null or InputStream.available()
      • read

        public YAPIONObject read()
                          throws java.io.IOException
        Read and parses the next YAPIONObject.
        Returns:
        the next YAPIONObject
        Throws:
        java.io.IOException - YAPIONPacketReceiver not null
      • readObject

        public java.lang.Object readObject()
                                    throws java.io.IOException
        Read, parses and deserialized the next YAPIONObject.
        Returns:
        the next Object
        Throws:
        java.io.IOException - YAPIONPacketReceiver not null
      • close

        public void close()
                   throws java.io.IOException
        Closes this InputStream and tries to close the handler Thread
        Throws:
        java.io.IOException - InputStream.close()