Example usage for java.math BigInteger and

List of usage examples for java.math BigInteger and

Introduction

In this page you can find the example usage for java.math BigInteger and.

Prototype

public BigInteger and(BigInteger val) 

Source Link

Document

Returns a BigInteger whose value is (this & val) .

Usage

From source file:nl.minvenj.pef.pseudo.IPPseudonymizer.java

private byte[] pseudonymize(final byte[] ipAddress, final int bitCount, final int mask,
        final int changeBitCount) {
    final BigInteger ipBigInt = new BigInteger(1, ipAddress);
    final String ipString = ipBigInt.toString(RADIX);

    final BigInteger bigIntMask = BigInteger.ONE.shiftLeft(bitCount - mask).subtract(BigInteger.ONE);

    final String bitStringToEncrypt = ipBigInt.and(bigIntMask).toString(RADIX);
    final String bitStringToEncryptPadded = Util.padZeroLeft(bitStringToEncrypt,
            changeBitCount - bitStringToEncrypt.length());

    final String encrypted = _encrypter.encrypt(TWEAK, bitStringToEncryptPadded);

    final int keptBitCount = ipString.length() - changeBitCount;
    // keptBitCount is how many (string) bits to keep there are left in the original string
    // this is not necessarily equal to the mask, due to the conversion from BigInteger
    // since it will get converted to a number, take those left and concat, or if none, just use encrypted
    final String rebuiltBitString = keptBitCount > 0 ? ipString.substring(0, keptBitCount).concat(encrypted)
            : encrypted;//w w w .j  a  v  a2  s .  co m

    return toIPAddressOfSize(new BigInteger(rebuiltBitString, RADIX), ipAddress.length);
}

From source file:com.bigdata.dastor.dht.CollatingOrderPreservingPartitioner.java

/**
 * Convert a (positive) BigInteger into a byte array representing its magnitude.
 * If remainder is true, an additional byte with the high order bit enabled
 * will be added to the end of the array
 *//*from w w w .  j a va2 s . c om*/
private byte[] bytesForBig(BigInteger big, int sigbytes, boolean remainder) {
    byte[] bytes = new byte[sigbytes + (remainder ? 1 : 0)];
    if (remainder) {
        // remaining bit is the most significant in the last byte
        bytes[sigbytes] |= 0x80;
    }
    // bitmask for a single byte
    for (int i = 0; i < sigbytes; i++) {
        int maskpos = 8 * (sigbytes - (i + 1));
        // apply bitmask and get byte value
        bytes[i] = (byte) (big.and(BYTE_MASK.shiftLeft(maskpos)).shiftRight(maskpos).intValue() & 0xFF);
    }
    return bytes;
}

From source file:org.rifidi.emulator.reader.epc.commandhandler.EPCSource.java

/**
 * Gets a list of tags using the TagSelectors.
 * //from   ww w  .  jav  a  2s .c  om
 * @param arg
 * @param asr
 * @return
 */
