Package io.netty5.buffer
Class DefaultByteBufHolder
- java.lang.Object
-
- io.netty5.buffer.DefaultByteBufHolder
-
- All Implemented Interfaces:
ByteBufHolder
,io.netty5.util.ReferenceCounted
public class DefaultByteBufHolder extends Object implements ByteBufHolder
Default implementation of aByteBufHolder
that holds it's data in aByteBuf
.
-
-
Constructor Summary
Constructors Constructor Description DefaultByteBufHolder(ByteBuf data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBuf
content()
Return the data which is held by thisByteBufHolder
.protected String
contentToString()
ReturnByteBuf.toString()
without checking the reference count first.ByteBufHolder
copy()
Creates a deep copy of thisByteBufHolder
.ByteBufHolder
duplicate()
Duplicates thisByteBufHolder
.boolean
equals(Object o)
This implementation of theequals
operation is restricted to work only with instances of the same class.int
hashCode()
int
refCnt()
boolean
release()
boolean
release(int decrement)
ByteBufHolder
replace(ByteBuf content)
Returns a newByteBufHolder
which contains the specifiedcontent
.ByteBufHolder
retain()
ByteBufHolder
retain(int increment)
ByteBufHolder
retainedDuplicate()
Duplicates thisByteBufHolder
.String
toString()
ByteBufHolder
touch()
ByteBufHolder
touch(Object hint)
-
-
-
Constructor Detail
-
DefaultByteBufHolder
public DefaultByteBufHolder(ByteBuf data)
-
-
Method Detail
-
content
public ByteBuf content()
Description copied from interface:ByteBufHolder
Return the data which is held by thisByteBufHolder
.- Specified by:
content
in interfaceByteBufHolder
-
copy
public ByteBufHolder copy()
Creates a deep copy of thisByteBufHolder
.This method calls
replace(content().copy())
by default.- Specified by:
copy
in interfaceByteBufHolder
-
duplicate
public ByteBufHolder duplicate()
Duplicates thisByteBufHolder
. Be aware that this will not automatically callByteBufHolder.retain()
.This method calls
replace(content().duplicate())
by default.- Specified by:
duplicate
in interfaceByteBufHolder
-
retainedDuplicate
public ByteBufHolder retainedDuplicate()
Duplicates thisByteBufHolder
. This method returns a retained duplicate unlikeByteBufHolder.duplicate()
.This method calls
replace(content().retainedDuplicate())
by default.- Specified by:
retainedDuplicate
in interfaceByteBufHolder
- See Also:
ByteBuf.retainedDuplicate()
-
replace
public ByteBufHolder replace(ByteBuf content)
Returns a newByteBufHolder
which contains the specifiedcontent
.Override this method to return a new instance of this object whose content is set to the specified
content
. The default implementation ofcopy()
,duplicate()
andretainedDuplicate()
invokes this method to create a copy.- Specified by:
replace
in interfaceByteBufHolder
-
refCnt
public int refCnt()
- Specified by:
refCnt
in interfaceio.netty5.util.ReferenceCounted
-
retain
public ByteBufHolder retain()
- Specified by:
retain
in interfaceByteBufHolder
- Specified by:
retain
in interfaceio.netty5.util.ReferenceCounted
-
retain
public ByteBufHolder retain(int increment)
- Specified by:
retain
in interfaceByteBufHolder
- Specified by:
retain
in interfaceio.netty5.util.ReferenceCounted
-
touch
public ByteBufHolder touch()
- Specified by:
touch
in interfaceByteBufHolder
- Specified by:
touch
in interfaceio.netty5.util.ReferenceCounted
-
touch
public ByteBufHolder touch(Object hint)
- Specified by:
touch
in interfaceByteBufHolder
- Specified by:
touch
in interfaceio.netty5.util.ReferenceCounted
-
release
public boolean release()
- Specified by:
release
in interfaceio.netty5.util.ReferenceCounted
-
release
public boolean release(int decrement)
- Specified by:
release
in interfaceio.netty5.util.ReferenceCounted
-
contentToString
protected final String contentToString()
ReturnByteBuf.toString()
without checking the reference count first. This is useful to implementtoString()
.
-
equals
public boolean equals(Object o)
This implementation of theequals
operation is restricted to work only with instances of the same class. The reason for that is that Netty library already has a number of classes that extendDefaultByteBufHolder
and overrideequals
method with an additional comparison logic and we need the symmetric property of theequals
operation to be preserved.
-
-