public static Xid stringToXid(String s) {
    RecoveredXid xid = new RecoveredXid();

    int a = s.indexOf('_');
    int b = s.lastIndexOf('_');

    if (a == b) {
      // this also catches the case a == b == -1.
      return null;
    }

    try {
      xid.formatId = Integer.parseInt(s.substring(0, a));
      xid.globalTransactionId = Base64.decode(s.substring(a + 1, b));
      xid.branchQualifier = Base64.decode(s.substring(b + 1));

      if (xid.globalTransactionId == null || xid.branchQualifier == null) {
        return null;
      }
    } catch (Exception ex) {
      return null; // Doesn't seem to be an xid generated by this driver.
    }

    return xid;
  }
public static Xid stringToXid ( String s ) { RecoveredXid xid = new RecoveredXid ( ) ; int a = s . indexOf ( '_' ) ; int b = s . lastIndexOf ( '_' ) ; if ( a == b ) { return null ; } try { xid . formatId = Integer . parseInt ( s . substring ( 0 , a ) ) ; xid . globalTransactionId = Base64 . decode ( s . substring ( a + 1 , b ) ) ; xid . branchQualifier = Base64 . decode ( s . substring ( b + 1 ) ) ; if ( xid . globalTransactionId == null || xid . branchQualifier == null ) { return null ; } } catch ( Exception ex ) { return null ; } return xid ; }
@param s The string to convert
@return recovered xid, or null if s does not represent a valid xid encoded by the driver.