Package io.netty.buffer
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
public class DefaultByteBufHolder extends java.lang.Object implements ByteBufHolder
Default implementation of aByteBufHolderthat 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 ByteBufcontent()Return the data which is held by thisByteBufHolder.protected java.lang.StringcontentToString()ReturnByteBuf.toString()without checking the reference count first.ByteBufHoldercopy()Creates a deep copy of thisByteBufHolder.ByteBufHolderduplicate()Duplicates thisByteBufHolder.booleanequals(java.lang.Object o)This 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.ByteBufHolderreplace(ByteBuf content)Returns a newByteBufHolderwhich contains the specifiedcontent.ByteBufHolderretain()Increases the reference count by1.ByteBufHolderretain(int increment)Increases the reference count by the specifiedincrement.ByteBufHolderretainedDuplicate()Duplicates thisByteBufHolder.java.lang.StringtoString()ByteBufHoldertouch()Records the current access location of this object for debugging purposes.ByteBufHoldertouch(java.lang.Object hint)Records the current access location of this object with an additional arbitrary information for debugging purposes.
-
-
-
Constructor Detail
-
DefaultByteBufHolder
public DefaultByteBufHolder(ByteBuf data)
-
-
Method Detail
-
content
public ByteBuf content()
Description copied from interface:ByteBufHolderReturn the data which is held by thisByteBufHolder.- Specified by:
contentin interfaceByteBufHolder
-
copy
public ByteBufHolder copy()
Creates a deep copy of thisByteBufHolder.This method calls
replace(content().copy())by default.- Specified by:
copyin 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:
duplicatein 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:
retainedDuplicatein interfaceByteBufHolder- See Also:
ByteBuf.retainedDuplicate()
-
replace
public ByteBufHolder replace(ByteBuf content)
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
public ByteBufHolder retain()
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfaceReferenceCounted
-
retain
public ByteBufHolder retain(int increment)
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfaceReferenceCounted
-
touch
public ByteBufHolder 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
public ByteBufHolder touch(java.lang.Object hint)
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
protected final java.lang.String contentToString()
ReturnByteBuf.toString()without checking the reference count first. This is useful to implementtoString().
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
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.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- the reference object with which to compare.- Returns:
trueif this object is the same as the obj argument;falseotherwise.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-