Here you can find the source of writeXid(ByteBuffer logBuf, Xid xid)
public static void writeXid(ByteBuffer logBuf, Xid xid)
//package com.java2s; /*-//ww w . j av a 2 s.c o m * See the file LICENSE for redistribution information. * * Copyright (c) 2002-2010 Oracle. All rights reserved. * */ import java.nio.ByteBuffer; import javax.transaction.xa.Xid; public class Main { public static void writeXid(ByteBuffer logBuf, Xid xid) { byte[] gid = xid.getGlobalTransactionId(); byte[] bqual = xid.getBranchQualifier(); writeInt(logBuf, xid.getFormatId()); if (gid == null) { logBuf.put((byte) -1); } else { logBuf.put((byte) (gid.length)); logBuf.put(gid); } if (bqual == null) { logBuf.put((byte) -1); } else { logBuf.put((byte) (bqual.length)); logBuf.put(bqual); } } /** * Write an int into the log. */ public static void writeInt(ByteBuffer logBuf, int i) { byte b = (byte) ((i >> 0) & 0xff); logBuf.put(b); b = (byte) ((i >> 8) & 0xff); logBuf.put(b); b = (byte) ((i >> 16) & 0xff); logBuf.put(b); b = (byte) ((i >> 24) & 0xff); logBuf.put(b); } }