Here you can find the source of serializeNullableString(ByteBuffer outputBuffer, String value)
Parameter | Description |
---|---|
outputBuffer | The output buffer to serialize the value to |
value | The value to serialize |
public static void serializeNullableString(ByteBuffer outputBuffer, String value)
//package com.java2s; /**/*w w w. j av a 2 s. c om*/ * Copyright 2016 LinkedIn Corp. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ import java.nio.ByteBuffer; public class Main { /** * Serializes a nullable string into byte buffer * * @param outputBuffer The output buffer to serialize the value to * @param value The value to serialize */ public static void serializeNullableString(ByteBuffer outputBuffer, String value) { if (value == null) { outputBuffer.putInt(0); } else { outputBuffer.putInt(value.length()); outputBuffer.put(value.getBytes()); } } }