Package io.netty.buffer
Class DefaultByteBufHolder
java.lang.Object
io.netty.buffer.DefaultByteBufHolder
- All Implemented Interfaces:
ByteBufHolder
,ReferenceCounted
- Direct Known Subclasses:
DefaultBulkStringRedisContent
,DefaultHttp2GoAwayFrame
,DefaultHttp2UnknownFrame
,DefaultSmtpContent
,DefaultSpdyUnknownFrame
,DefaultStompContentSubframe
,FullBulkStringRedisMessage
,HAProxyTLV
,SctpMessage
,WebSocketFrame
Default implementation of a
ByteBufHolder
that holds it's data in a ByteBuf
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncontent()
Return the data which is held by thisByteBufHolder
.protected final String
ReturnByteBuf.toString()
without checking the reference count first.copy()
Creates a deep copy of thisByteBufHolder
.Duplicates thisByteBufHolder
.boolean
This implementation of theequals
operation is restricted to work only with instances of the same class.int
hashCode()
int
refCnt()
Returns the reference count of this object.boolean
release()
Decreases the reference count by1
and deallocates this object if the reference count reaches at0
.boolean
release
(int decrement) Decreases the reference count by the specifieddecrement
and deallocates this object if the reference count reaches at0
.Returns a newByteBufHolder
which contains the specifiedcontent
.retain()
Increases the reference count by1
.retain
(int increment) Increases the reference count by the specifiedincrement
.Duplicates thisByteBufHolder
.toString()
touch()
Records the current access location of this object for debugging purposes.Records the current access location of this object with an additional arbitrary information for debugging purposes.
-
Field Details
-
data
-
-
Constructor Details
-
DefaultByteBufHolder
-
-
Method Details
-
content
Description copied from interface:ByteBufHolder
Return the data which is held by thisByteBufHolder
.- Specified by:
content
in interfaceByteBufHolder
-
copy
Creates a deep copy of thisByteBufHolder
.This method calls
replace(content().copy())
by default.- Specified by:
copy
in interfaceByteBufHolder
-
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
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:
-
replace
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()Description copied from interface:ReferenceCounted
Returns the reference count of this object. If0
, it means this object has been deallocated.- Specified by:
refCnt
in interfaceReferenceCounted
-
retain
Description copied from interface:ReferenceCounted
Increases the reference count by1
.- Specified by:
retain
in interfaceByteBufHolder
- Specified by:
retain
in interfaceReferenceCounted
-
retain
Description copied from interface:ReferenceCounted
Increases the reference count by the specifiedincrement
.- Specified by:
retain
in interfaceByteBufHolder
- Specified by:
retain
in interfaceReferenceCounted
-
touch
Description copied from interface:ReferenceCounted
Records the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector
. This method is a shortcut totouch(null)
.- Specified by:
touch
in interfaceByteBufHolder
- Specified by:
touch
in interfaceReferenceCounted
-
touch
Description copied from interface:ReferenceCounted
Records the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector
.- Specified by:
touch
in interfaceByteBufHolder
- Specified by:
touch
in interfaceReferenceCounted
-
release
public boolean release()Description copied from interface:ReferenceCounted
Decreases the reference count by1
and deallocates this object if the reference count reaches at0
.- Specified by:
release
in interfaceReferenceCounted
- Returns:
true
if and only if the reference count became0
and this object has been deallocated
-
release
public boolean release(int decrement) Description copied from interface:ReferenceCounted
Decreases the reference count by the specifieddecrement
and deallocates this object if the reference count reaches at0
.- Specified by:
release
in interfaceReferenceCounted
- Returns:
true
if and only if the reference count became0
and this object has been deallocated
-
contentToString
ReturnByteBuf.toString()
without checking the reference count first. This is useful to implementtoString()
. -
toString
-
equals
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. -
hashCode
public int hashCode()
-