Java Bit Value Set bit_marker(String attribute, String type, int maxBits, int bit, boolean on)

Here you can find the source of bit_marker(String attribute, String type, int maxBits, int bit, boolean on)

Description

bimarker

License

Open Source License

Declaration

private static String bit_marker(String attribute, String type, int maxBits, int bit, boolean on) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static String bit_marker(String attribute, String type, int maxBits, int bit, boolean on) {
        if (bit >= maxBits)
            throw new RuntimeException("bit is greater than maxbits");
        StringBuilder result = new StringBuilder(attribute.length() + maxBits + type.length() + 2);
        StringBuilder bitmarks = new StringBuilder(maxBits + 1);
        result.append(attribute).append('_').append(type).append('_');
        for (int i = 0; i < maxBits; i++) {
            bitmarks.append('x');
        }/*ww w .ja va  2  s .com*/
        bitmarks.setCharAt(maxBits - bit - 1, on ? '1' : '0');
        return result.append(bitmarks).toString();
    }
}

Related

  1. bit_marker_flexint(String attribute, int bit, boolean on)
  2. bit_marker_geohash(String attribute, int bit, boolean on)
  3. bitIsSet(byte data, byte bit)
  4. bitIsSet(int i, int offset)