List of usage examples for io.netty.buffer ByteBuf writeZero
public abstract ByteBuf writeZero(int length);
From source file:org.opendaylight.protocol.rsvp.parser.impl.te.SessionAttributeLspObjectParser.java
License:Open Source License
@Override public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) { Preconditions.checkArgument(teLspObject instanceof BasicSessionAttributeObject, "SessionAttributeObject is mandatory."); final BasicSessionAttributeObject sessionObject = (BasicSessionAttributeObject) teLspObject; final ByteBuf sessionName = Unpooled .wrappedBuffer(StandardCharsets.US_ASCII.encode(sessionObject.getSessionName())); final int pad = getPadding(sessionName.readableBytes()); serializeAttributeHeader(BODY_SIZE_C7 + pad + sessionName.readableBytes(), CLASS_NUM, CTYPE, output); output.writeByte(sessionObject.getSetupPriority()); output.writeByte(sessionObject.getHoldPriority()); final BitArray bs = new BitArray(FLAGS_SIZE); bs.set(LOCAL_PROTECTION, sessionObject.isLocalProtectionDesired()); bs.set(LABEL_RECORDING, sessionObject.isLabelRecordingDesired()); bs.set(SE_STYLE, sessionObject.isSeStyleDesired()); bs.toByteBuf(output);/*from ww w .j a v a2s . c o m*/ output.writeByte(sessionName.readableBytes()); output.writeBytes(sessionName); output.writeZero(pad); }
From source file:org.opendaylight.protocol.rsvp.parser.impl.te.SessionAttributeLspRaObjectParser.java
License:Open Source License
@Override public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) { Preconditions.checkArgument(teLspObject instanceof SessionAttributeObjectWithResourcesAffinities, "SessionAttributeObject is mandatory."); final SessionAttributeObjectWithResourcesAffinities sessionObject = (SessionAttributeObjectWithResourcesAffinities) teLspObject; final ByteBuf sessionName = Unpooled .wrappedBuffer(StandardCharsets.US_ASCII.encode(sessionObject.getSessionName())); final int pad = SessionAttributeLspObjectParser.getPadding(sessionName.readableBytes()); serializeAttributeHeader(BODY_SIZE_C1 + pad + sessionName.readableBytes(), CLASS_NUM, CTYPE, output); writeAttributeFilter(sessionObject.getIncludeAny(), output); writeAttributeFilter(sessionObject.getExcludeAny(), output); writeAttributeFilter(sessionObject.getIncludeAll(), output); output.writeByte(sessionObject.getSetupPriority()); output.writeByte(sessionObject.getHoldPriority()); final BitArray bs = new BitArray(FLAGS_SIZE); bs.set(SessionAttributeLspObjectParser.LOCAL_PROTECTION, sessionObject.isLocalProtectionDesired()); bs.set(SessionAttributeLspObjectParser.LABEL_RECORDING, sessionObject.isLabelRecordingDesired()); bs.set(SessionAttributeLspObjectParser.SE_STYLE, sessionObject.isSeStyleDesired()); bs.toByteBuf(output);//ww w . ja v a 2 s . c o m output.writeByte(sessionName.readableBytes()); output.writeBytes(Unpooled.wrappedBuffer(StandardCharsets.US_ASCII.encode(sessionObject.getSessionName()))); output.writeZero(pad); }
From source file:org.opendaylight.protocol.util.ByteBufWriteUtil.java
License:Open Source License
/** * Writes 32-bit integer <code>value</code> if not null, otherwise writes * zeros to the <code>output</code> ByteBuf. ByteBuf's writerIndex is * increased by 4./*from www . java 2s. com*/ * * @param value * Integer value to be written to the output. * @param output * ByteBuf, where value or zeros are written. */ public static void writeInt(final Integer value, final ByteBuf output) { if (value != null) { output.writeInt(value); } else { output.writeZero(INT_BYTES_LENGTH); } }
From source file:org.opendaylight.protocol.util.ByteBufWriteUtil.java
License:Open Source License
/** * Writes 24-bit integer <code>value</code> if not null, otherwise writes * zeros to the <code>output</code> ByteBuf. ByteBuf's writerIndex is * increased by 3./*from www .j a va 2s . com*/ * * @param value * Medium value to be written to the output. * @param output * ByteBuf, where value or zeros are written. */ public static void writeMedium(final Integer value, final ByteBuf output) { if (value != null) { output.writeMedium(value); } else { output.writeZero(MEDIUM_BYTES_LENGTH); } }
From source file:org.opendaylight.protocol.util.ByteBufWriteUtil.java
License:Open Source License
/** * Writes 16-bit short <code>value</code> if not null, otherwise writes * zeros to the <code>output</code> ByteBuf. ByteBuf's writerIndex is * increased by 2./*from w w w . ja v a 2s.c o m*/ * * @param value * Short value to be written to the output. * @param output * ByteBuf, where value or zeros are written. */ public static void writeShort(final Short value, final ByteBuf output) { if (value != null) { output.writeShort(value); } else { output.writeZero(SHORT_BYTES_LENGTH); } }
From source file:org.opendaylight.protocol.util.ByteBufWriteUtil.java
License:Open Source License
/** * Writes 64-bit long <code>value</code> if not null, otherwise writes zeros * to the <code>output</code> ByteBuf. ByteBuf's writerIndex is increased by * 8.//from w ww .ja v a 2s . c o m * * @param value * Long value to be written to the output. * @param output * ByteBuf, where value or zeros are written. */ public static void writeLong(final Long value, final ByteBuf output) { if (value != null) { output.writeLong(value); } else { output.writeZero(LONG_BYTES_LENGTH); } }
From source file:org.opendaylight.protocol.util.ByteBufWriteUtil.java
License:Open Source License
/** * Writes boolean <code>value</code> if not null, otherwise writes zero to * the <code>output</code> ByteBuf. ByteBuf's writerIndex is increased by 1. * * @param value/* w w w.j a va2 s . c o m*/ * Boolean value to be written to the output. * @param output * ByteBuf, where value or zero is written. */ public static void writeBoolean(final Boolean value, final ByteBuf output) { if (value != null) { output.writeBoolean(value); } else { output.writeZero(ONE_BYTE_LENGTH); } }
From source file:org.opendaylight.protocol.util.ByteBufWriteUtil.java
License:Open Source License
/** * Writes unsigned byte <code>value</code> if not null, otherwise writes * zero to the <code>output</code> ByteBuf. ByteBuf's writerIndex is * increased by 1.// www. ja va 2 s.com * * @param value * Short value to be write to the output. * @param output * ByteBuf, where value or zeros are written. */ public static void writeUnsignedByte(final Short value, final ByteBuf output) { if (value != null) { output.writeByte(value); } else { output.writeZero(ONE_BYTE_LENGTH); } }
From source file:org.opendaylight.protocol.util.ByteBufWriteUtil.java
License:Open Source License
/** * Writes unsigned 16-bit short integer <code>value</code> if not null, * otherwise writes zeros to the <code>output</code> ByteBuf. ByteBuf's * writerIndex is increased by 2./*from w w w . j av a2 s . c om*/ * * @param value * Integer value to be written to the output. * @param output * ByteBuf, where value or zeros are written. */ public static void writeUnsignedShort(final Integer value, final ByteBuf output) { if (value != null) { output.writeShort(value.shortValue()); } else { output.writeZero(SHORT_BYTES_LENGTH); } }
From source file:org.opendaylight.protocol.util.ByteBufWriteUtil.java
License:Open Source License
/** * Writes unsigned 32-bit integer <code>value</code> if not null, otherwise * writes zeros to the <code>output</code> ByteBuf. ByteBuf's writerIndex is * increased by 4./*ww w . j a v a2 s.co m*/ * * @param value * Long value to be written to the output. * @param output * ByteBuf, where value or zeros are written. */ public static void writeUnsignedInt(final Long value, final ByteBuf output) { if (value != null) { output.writeInt(value.intValue()); } else { output.writeZero(INT_BYTES_LENGTH); } }