public CommandObject readIDs(CommandObject arg, AbstractReaderSharedResources asr) {
    String[] nameSplit = arg.getCurrentQueryName().split("\\.");
    String name = nameSplit[0];

    GenericRadio newRadio = asr.getRadio();
    EPCTagMemory memory;

    Set<Integer> antennaKeySet = new HashSet<Integer>();

    Integer z;
    for (String x : asr.getSourceMap().get(name).getReadPoints()) {
        z = Integer.valueOf(x);
        antennaKeySet.add(z);
    }

    memory = (EPCTagMemory) asr.getTagMemory();
    newRadio.scan(antennaKeySet, memory);
    Collection<RifidiTag> tagList = memory.getTagReport();

    Set<String> tagListSet = new HashSet<String>();

    for (RifidiTag t : tagList) {
        tagListSet.add(ByteAndHexConvertingUtility.toHexString(t.getTag().readId()).replace(" ", ""));
    }

    for (TagSelector selector : asr.getSourceMap().get(name).getTagSelectors().values()) {
        ArrayList<String> removeString = new ArrayList<String>();
        for (String tag : tagListSet) {
            BigInteger mask = new BigInteger(selector.getMask(), 16);
            BigInteger value = new BigInteger(selector.getValue(), 16);
            BigInteger tagBig = new BigInteger(tag, 16);
            if (selector.getInclusiveFlag()) {
                if (!tagBig.and(mask).equals(tagBig.and(value))) {
                    removeString.add(tag);
                }
            } else {
                if (tagBig.and(mask).equals(tagBig.and(value))) {
                    removeString.add(tag);
                }
            }
        }
        for (String i : removeString) {
            tagListSet.remove(i);
        }
    }

    arg.getReturnValue().clear();
    EPCCommon.format_echo(arg, asr);

    String retVal = "";

    for (String tag : tagListSet) {
        retVal += tag + EPCCommon.NEWLINE;
    }

    if (tagListSet.size() == 0) {
        retVal += "(no tags)" + EPCCommon.NEWLINE;
    }

    arg.getReturnValue().add(retVal);

    arg.getReturnValue().add(EPCCommon.NEWLINE);

    EPCCommon.prompt(arg, asr);
    return arg;
}

From source file:dap4.dap4.Dap4Print.java

protected String valueString(Object value, DapType basetype) throws DataException {
    if (value == null)
        return "null";
    AtomicType atype = basetype.getAtomicType();
    boolean unsigned = atype.isUnsigned();
    switch (atype) {
    case Int8://from  ww  w  .  j  a  v a  2s . c  o m
    case UInt8:
        long lvalue = ((Byte) value).longValue();
        if (unsigned)
            lvalue &= 0xFFL;
        return String.format("%d", lvalue);
    case Int16:
    case UInt16:
        lvalue = ((Short) value).longValue();
        if (unsigned)
            lvalue &= 0xFFFFL;
        return String.format("%d", lvalue);
    case Int32:
    case UInt32:
        lvalue = ((Integer) value).longValue();
        if (unsigned)
            lvalue &= 0xFFFFFFFFL;
        return String.format("%d", lvalue);
    case Int64:
    case UInt64:
        lvalue = ((Long) value).longValue();
        if (unsigned) {
            BigInteger b = BigInteger.valueOf(lvalue);
            b = b.and(DapUtil.BIG_UMASK64);
            return b.toString();
        } else
            return String.format("%d", lvalue);
    case Float32:
        return String.format("%f", ((Float) value).floatValue());
    case Float64:
        return String.format("%f", ((Double) value).doubleValue());
    case Char:
        return "'" + ((Character) value).toString() + "'";
    case String:
    case URL:
        return "\"" + ((String) value) + "\"";
    case Opaque:
        ByteBuffer opaque = (ByteBuffer) value;
        String s = "0x";
        for (int i = 0; i < opaque.limit(); i++) {
            byte b = opaque.get(i);
            char c = hexchar((b >> 4) & 0xF);
            s += c;
            c = hexchar((b) & 0xF);
            s += c;
        }
        return s;
    case Enum:
        return valueString(value, ((DapEnum) basetype).getBaseType());
    default:
        break;
    }
    throw new DataException("Unknown type: " + basetype);
}

From source file:org.rifidi.emulator.reader.alien.commandhandler.AlienTag.java

/**
 * Gets and sets the type of the tag to return.
 * /*w ww.j  av  a2  s  .  c  o  m*/
 * @param arg
 *            The CommandObject which contains the information from the
 *            method.
 * @param asr
 *            An Alien Shared Resources Object which is needed for access to
 *            Radio, TagMemory and so on
 * @return The CommandObject, unmodified if the command was a get, modified
 *         if the command is a set.
 */
