Package io.netty.buffer
Class DefaultByteBufHolder
- java.lang.Object
-
- io.netty.buffer.DefaultByteBufHolder
-
- All Implemented Interfaces:
ByteBufHolder,io.netty.util.ReferenceCounted
public class DefaultByteBufHolder extends 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 StringcontentToString()ReturnByteBuf.toString()without checking the reference count first.ByteBufHoldercopy()Creates a deep copy of thisByteBufHolder.ByteBufHolderduplicate()Duplicates thisByteBufHolder.booleanequals(Object o)This implementation of theequalsoperation is restricted to work only with instances of the same class.inthashCode()intrefCnt()booleanrelease()booleanrelease(int decrement)ByteBufHolderreplace(ByteBuf content)Returns a newByteBufHolderwhich contains the specifiedcontent.ByteBufHolderretain()ByteBufHolderretain(int increment)ByteBufHolderretainedDuplicate()Duplicates thisByteBufHolder.StringtoString()ByteBufHoldertouch()ByteBufHoldertouch(Object hint)
-
-
-
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()
- Specified by:
refCntin interfaceio.netty.util.ReferenceCounted
-
retain
public ByteBufHolder retain()
- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfaceio.netty.util.ReferenceCounted
-
retain
public ByteBufHolder retain(int increment)
- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfaceio.netty.util.ReferenceCounted
-
touch
public ByteBufHolder touch()
- Specified by:
touchin interfaceByteBufHolder- Specified by:
touchin interfaceio.netty.util.ReferenceCounted
-
touch
public ByteBufHolder touch(Object hint)
- Specified by:
touchin interfaceByteBufHolder- Specified by:
touchin interfaceio.netty.util.ReferenceCounted
-
release
public boolean release()
- Specified by:
releasein interfaceio.netty.util.ReferenceCounted
-
release
public boolean release(int decrement)
- Specified by:
releasein interfaceio.netty.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 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.
-
-