Class AttributedInputStream

    • Field Detail

      • cleanup

        protected final Cleanup<IOException> cleanup
        The clean-up for closing the wrapped input stream as post-mortem action of this AttributedInputStream or null to only InputStream.close() the wrapped input stream.
    • Constructor Detail

      • AttributedInputStream

        public AttributedInputStream​(InputStream in)
        Creates a new input stream wrapping the designated input stream and having arbitrary attributes.
        Parameters:
        in - The wrapped input stream.
      • AttributedInputStream

        public AttributedInputStream​(InputStream in,
                                     CleanupTask<IOException> cleanup)
        Creates a new input stream wrapping the designated input stream and having arbitrary attributes and the designated clean-up task. If present, this task will be executed before closing the wrapped input stream
        Parameters:
        in - The wrapped input stream.
        cleanup - An additional clean-up task for the created instance. This will be executed in close() and also in clean-up before closing the wrapped input stream. If this is null, there will be no cleanup and the wrapped input stream has to be closed explicitly.
    • Method Detail

      • unwrap

        protected InputStream unwrap()
        Gets the wrapped input stream.
        Returns:
        The wrapped input stream.
      • contains

        public boolean contains​(String name)
        Description copied from interface: Attributable
        Gets whether this Attributable contains an attribute value for the designated attribute name.
        Specified by:
        contains in interface Attributable
        Parameters:
        name - The name of the attribute for which an attribute value exists or not.
        Returns:
        Whether this Attributable contains an attribute value for the designated attribute name.
      • containsType

        public boolean containsType​(String name,
                                    Class<?> valueType)
        Description copied from interface: Attributable
        Gets whether this Attributable contains an attribute value for the designated attribute name of the designated type.
        Specified by:
        containsType in interface Attributable
        Parameters:
        name - The name of the attribute for which an attribute value exists or not.
        valueType - The type of the value of the attribute of the designated name.
        Returns:
        Whether this Attributable contains an attribute value for the designated attribute name of the designate type.
      • get

        public Object get​(String name)
        Description copied from interface: Attributable
        Gets the value of the attribute with the designated name or null if the attribute is not present or has a null value.
        Specified by:
        get in interface Attributable
        Parameters:
        name - The name of the attribute for which to retrieve the value.
        Returns:
        The value of the attribute with the designated name or null if the attribute is not present or has a null value.
      • putIfAbsent

        public Object putIfAbsent​(String name,
                                  Object value)
        Description copied from interface: Attributable
        Puts an attribute with the designated name and value if the attribute is not present yet and returns null or the existing current value.
        Specified by:
        putIfAbsent in interface Attributable
        Parameters:
        name - The name of the attribute which make available.
        value - The value of the attribute which to make available.
        Returns:
        The previous value (always null) or the current value (in case putting is refused since the attribute is already present).
      • computeIfAbsent

        public Object computeIfAbsent​(String name,
                                      Function<? super String,​Object> compFunc)
        Description copied from interface: Attributable
        Computes the value of the attribute with the designated name if the attribute is not present yet and returns the value (or the current value if already present and not computed).
        Specified by:
        computeIfAbsent in interface Attributable
        Parameters:
        name - The name of the attribute which make available.
        compFunc - The function computing the attribute value which to make available.
        Returns:
        The previous value if already present (and therefore not computed) or the computed value.
      • remove

        public Object remove​(String name)
        Description copied from interface: Attributable
        Removes the attribute with the designated name and returns its current (previous) value.
        Specified by:
        remove in interface Attributable
        Parameters:
        name - The name of the attribute which to remove.
        Returns:
        The value of the removed attribute.
      • replace

        public Object replace​(String name,
                              Object newValue)
        Description copied from interface: Attributable
        Replaces the value of the attribute with the designated name if it has a value and returns its previous value. If the attribute does not have a value yet, it will not be added and null will be returned. Note that null will also be returned when replacing the explicit attribute value null.
        Specified by:
        replace in interface Attributable
        Parameters:
        name - The name of the attribute which to replace.
        newValue - The value of the attribute with which to replace the existing value.
        Returns:
        The replaced value of the attribute or null in case of an unknown attribute (and no replacement).
      • replace

        public boolean replace​(String name,
                               Object oldValue,
                               Object newValue)
        Description copied from interface: Attributable
        Replaces the value of the attribute with the designated name if it has the designated value. If the attribute does not have a value yet, it will not be added and false will be returned.
        Specified by:
        replace in interface Attributable
        Parameters:
        name - The name of the attribute which to replace.
        oldValue - The old value of the attribute which to replace.
        newValue - The value of the attribute with which to replace the old value.
        Returns:
        Whether the attribute value has been replaced.