public CommandObject tagType(CommandObject arg, AbstractReaderSharedResources asr) {

    ArrayList<Object> retValArray = new ArrayList<Object>();
    if (arg.getArguments().size() > 0) {

        if (!AlienCommon.checkIntegerArg(arg)) {
            ArrayList<Object> retVal;
            String i = arg.getCurrentQueryName();
            ArrayList<Object> tempVal = new ArrayList<Object>();
            tempVal.add(i);
            retVal = new AlienExceptionHandler().invalidCommandError(tempVal, "Integer", arg);
            arg.setReturnValue(retVal);
            return arg;
        }

        Integer intVal = new Integer(((String) arg.getArguments().get(0)));
        if (intVal < 1 || intVal > 31) {
            // Here we have to catch a possible range-based error
            if (!arg.getPromptSuppress()) {
                retValArray.add(arg.getCurrentQueryName() + AlienCommon.NEWLINE
                        + "Error 10: Value out of range.  Legal limits" + " are between 1 and 31."
                        + AlienCommon.NEWLINE + AlienCommon.ENDOFREPLY + AlienCommon.NONZEROPROMPT);
            } else {
                retValArray.add(arg.getCurrentQueryName() + AlienCommon.NEWLINE
                        + "Error 10: Value out of range.  Legal limits" + " are between 1 and 31."
                        + AlienCommon.ENDOFREPLY);
            }
            arg.setReturnValue(retValArray);
            return arg;
        }

        BigInteger newInt = new BigInteger(String.valueOf(intVal.intValue()));
        BigInteger sixteen = new BigInteger("16");
        BigInteger four = new BigInteger("4");
        BigInteger two = new BigInteger("2");
        BigInteger one = new BigInteger("1");

        HashSet<TagGen> types = new HashSet<TagGen>();

        // Doing bitwise operations with BigInteger. If any of the 3 least
        // significant bits are 1, we read gen1 tags
        if (newInt.and(four).intValue() != 0 || newInt.and(two).intValue() != 0
                || newInt.and(one).intValue() != 0) {
            types.add(TagGen.GEN1);
        }

        // If the most significant bit is 1, we read gen2 tags
        if (newInt.and(sixteen).intValue() != 0) {
            types.add(TagGen.GEN2);
        }

        AlienTagMemory tm = (AlienTagMemory) asr.getTagMemory();
        tm.setTagTypeSelection(types);
    }

    return AlienCommon.getter_setter(arg, asr);
}

From source file:android_network.hetnet.vpn_service.ServiceSinkhole.java

