Top Description Fields Constructors Methods
io.netty.buffer

public Class DefaultByteBufHolder

extends Object
implements ByteBufHolder
Class Inheritance
All Implemented Interfaces
io.netty.buffer.ByteBufHolder, io.netty.util.ReferenceCounted
Imports
io.netty.util.internal.ObjectUtil, .StringUtil

Default implementation of a ByteBufHolder that holds it's data in a ByteBuf.

Field Summary

Modifier and TypeField and Description
private final ByteBuf

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ByteBuf
content()

Implements io.netty.buffer.ByteBufHolder.content.

Return the data which is held by this ByteBufHolder.
protected final String
contentToString()

Return ByteBuf#toString() without checking the reference count first.

public ByteBufHolder
copy()

Implements io.netty.buffer.ByteBufHolder.copy.

Creates a deep copy of this ByteBufHolder.
public ByteBufHolder
public boolean

Returns:

true if this object is the same as the obj argument; false otherwise.
equals
(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

This implementation of the equals operation is restricted to work only with instances of the same class.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public int
refCnt()

Implements io.netty.util.ReferenceCounted.refCnt.

Returns the reference count of this object.
public boolean
release()

Implements io.netty.util.ReferenceCounted.release.

Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.
public boolean
release(int decrement)

Implements io.netty.util.ReferenceCounted.release.

Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.
public ByteBufHolder
replace(ByteBuf content)

Implements io.netty.buffer.ByteBufHolder.replace.

Returns a new ByteBufHolder which contains the specified content.
public ByteBufHolder
retain()

Implements io.netty.buffer.ByteBufHolder.retain.

Increases the reference count by 1.
public ByteBufHolder
retain(int increment)

Implements io.netty.buffer.ByteBufHolder.retain.

Increases the reference count by the specified increment.
public ByteBufHolder
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public ByteBufHolder
touch()

Implements io.netty.buffer.ByteBufHolder.touch.

Records the current access location of this object for debugging purposes.
public ByteBufHolder
touch(Object hint)

Implements io.netty.buffer.ByteBufHolder.touch.

Records the current access location of this object with an additional arbitrary information for debugging purposes.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

databack to summary
private final ByteBuf data

Constructor Detail

DefaultByteBufHolderback to summary
public DefaultByteBufHolder(ByteBuf data)

Method Detail

contentback to summary
public ByteBuf content()

Implements io.netty.buffer.ByteBufHolder.content.

Doc from io.netty.buffer.ByteBufHolder.content.

Return the data which is held by this ByteBufHolder.

Annotations
@Override
contentToStringback to summary
protected final String contentToString()

Return ByteBuf#toString() without checking the reference count first. This is useful to implement toString().

copyback to summary
public ByteBufHolder copy()

Implements io.netty.buffer.ByteBufHolder.copy.

Doc from io.netty.buffer.ByteBufHolder.copy.

Creates a deep copy of this ByteBufHolder.

This method calls replace(content().copy()) by default.

Annotations
@Override
duplicateback to summary
public ByteBufHolder duplicate()

Implements io.netty.buffer.ByteBufHolder.duplicate.

Doc from io.netty.buffer.ByteBufHolder.duplicate.

Duplicates this ByteBufHolder. Be aware that this will not automatically call retain().

This method calls replace(content().duplicate()) by default.

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

This implementation of the equals 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 extend DefaultByteBufHolder and override equals method with an additional comparison logic and we need the symmetric property of the equals operation to be preserved.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
refCntback to summary
public int refCnt()

Implements io.netty.util.ReferenceCounted.refCnt.

Doc from io.netty.util.ReferenceCounted.refCnt.

Returns the reference count of this object. If 0, it means this object has been deallocated.

Annotations
@Override
releaseback to summary
public boolean release()

Implements io.netty.util.ReferenceCounted.release.

Doc from io.netty.util.ReferenceCounted.release.

Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.

Returns:boolean

true if and only if the reference count became 0 and this object has been deallocated

Annotations
@Override
releaseback to summary
public boolean release(int decrement)

Implements io.netty.util.ReferenceCounted.release.

Doc from io.netty.util.ReferenceCounted.release.

Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.

Returns:boolean

true if and only if the reference count became 0 and this object has been deallocated

Annotations
@Override
replaceback to summary
public ByteBufHolder replace(ByteBuf content)

Implements io.netty.buffer.ByteBufHolder.replace.

Doc from io.netty.buffer.ByteBufHolder.replace.

Returns a new ByteBufHolder which contains the specified content.

Override this method to return a new instance of this object whose content is set to the specified content. The default implementation of copy(), duplicate() and retainedDuplicate() invokes this method to create a copy.

Annotations
@Override
retainback to summary
public ByteBufHolder retain()

Implements io.netty.buffer.ByteBufHolder.retain.

Doc from io.netty.util.ReferenceCounted.retain.

Increases the reference count by 1.

Annotations
@Override
retainback to summary
public ByteBufHolder retain(int increment)

Implements io.netty.buffer.ByteBufHolder.retain.

Doc from io.netty.util.ReferenceCounted.retain.

Increases the reference count by the specified increment.

Annotations
@Override
retainedDuplicateback to summary
public ByteBufHolder retainedDuplicate()

Implements io.netty.buffer.ByteBufHolder.retainedDuplicate.

Doc from io.netty.buffer.ByteBufHolder.retainedDuplicate.

Duplicates this ByteBufHolder. This method returns a retained duplicate unlike duplicate().

This method calls replace(content().retainedDuplicate()) by default.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
touchback to summary
public ByteBufHolder touch()

Implements io.netty.buffer.ByteBufHolder.touch.

Doc from io.netty.util.ReferenceCounted.touch.

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 via ResourceLeakDetector. This method is a shortcut to touch(null).

Annotations
@Override
touchback to summary
public ByteBufHolder touch(Object hint)

Implements io.netty.buffer.ByteBufHolder.touch.

Doc from io.netty.util.ReferenceCounted.touch.

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 via ResourceLeakDetector.

Annotations
@Override