Class IError


  • public class IError
    extends RefCounted
    Maps from int return codes to defined Error values.


    This class is used to map from AVPKit return codes
    (for example on {IContainer#readNextPacket(IPacket)}
    into an enum type if the error is known and a text description.


    WARNING: Do not write code that depends on the integer values
    returned from AVPKit; instead use the integer value to create
    one of these objects. That's because integer values returned
    from methods can have different meanings on different OS systems
    (for example, ERROR_AGAIN is -11 on Linux, but a different
    value on MacOS). This class maps the error to a os-type-safe
    value.


    Also, do not depend on the string messages staying constant. They
    are for debugging purposes only. And we can't control whether or
    not they are localized -- that's up to your OS. Sorry.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  IError.Type
      A set of errors that AVPKit knows about.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected IError​(long cPtr, boolean cMemoryOwn)
      Internal Only.
      protected IError​(long cPtr, boolean cMemoryOwn, java.util.concurrent.atomic.AtomicLong ref)
      Internal Only.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      IError copyReference()
      Create a new IError object that is actually referring to the exact same underlying native object.
      boolean equals​(java.lang.Object obj)
      Compares two values, returning true if the underlying objects in native code are the same object.
      static IError.Type errorNumberToType​(int errorNo)
      Translate an error number to a type.
      static long getCPtr​(IError obj)
      Internal Only.
      java.lang.String getDescription()
      Get a text description for this error.

      The description returned will be in whatever language
      the underlying OS decides to use, and no, we can't
      support localization here if the OS hasn't already done it.

      Sorry.

      int getErrorNumber()
      Return the raw integer value that AVPKit returned and
      was used to create this IError.

      Note that this value can have different meanings on
      different operating systems.
      long getMyCPtr()
      Internal Only.
      IError.Type getType()
      Get the OS-independent AVPKit type for this error.

      int hashCode()
      Get a hashable value for this object.
      static IError make​(int errorNumber)
      Create a new IError object from a return value passed in from AVPKit.

      static IError make​(IError.Type type)
      Create a new IError object from an IError.Type enum value.

      java.lang.String toString()
      Return a string representation of this error
      static int typeToErrorNumber​(IError.Type type)
      Translate an a type to an error number.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • IError

        protected IError​(long cPtr,
                         boolean cMemoryOwn)
        Internal Only.
      • IError

        protected IError​(long cPtr,
                         boolean cMemoryOwn,
                         java.util.concurrent.atomic.AtomicLong ref)
        Internal Only.
    • Method Detail

      • getCPtr

        public static long getCPtr​(IError obj)
        Internal Only. Not part of public API. Get the raw value of the native object that obj is proxying for.
        Parameters:
        obj - The java proxy object for a native object.
        Returns:
        The raw pointer obj is proxying for.
      • getMyCPtr

        public long getMyCPtr()
        Internal Only. Not part of public API. Get the raw value of the native object that we're proxying for.
        Overrides:
        getMyCPtr in class RefCounted
        Returns:
        The raw pointer we're proxying for.
      • copyReference

        public IError copyReference()
        Create a new IError object that is actually referring to the exact same underlying native object.
        Overrides:
        copyReference in class RefCounted
        Returns:
        the new Java object.
      • equals

        public boolean equals​(java.lang.Object obj)
        Compares two values, returning true if the underlying objects in native code are the same object. That means you can have two different Java objects, but when you do a comparison, you'll find out they are the EXACT same object.
        Overrides:
        equals in class java.lang.Object
        Returns:
        True if the underlying native object is the same. False otherwise.
      • hashCode

        public int hashCode()
        Get a hashable value for this object.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashable value.
      • toString

        public java.lang.String toString()
        Return a string representation of this error
        Overrides:
        toString in class java.lang.Object
        Returns:
        the error as a string
      • getType

        public IError.Type getType()
        Get the OS-independent AVPKit type for this error.

        Returns:
        the type.
      • getDescription

        public java.lang.String getDescription()
        Get a text description for this error.

        The description returned will be in whatever language
        the underlying OS decides to use, and no, we can't
        support localization here if the OS hasn't already done it.

        Sorry.

        Returns:
        the description.
      • getErrorNumber

        public int getErrorNumber()
        Return the raw integer value that AVPKit returned and
        was used to create this IError.

        Note that this value can have different meanings on
        different operating systems. Use {#getType()}
        instead for programmatic decisions.

        Returns:
        the native error number.
      • make

        public static IError make​(int errorNumber)
        Create a new IError object from a return value passed in from AVPKit.

        Parameters:
        errorNumber - The error number as returned from another
        AVPKit call. ErrorNumber must be < 0.
        Returns:
        a new IError, or null on error.
      • make

        public static IError make​(IError.Type type)
        Create a new IError object from an IError.Type enum value.

        Parameters:
        type - The type to use for creation.
        Returns:
        a new IError, or null on error.
      • errorNumberToType

        public static IError.Type errorNumberToType​(int errorNo)
        Translate an error number to a type.
        Parameters:
        errorNo - The error returned from AVPKit
        Returns:
        the type
      • typeToErrorNumber

        public static int typeToErrorNumber​(IError.Type type)
        Translate an a type to an error number.
        Parameters:
        type - The type
        Returns:
        the error number