public static List<InetAddress> getDns(Context context) {
    List<InetAddress> listDns = new ArrayList<>();
    List<String> sysDns = Util.getDefaultDNS(context);

    // Get custom DNS servers
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    String vpnDns1 = prefs.getString("dns", null);
    String vpnDns2 = prefs.getString("dns2", null);
    Log.i(TAG, "DNS system=" + TextUtils.join(",", sysDns) + " VPN1=" + vpnDns1 + " VPN2=" + vpnDns2);

    if (vpnDns1 != null)
        try {/*from  w  w w .j  av a 2 s  .  co  m*/
            InetAddress dns = InetAddress.getByName(vpnDns1);
            if (!(dns.isLoopbackAddress() || dns.isAnyLocalAddress()))
                listDns.add(dns);
        } catch (Throwable ignored) {
        }

    if (vpnDns2 != null)
        try {
            InetAddress dns = InetAddress.getByName(vpnDns2);
            if (!(dns.isLoopbackAddress() || dns.isAnyLocalAddress()))
                listDns.add(dns);
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

    // Use system DNS servers only when no two custom DNS servers specified
    if (listDns.size() <= 1)
        for (String def_dns : sysDns)
            try {
                InetAddress ddns = InetAddress.getByName(def_dns);
                if (!listDns.contains(ddns) && !(ddns.isLoopbackAddress() || ddns.isAnyLocalAddress()))
                    listDns.add(ddns);
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
            }

    // Remove local DNS servers when not routing LAN
    boolean lan = prefs.getBoolean("lan", false);
    if (lan) {
        List<InetAddress> listLocal = new ArrayList<>();
        try {
            Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
            if (nis != null)
                while (nis.hasMoreElements()) {
                    NetworkInterface ni = nis.nextElement();
                    if (ni != null && ni.isUp() && !ni.isLoopback()) {
                        List<InterfaceAddress> ias = ni.getInterfaceAddresses();
                        if (ias != null)
                            for (InterfaceAddress ia : ias) {
                                InetAddress hostAddress = ia.getAddress();
                                BigInteger host = new BigInteger(1, hostAddress.getAddress());

                                int prefix = ia.getNetworkPrefixLength();
                                BigInteger mask = BigInteger.valueOf(-1)
                                        .shiftLeft(hostAddress.getAddress().length * 8 - prefix);

                                for (InetAddress dns : listDns)
                                    if (hostAddress.getAddress().length == dns.getAddress().length) {
                                        BigInteger ip = new BigInteger(1, dns.getAddress());

                                        if (host.and(mask).equals(ip.and(mask))) {
                                            Log.i(TAG, "Local DNS server host=" + hostAddress + "/" + prefix
                                                    + " dns=" + dns);
                                            listLocal.add(dns);
                                        }
                                    }
                            }
                    }
                }
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

        List<InetAddress> listDns4 = new ArrayList<>();
        List<InetAddress> listDns6 = new ArrayList<>();
        try {
            listDns4.add(InetAddress.getByName("8.8.8.8"));
            listDns4.add(InetAddress.getByName("8.8.4.4"));
            listDns6.add(InetAddress.getByName("2001:4860:4860::8888"));
            listDns6.add(InetAddress.getByName("2001:4860:4860::8844"));

        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

        for (InetAddress dns : listLocal) {
            listDns.remove(dns);
            if (dns instanceof Inet4Address) {
                if (listDns4.size() > 0) {
                    listDns.add(listDns4.get(0));
                    listDns4.remove(0);
                }
            } else {
                if (listDns6.size() > 0) {
                    listDns.add(listDns6.get(0));
                    listDns6.remove(0);
                }
            }
        }
    }

    // Prefer IPv4 addresses
    Collections.sort(listDns, new Comparator<InetAddress>() {
        @Override
        public int compare(InetAddress a, InetAddress b) {
            boolean a4 = (a instanceof Inet4Address);
            boolean b4 = (b instanceof Inet4Address);
            if (a4 && !b4)
                return -1;
            else if (!a4 && b4)
                return 1;
            else
                return 0;
        }
    });

    return listDns;
}

From source file:eu.faircode.netguard.ServiceSinkhole.java

public static List<InetAddress> getDns(Context context) {
    List<InetAddress> listDns = new ArrayList<>();
    List<String> sysDns = Util.getDefaultDNS(context);

    // Get custom DNS servers
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean ip6 = prefs.getBoolean("ip6", true);
    String vpnDns1 = prefs.getString("dns", null);
    String vpnDns2 = prefs.getString("dns2", null);
    Log.i(TAG, "DNS system=" + TextUtils.join(",", sysDns) + " VPN1=" + vpnDns1 + " VPN2=" + vpnDns2);

    if (vpnDns1 != null)
        try {//from  w w w  .j a  v a2  s  .  co m
            InetAddress dns = InetAddress.getByName(vpnDns1);
            if (!(dns.isLoopbackAddress() || dns.isAnyLocalAddress()) && (ip6 || dns instanceof Inet4Address))
                listDns.add(dns);
        } catch (Throwable ignored) {
        }

    if (vpnDns2 != null)
        try {
            InetAddress dns = InetAddress.getByName(vpnDns2);
            if (!(dns.isLoopbackAddress() || dns.isAnyLocalAddress()) && (ip6 || dns instanceof Inet4Address))
                listDns.add(dns);
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

    // Use system DNS servers only when no two custom DNS servers specified
    if (listDns.size() <= 1)
        for (String def_dns : sysDns)
            try {
                InetAddress ddns = InetAddress.getByName(def_dns);
                if (!listDns.contains(ddns) && !(ddns.isLoopbackAddress() || ddns.isAnyLocalAddress())
                        && (ip6 || ddns instanceof Inet4Address))
                    listDns.add(ddns);
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
            }

    // Remove local DNS servers when not routing LAN
    boolean lan = prefs.getBoolean("lan", false);
    boolean use_hosts = prefs.getBoolean("filter", false) && prefs.getBoolean("use_hosts", false);
    if (lan && use_hosts) {
        List<InetAddress> listLocal = new ArrayList<>();
        try {
            Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
            if (nis != null)
                while (nis.hasMoreElements()) {
                    NetworkInterface ni = nis.nextElement();
                    if (ni != null && ni.isUp() && !ni.isLoopback()) {
                        List<InterfaceAddress> ias = ni.getInterfaceAddresses();
                        if (ias != null)
                            for (InterfaceAddress ia : ias) {
                                InetAddress hostAddress = ia.getAddress();
                                BigInteger host = new BigInteger(1, hostAddress.getAddress());

                                int prefix = ia.getNetworkPrefixLength();
                                BigInteger mask = BigInteger.valueOf(-1)
                                        .shiftLeft(hostAddress.getAddress().length * 8 - prefix);

                                for (InetAddress dns : listDns)
                                    if (hostAddress.getAddress().length == dns.getAddress().length) {
                                        BigInteger ip = new BigInteger(1, dns.getAddress());

                                        if (host.and(mask).equals(ip.and(mask))) {
                                            Log.i(TAG, "Local DNS server host=" + hostAddress + "/" + prefix
                                                    + " dns=" + dns);
                                            listLocal.add(dns);
                                        }
                                    }
                            }
                    }
                }
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

        List<InetAddress> listDns4 = new ArrayList<>();
        List<InetAddress> listDns6 = new ArrayList<>();
        try {
            listDns4.add(InetAddress.getByName("8.8.8.8"));
            listDns4.add(InetAddress.getByName("8.8.4.4"));
            if (ip6) {
                listDns6.add(InetAddress.getByName("2001:4860:4860::8888"));
                listDns6.add(InetAddress.getByName("2001:4860:4860::8844"));
            }

        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

        for (InetAddress dns : listLocal) {
            listDns.remove(dns);
            if (dns instanceof Inet4Address) {
                if (listDns4.size() > 0) {
                    listDns.add(listDns4.get(0));
                    listDns4.remove(0);
                }
            } else {
                if (listDns6.size() > 0) {
                    listDns.add(listDns6.get(0));
                    listDns6.remove(0);
                }
            }
        }
    }

    return listDns;
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void updateInstructionUsingBochs(BigInteger address) {
    try {/*from ww w . ja  v  a  2 s .  c o  m*/
        final int maximumLine = 400;
        String command;
        jStatusLabel.setText("Updating instruction");
        if (address == null) {
            BigInteger cs = CommonLib.string2BigInteger(this.registerPanel.jCSTextField.getText());
            BigInteger eip = CommonLib.string2BigInteger(this.registerPanel.eipTextField.getText());
            eip = eip.and(CommonLib.string2BigInteger("0xffffffffffffffff"));
            command = "disasm cs:0x" + eip.toString(16) + " 0x" + cs.toString(16) + ":0x"
                    + eip.add(BigInteger.valueOf(0x400)).toString(16);
        } else {
            command = "disasm " + address + " " + address.add(BigInteger.valueOf(0x400));
        }
        commandReceiver.clearBuffer();
        commandReceiver.shouldShow = false;
        sendCommand(command);
        commandReceiver.waitUntilHaveLine(30);
        String result = commandReceiver.getCommandResultUntilEnd();
        String lines[] = result.split("\n");
        if (lines.length > 0) {
            InstructionTableModel model = (InstructionTableModel) instructionTable.getModel();
            jStatusProgressBar.setMaximum(lines.length - 1);
            for (int x = 0; x < lines.length && x < maximumLine; x++) {
                jStatusProgressBar.setValue(x);
                try {
                    lines[x] = lines[x].replaceFirst("\\<.*\\>", "");
                    String strs[] = lines[x].split(":");
                    int secondColon = lines[x].indexOf(":", lines[x].indexOf(":") + 1);

                    // load cCode
                    String pcStr = strs[0].trim();
                    BigInteger pc = CommonLib.string2BigInteger("0x" + pcStr);
                    if (pc == null) {
                        continue;
                    }
                    String s[] = getCCode(pc, false);
                    String lineNo[] = getCCode(pc, true);
                    if (s != null && lineNo != null) {
                        for (int index = 0; index < s.length; index++) {
                            model.addRow(new String[] { "",
                                    "cCode : 0x" + pc.toString(16) + " : " + lineNo[index], s[index], "" });
                        }
                    }
                    // end load cCode
                    model.addRow(new String[] { "", "0x" + pc.toString(16),
                            lines[x].substring(secondColon + 1).trim().split(";")[0].trim(),
                            lines[x].split(";")[1] });
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }

            model.removeNonOrderInstruction();
            model.fireTableDataChanged();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void jRefreshAddressTranslateButtonActionPerformed(ActionEvent evt) {
    AddressTranslateTableModel model = (AddressTranslateTableModel) this.jAddressTranslateTable2.getModel();

    if (jSearchAddressRadioButton1.isSelected()) {
        if (!this.jAddressTextField.getText().contains(":")
                || this.jAddressTextField.getText().replaceAll("[^:]", "").length() != 1) {
            JOptionPane.showMessageDialog(this,
                    "Error, please input <segment selector>:<offset>\n\ne.g. : 0x10:0x12345678", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return;
        }/*  www . java  2  s.  c  o m*/
        BigInteger segSelector = CommonLib.string2BigInteger(this.jAddressTextField.getText().split(":")[0]);
        BigInteger address = CommonLib.string2BigInteger(this.jAddressTextField.getText().split(":")[1]);

        // for (int x = 0; x < model.getRowCount(); x++) {
        // if (model.searchType.get(x).equals(1) &&
        // model.searchSegSelector.get(x).equals(segSelector) &&
        // model.searchAddress.get(x).equals(address)) {
        // return;
        // }
        // }

        model.searchType.add(1);
        model.searchSegSelector.add(segSelector);
        model.searchAddress.add(address);

        model.virtualAddress.add(address);
        BigInteger segNo = segSelector.shiftRight(3);
        model.segNo.add(segNo);

        // read GDT descriptor
        int descriptor[] = PeterBochsCommonLib
                .getMemoryFromBochs(CommonLib.string2BigInteger(this.registerPanel.jGDTRTextField.getText())
                        .add(segNo.multiply(BigInteger.valueOf(8))), 8);
        BigInteger baseAddress = CommonLib.getBigInteger(descriptor[2], descriptor[3], descriptor[4],
                descriptor[7], 0, 0, 0, 0);
        BigInteger linearAddress = baseAddress.add(address);
        model.baseAddress.add(baseAddress);
        model.linearAddress.add(linearAddress);

        BigInteger pdNo = CommonLib.getBigInteger(linearAddress, 31, 22);
        model.pdNo.add(pdNo);
        int pdeBytes[] = PeterBochsCommonLib
                .getMemoryFromBochs(CommonLib.string2BigInteger(this.registerPanel.jCR3TextField.getText())
                        .add(pdNo.multiply(BigInteger.valueOf(4))), 4);
        BigInteger pde = CommonLib.getBigInteger(pdeBytes, 0);
        model.pde.add(pde);

        BigInteger ptNo = CommonLib.getBigInteger(linearAddress, 21, 12);
        model.ptNo.add(ptNo);
        BigInteger pageTableBaseAddress = pde.and(CommonLib.string2BigInteger("0xfffff000"));
        int pteBytes[] = PeterBochsCommonLib
                .getMemoryFromBochs(pageTableBaseAddress.add(ptNo.multiply(BigInteger.valueOf(4))), 4);
        BigInteger pte = CommonLib.getBigInteger(pteBytes, 0);
        BigInteger pagePhysicalAddress = pte.and(CommonLib.string2BigInteger("0xfffff000"));
        model.pte.add(pte);

        BigInteger physicalAddress = pagePhysicalAddress.add(CommonLib.getBigInteger(linearAddress, 11, 0));
        model.physicalAddress.add(physicalAddress);
        int bytesAtPhysicalAddress[] = PeterBochsCommonLib.getMemoryFromBochs(physicalAddress, 8);
        model.bytes.add(PeterBochsCommonLib.convertToString(bytesAtPhysicalAddress));

        model.fireTableDataChanged();
    } else if (jSearchAddressRadioButton2.isSelected()) {
        // for (int x = 0; x < model.getRowCount(); x++) {
        // if (model.searchType.get(x).equals(2) &&
        // model.searchAddress.get(x).equals(CommonLib.string2long(this.jAddressTextField.getText())))
        // {
        // return;
        // }
        // }
        BigInteger address = CommonLib.string2BigInteger(this.jAddressTextField.getText());

        model.searchType.add(2);
        model.searchAddress.add(address);

        BigInteger baseAddress = BigInteger.ZERO;
        BigInteger linearAddress = baseAddress.add(address);
        model.baseAddress.add(baseAddress);
        model.linearAddress.add(linearAddress);

        BigInteger pdNo = CommonLib.getBigInteger(linearAddress, 31, 22);
        model.pdNo.add(pdNo);
        int pdeBytes[] = PeterBochsCommonLib
                .getMemoryFromBochs(CommonLib.string2BigInteger(this.registerPanel.jCR3TextField.getText())
                        .add(pdNo.multiply(BigInteger.valueOf(4))), 4);
        BigInteger pde = CommonLib.getBigInteger(pdeBytes, 0);
        model.pde.add(pde);

        BigInteger ptNo = CommonLib.getBigInteger(linearAddress, 21, 12);
        model.ptNo.add(ptNo);
        BigInteger pageTableBaseAddress = pde.and(CommonLib.string2BigInteger("0xfffff000"));
        int pteBytes[] = PeterBochsCommonLib
                .getMemoryFromBochs(pageTableBaseAddress.add(ptNo.multiply(BigInteger.valueOf(4))), 4);
        BigInteger pte = CommonLib.getBigInteger(pteBytes, 0);
        BigInteger pagePhysicalAddress = pte.and(CommonLib.string2BigInteger("0xfffff000"));
        model.pte.add(pte);

        BigInteger physicalAddress = pagePhysicalAddress.add(CommonLib.getBigInteger(linearAddress, 11, 0));
        model.physicalAddress.add(physicalAddress);
        int bytesAtPhysicalAddress[] = PeterBochsCommonLib.getMemoryFromBochs(physicalAddress, 8);
        model.bytes.add(PeterBochsCommonLib.convertToString(bytesAtPhysicalAddress));

        model.fireTableDataChanged();
    } else if (jSearchAddressRadioButton3.isSelected()) {
        for (int x = 0; x < model.getRowCount(); x++) {
            if (model.searchType.get(x).equals(3) && model.searchAddress.get(x)
                    .equals(CommonLib.string2long(this.jAddressTextField.getText()))) {
                return;
            }
        }
        BigInteger addr = CommonLib.string2BigInteger(this.jAddressTextField.getText());
        model.searchType.add(3);
        model.searchSegSelector.add(BigInteger.ZERO);
        model.searchAddress.add(addr);
        model.virtualAddress.add(BigInteger.ZERO);
        model.segNo.add(BigInteger.ZERO);
        model.linearAddress.add(BigInteger.ZERO);
        model.pdNo.add(BigInteger.ZERO);
        model.ptNo.add(BigInteger.ZERO);
        model.physicalAddress.add(BigInteger.ZERO);
        model.bytes.add("");

        model.fireTableDataChanged();
    }
}