Class DefaultByteBufHolder
java.lang.Object
io.netty.buffer.DefaultByteBufHolder
- All Implemented Interfaces:
ByteBufHolder, ReferenceCounted
- Direct Known Subclasses:
DefaultBulkStringRedisContent, DefaultHttp2GoAwayFrame, DefaultHttp2UnknownFrame, DefaultHttp3DataFrame, DefaultHttp3UnknownFrame, DefaultQuicStreamFrame, DefaultSmtpContent, DefaultSpdyUnknownFrame, DefaultStompContentSubframe, FullBulkStringRedisMessage, HAProxyTLV, SctpMessage, UdtMessage, WebSocketFrame
Default implementation of a
ByteBufHolder that holds it's data in a ByteBuf.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncontent()Return the data which is held by thisByteBufHolder.protected final StringReturnByteBuf.toString()without checking the reference count first.copy()Creates a deep copy of thisByteBufHolder.Duplicates thisByteBufHolder.booleanThis implementation of theequalsoperation is restricted to work only with instances of the same class.inthashCode()intrefCnt()Returns the reference count of this object.booleanrelease()Decreases the reference count by1and deallocates this object if the reference count reaches at0.booleanrelease(int decrement) Decreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.Returns a newByteBufHolderwhich 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.
-
Constructor Details
-
DefaultByteBufHolder
-
-
Method Details
-
content
Description copied from interface:ByteBufHolderReturn the data which is held by thisByteBufHolder.- Specified by:
contentin interfaceByteBufHolder
-
copy
Creates a deep copy of thisByteBufHolder.This method calls
replace(content().copy())by default.- Specified by:
copyin interfaceByteBufHolder
-
duplicate
Duplicates thisByteBufHolder. Be aware that this will not automatically callByteBufHolder.retain().This method calls
replace(content().duplicate())by default.- Specified by:
duplicatein interfaceByteBufHolder
-
retainedDuplicate
Duplicates thisByteBufHolder. This method returns a retained duplicate unlikeByteBufHolder.duplicate().This method calls
replace(content().retainedDuplicate())by default.- Specified by:
retainedDuplicatein interfaceByteBufHolder- See Also:
-
replace
Returns a newByteBufHolderwhich 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:
replacein interfaceByteBufHolder
-
refCnt
public int refCnt()Description copied from interface:ReferenceCountedReturns the reference count of this object. If0, it means this object has been deallocated.- Specified by:
refCntin interfaceReferenceCounted
-
retain
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfaceReferenceCounted
-
retain
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfaceReferenceCounted
-
touch
Description copied from interface:ReferenceCountedRecords 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:
touchin interfaceByteBufHolder- Specified by:
touchin interfaceReferenceCounted
-
touch
Description copied from interface:ReferenceCountedRecords 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:
touchin interfaceByteBufHolder- Specified by:
touchin interfaceReferenceCounted
-
release
public boolean release()Description copied from interface:ReferenceCountedDecreases the reference count by1and deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
release
public boolean release(int decrement) Description copied from interface:ReferenceCountedDecreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
contentToString
ReturnByteBuf.toString()without checking the reference count first. This is useful to implementtoString(). -
toString
-
equals
This implementation of theequalsoperation 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 extendDefaultByteBufHolderand overrideequalsmethod with an additional comparison logic and we need the symmetric property of theequalsoperation to be preserved. -
hashCode
-