Java Code Examples for java.util.BitSet

The following are top voted examples for showing how to use java.util.BitSet. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ditb   File: Hbase.java   View source code 6 votes vote down vote up
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, scannerOpenWithStop_result struct) throws org.apache.thrift.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  BitSet optionals = new BitSet();
  if (struct.isSetSuccess()) {
    optionals.set(0);
  }
  if (struct.isSetIo()) {
    optionals.set(1);
  }
  oprot.writeBitSet(optionals, 2);
  if (struct.isSetSuccess()) {
    oprot.writeI32(struct.success);
  }
  if (struct.isSetIo()) {
    struct.io.write(oprot);
  }
}
 
Example 2
Project: iTAP-controller   File: PutRequestMessage.java   View source code 6 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, PutRequestMessage struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  struct.header = new AsyncMessageHeader();
  struct.header.read(iprot);
  struct.setHeaderIsSet(true);
  struct.storeName = iprot.readString();
  struct.setStoreNameIsSet(true);
  struct.key = iprot.readBinary();
  struct.setKeyIsSet(true);
  BitSet incoming = iprot.readBitSet(2);
  if (incoming.get(0)) {
    struct.versionedValue = new VersionedValue();
    struct.versionedValue.read(iprot);
    struct.setVersionedValueIsSet(true);
  }
  if (incoming.get(1)) {
    struct.value = iprot.readBinary();
    struct.setValueIsSet(true);
  }
}
 
Example 3
Project: javaide   File: Form21c.java   View source code 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int sz = regs.size();
    BitSet bits = new BitSet(sz);
    boolean compat = unsignedFitsInByte(regs.get(0).getReg());

    if (sz == 1) {
        bits.set(0, compat);
    } else {
        if (regs.get(0).getReg() == regs.get(1).getReg()) {
            bits.set(0, compat);
            bits.set(1, compat);
        }
    }

    return bits;
}
 
Example 4
Project: letv   File: au.java   View source code 6 votes vote down vote up
public void a(cy cyVar, au auVar) throws cf {
    de deVar = (de) cyVar;
    deVar.a(auVar.a);
    deVar.a(auVar.b);
    deVar.a(auVar.c.size());
    for (Entry entry : auVar.c.entrySet()) {
        deVar.a((String) entry.getKey());
        deVar.a((String) entry.getValue());
    }
    BitSet bitSet = new BitSet();
    if (auVar.p()) {
        bitSet.set(0);
    }
    if (auVar.s()) {
        bitSet.set(1);
    }
    deVar.a(bitSet, 2);
    if (auVar.p()) {
        deVar.a(auVar.d);
    }
    if (auVar.s()) {
        deVar.a(auVar.e);
    }
}
 
Example 5
Project: jdk8u-jdk   File: JMXServiceURL.java   View source code 6 votes vote down vote up
private static int indexOfFirstNotInSet(String s, BitSet set,
                                        int fromIndex) {
    final int slen = s.length();
    int i = fromIndex;
    while (true) {
        if (i >= slen)
            break;
        char c = s.charAt(i);
        if (c >= 128)
            break; // not ASCII
        if (!set.get(c))
            break;
        i++;
    }
    return i;
}
 
Example 6
Project: lighthouse   File: TokenParser.java   View source code 6 votes vote down vote up
/**
 * Extracts from the sequence of chars a token terminated with any of the given delimiters
 * discarding semantically insignificant whitespace characters.
 *
 * @param buf buffer with the sequence of chars to be parsed
 * @param cursor defines the bounds and current position of the buffer
 * @param delimiters set of delimiting characters. Can be {@code null} if the token
 *  is not delimited by any character.
 */
public String parseToken(final ru.radiomayak.http.util.CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters) {
    final StringBuilder dst = new StringBuilder();
    boolean whitespace = false;
    while (!cursor.atEnd()) {
        final char current = buf.charAt(cursor.getPos());
        if (delimiters != null && delimiters.get(current)) {
            break;
        } else if (isWhitespace(current)) {
            skipWhiteSpace(buf, cursor);
            whitespace = true;
        } else {
            if (whitespace && dst.length() > 0) {
                dst.append(' ');
            }
            copyContent(buf, cursor, delimiters, dst);
            whitespace = false;
        }
    }
    return dst.toString();
}
 
Example 7
Project: boohee_v5.6   File: bq$c.java   View source code 6 votes vote down vote up
public void a(cy cyVar, bq bqVar) throws cf {
    de deVar = (de) cyVar;
    deVar.a(bqVar.a);
    deVar.a(bqVar.b);
    deVar.a(bqVar.c);
    deVar.a(bqVar.d);
    deVar.a(bqVar.e);
    deVar.a(bqVar.f);
    deVar.a(bqVar.g);
    deVar.a(bqVar.h);
    deVar.a(bqVar.i);
    BitSet bitSet = new BitSet();
    if (bqVar.H()) {
        bitSet.set(0);
    }
    deVar.a(bitSet, 1);
    if (bqVar.H()) {
        deVar.a(bqVar.j);
    }
}
 
Example 8
Project: lams   File: Operations.java   View source code 6 votes vote down vote up
/** Returns bitset marking states reachable from the initial state. */
private static BitSet getLiveStatesFromInitial(Automaton a) {
  int numStates = a.getNumStates();
  BitSet live = new BitSet(numStates);
  if (numStates == 0) {
    return live;
  }
  LinkedList<Integer> workList = new LinkedList<>();
  live.set(0);
  workList.add(0);

  Transition t = new Transition();
  while (workList.isEmpty() == false) {
    int s = workList.removeFirst();
    int count = a.initTransition(s, t);
    for(int i=0;i<count;i++) {
      a.getNextTransition(t);
      if (live.get(t.dest) == false) {
        live.set(t.dest);
        workList.add(t.dest);
      }
    }
  }

  return live;
}
 
Example 9
Project: ditb   File: TResult.java   View source code 6 votes vote down vote up
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TResult struct) throws org.apache.thrift.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  {
    oprot.writeI32(struct.columnValues.size());
    for (TColumnValue _iter4 : struct.columnValues)
    {
      _iter4.write(oprot);
    }
  }
  BitSet optionals = new BitSet();
  if (struct.isSetRow()) {
    optionals.set(0);
  }
  oprot.writeBitSet(optionals, 1);
  if (struct.isSetRow()) {
    oprot.writeBinary(struct.row);
  }
}
 
Example 10
Project: powsybl-core   File: ConnectivityNodeContainer.java   View source code 6 votes vote down vote up
/**
 * Utility in charge of creating the message when the class is not
 * consistent within a specific context
 *
 * @param minBitset
 *            bitset describing which CIM attributes of this class have
 *            to be set so that it is consistent within a
 *            specific subset context
 * @return the message explaining what is not consistent
 */
private String getMessageForConsistency(final BitSet minBitset) {

    StringBuilder message = new StringBuilder(
            "Instance of \"ConnectivityNodeContainer\" of id \"");
    message.append(this.getId());
    message.append("\" is not consistent in this context:\n");
    /*
     * XOR and then AND
     * The result is :
     * "1" : has not been set and need to be
     * "0" : has been set or is not mandatory
     */

    BitSet isNotSet = new BitSet(minBitset.length());
    isNotSet.or(minBitset);
    // we create a copy of minBitset
    isNotSet.xor(this.currentBitset);
    isNotSet.and(minBitset);

    if (isNotSet.get(0)) {
        message.append("\t\"TopologicalNode\" needs to be set\n");
    }
    return message.toString();
}
 
Example 11
Project: mojo.core   File: NetworkGraph.java   View source code 6 votes vote down vote up
/**
 * The constructor.
 * 
 * @param graph
 *            The workflow graph.
 * @param nodeMap
 *            The map of nodes.
 * @param information
 *            The information for analysis.
 */
public NetworkGraph(WorkflowGraph graph, WGNode[] nodeMap, AnalysisInformation information) {
	super(graph, nodeMap, information);
	this.edges = new NetworkEdge[graph.getEdges().size()];
	this.replaced = new BitSet(this.edges.length);

	int max = 0;
	BitSet forkSet = (BitSet) graph.getForkSet().clone();
	forkSet.or(graph.getOrForkSet());
	BitSet[] outgoing = graph.getOutgoingEdges();
	// Determine the maximum number of outgoing edges of forks
	for (int f = forkSet.nextSetBit(0); f >= 0; f = forkSet.nextSetBit(f + 1)) {
		max = Math.max(outgoing[f].cardinality(), max);
	}
	this.maxAdditionalEdges = edges.length + max * 2;
	this.tmpEdges = new NetworkEdge[maxAdditionalEdges];
	int maxAdditionalNodes = nodeMap.length + max + 1;
	this.incoming = new BitSet[maxAdditionalNodes];
	this.outgoing = new BitSet[maxAdditionalNodes];

	this.capacities = new BitSet(maxAdditionalEdges);
	this.currentFlow = new BitSet(maxAdditionalEdges);

	initialize();
}
 
Example 12
Project: Cobweb   File: ProcessData.java   View source code 6 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, ProcessData struct) throws TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(4);
  if (incoming.get(0)) {
    struct.type = iprot.readI32();
    struct.setTypeIsSet(true);
  }
  if (incoming.get(1)) {
    struct.crcCode = iprot.readI32();
    struct.setCrcCodeIsSet(true);
  }
  if (incoming.get(2)) {
    struct.length = iprot.readI32();
    struct.setLengthIsSet(true);
  }
  if (incoming.get(3)) {
    struct.sessionId = iprot.readI64();
    struct.setSessionIdIsSet(true);
  }
}
 
Example 13
Project: openjdk-jdk10   File: JMXServiceURL.java   View source code 6 votes vote down vote up
private static int indexOfFirstNotInSet(String s, BitSet set,
                                        int fromIndex) {
    final int slen = s.length();
    int i = fromIndex;
    while (true) {
        if (i >= slen)
            break;
        char c = s.charAt(i);
        if (c >= 128)
            break; // not ASCII
        if (!set.get(c))
            break;
        i++;
    }
    return i;
}
 
Example 14
Project: incubator-netbeans   File: LuceneIndexTest.java   View source code 6 votes vote down vote up
@Test
public void testIndexAddDelete() throws Exception {
    for (int i=0; i< 1000; i++) {
        IndexDocument docwrap = IndexManager.createDocument(Integer.toString(i));
        docwrap.addPair("bin", Integer.toBinaryString(i), true, true);
        docwrap.addPair("oct", Integer.toOctalString(i), true, true);
        index.addDocument(docwrap);
    }
    index.store(true);
    BitSet expected = new BitSet(1000);
    expected.set(0, 1000);
    assertIndex(expected);
    for (int i = 100; i<200; i++) {
        index.removeDocument(Integer.toString(i));
        expected.clear(i);
    }
    index.store(true);
    assertIndex(expected);
}
 
Example 15
Project: iTAP-controller   File: HelloMessage.java   View source code 6 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, HelloMessage struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  struct.header = new AsyncMessageHeader();
  struct.header.read(iprot);
  struct.setHeaderIsSet(true);
  BitSet incoming = iprot.readBitSet(3);
  if (incoming.get(0)) {
    struct.nodeId = iprot.readI16();
    struct.setNodeIdIsSet(true);
  }
  if (incoming.get(1)) {
    struct.authScheme = AuthScheme.findByValue(iprot.readI32());
    struct.setAuthSchemeIsSet(true);
  }
  if (incoming.get(2)) {
    struct.authChallengeResponse = new AuthChallengeResponse();
    struct.authChallengeResponse.read(iprot);
    struct.setAuthChallengeResponseIsSet(true);
  }
}
 
Example 16
Project: DStream   File: PredictorHotKeyUtilTest.java   View source code 6 votes vote down vote up
@Test
public void changePositon2(){
    BitSet bitm =new BitSet(16);
    bitm.set(6);
    bitm.set(5);
    System.out.println(bitm);
    long[] lo = bitm.toLongArray();
    if(lo.length > 0){
        for(int j=0;j<lo.length - 1;j++){
            lo[j] = lo[j] >>> 1;
            lo[j] = lo[j] | (lo[j+1] << 63);
        }
        lo[lo.length-1] = lo[lo.length-1] >>> 1;
    }
    bitm = BitSet.valueOf(lo);
    System.out.println(bitm.size());
    System.out.println(bitm);
}
 
Example 17
Project: CompLib   File: Prime.java   View source code 6 votes vote down vote up
public static BitSet primes(int max) {
	BitSet primeSet = new BitSet(max + 1);
	if (max < 2) {
		return primeSet;
	}
	int limit = (int) Math.sqrt(max + 1);
	primeSet.set(2);
	for (int i = 3; i < max + 1; i += 2) {
		primeSet.set(i);
	}
	for (int i = 3; i <= limit; i += 2) {
		if (!primeSet.get(i)) {
			continue;
		}
		for (int j = i * i; j < max; j += i) {
			primeSet.clear(j);
		}
	}
	return primeSet;
}
 
Example 18
Project: monarch   File: RegionVersionHolderJUnitTest.java   View source code 6 votes vote down vote up
/**
 * Return true if bs1 dominates bs2 - meaning that at least all of the bits set in bs2 are set in
 * bs1.
 * 
 * @param bs1
 * @param bs2
 * @return
 */
private boolean dominates(BitSet bs1, BitSet bs2) {
  // bs1 dominates bs2 if it has set at least all of the bits in bs1.
  BitSet copy = new BitSet();
  // Make copy a copy of bit set 2
  copy.or(bs2);

  // Clear all of the bits in copy that are set in bit set 1
  copy.andNot(bs1);

  // If all of the bits have been cleared in copy, that means
  // bit set 1 had at least all of the bits set that were set in
  // bs2
  return copy.isEmpty();

}
 
Example 19
Project: atlas   File: PostInstructionRegisterInfoMethodItem.java   View source code 6 votes vote down vote up
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers) throws IOException {
    int registerNum = registers.nextSetBit(0);
    if (registerNum < 0) {
        return false;
    }

    writer.write('#');
    for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
        RegisterType registerType = analyzedInstruction.getPostInstructionRegisterType(registerNum);

        registerFormatter.writeTo(writer, registerNum);
        writer.write('=');
        registerType.writeTo(writer);
        writer.write(';');
    }
    return true;
}
 
Example 20
Project: scheduler   File: AgentService.java   View source code 6 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, instructionInvokeAsync_args struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(1);
  if (incoming.get(0)) {
    {
      org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
      struct.insList = new ArrayList<Instruct>(_list5.size);
      Instruct _elem6;
      for (int _i7 = 0; _i7 < _list5.size; ++_i7)
      {
        _elem6 = new Instruct();
        _elem6.read(iprot);
        struct.insList.add(_elem6);
      }
    }
    struct.setInsListIsSet(true);
  }
}
 
Example 21
Project: oscm   File: PriceModelAuditLogCollector.java   View source code 6 votes vote down vote up
public void localizePriceModel(DataService ds, Product product,
        Organization customer,
        VOPriceModelLocalization localizationOriginal,
        VOPriceModelLocalization localizationToBeUpdate) {
    ArgumentValidator.notNull("localizationToBeUpdate",
            localizationToBeUpdate);
    ArgumentValidator.notNull("localizationOriginal", localizationOriginal);
    Map<String, LocalizedAuditLogEntryParameters> mapToBeUpdate = prepareLocalizationMap(localizationToBeUpdate);
    Map<String, LocalizedAuditLogEntryParameters> mapOriginal = prepareLocalizationMap(localizationOriginal);
    Map<String, BitSet> localizationMap = collectLocalizationStates(
            mapToBeUpdate, mapOriginal);
    for (String locale : localizationMap.keySet()) {
        boolean descriptionLocalized = isDescriptionLocalized(
                localizationMap, locale);
        boolean licenseLocalized = isLicenseLocalized(localizationMap,
                locale);

        addLogEntryForAuditLogData(ds, product, customer, locale,
                descriptionLocalized, licenseLocalized);
    }
}
 
Example 22
Project: openjdk-jdk10   File: ConcurrentSkipListMapTest.java   View source code 6 votes vote down vote up
/**
 * Submaps of submaps subdivide correctly
 */
public void testRecursiveSubMaps() throws Exception {
    int mapSize = expensiveTests ? 1000 : 100;
    Class cl = ConcurrentSkipListMap.class;
    NavigableMap<Integer, Integer> map = newMap(cl);
    bs = new BitSet(mapSize);

    populate(map, mapSize);
    check(map,                 0, mapSize - 1, true);
    check(map.descendingMap(), 0, mapSize - 1, false);

    mutateMap(map, 0, mapSize - 1);
    check(map,                 0, mapSize - 1, true);
    check(map.descendingMap(), 0, mapSize - 1, false);

    bashSubMap(map.subMap(0, true, mapSize, false),
               0, mapSize - 1, true);
}
 
Example 23
Project: powsybl-core   File: ThermalGeneratingUnit.java   View source code 6 votes vote down vote up
/**
 * Utility in charge of creating the message when the class is not
 * consistent within a specific context
 *
 * @param minBitset
 *            bitset describing which CIM attributes of this class have
 *            to be set so that it is consistent within a
 *            specific subset context
 * @return the message explaining what is not consistent
 */
private String getMessageForConsistency(final BitSet minBitset) {

    StringBuilder message = new StringBuilder(
            "Instance of \"ThermalGeneratingUnit\" of id \"");
    message.append(this.getId());
    message.append("\" is not consistent in this context:\n");
    /*
     * XOR and then AND
     * The result is :
     * "1" : has not been set and need to be
     * "0" : has been set or is not mandatory
     */

    BitSet isNotSet = new BitSet(minBitset.length());
    isNotSet.or(minBitset);
    // we create a copy of minBitset
    isNotSet.xor(this.currentBitset);
    isNotSet.and(minBitset);

    if (isNotSet.get(0)) {
        message.append("\t\"FossilFuels\" needs to be set\n");
    }
    return message.toString();
}
 
Example 24
Project: powsybl-core   File: HydroGeneratingUnit.java   View source code 5 votes vote down vote up
/**
* Constructor of the class HydroGeneratingUnit
*/
protected HydroGeneratingUnit() {

    super.subset = Subset.Equipment;
    this.minBitsets.put(Subset.StateVariables, new BitSet(0));
    this.minBitsets.put(Subset.Topology, new BitSet(0));
    BitSet classBitset = new BitSet(0);
    this.minBitsets.put(Subset.Equipment, classBitset);
}
 
Example 25
Project: boohee_v5.6   File: SmallPatchedDexItemFile.java   View source code 5 votes vote down vote up
public boolean isProtoIdInSmallPatchedDex(String oldDexSign, int indexInPatchedDex) {
    BitSet indices = (BitSet) this.oldDexSignToProtoIdIndicesInSmallPatch.get(oldDexSign);
    if (indices == null) {
        return false;
    }
    return indices.get(indexInPatchedDex);
}
 
Example 26
Project: powsybl-core   File: RegulatingControl.java   View source code 5 votes vote down vote up
/**
* Constructor of the class RegulatingControl
*/
protected RegulatingControl() {

    super.subset = Subset.Equipment;
    this.minBitsets.put(Subset.StateVariables, new BitSet(7));
    this.minBitsets.put(Subset.Topology, new BitSet(7));
    BitSet classBitset = new BitSet(7);
    classBitset.set(1);
    classBitset.set(3);
    classBitset.set(4);
    classBitset.set(5);
    classBitset.set(6);
    this.minBitsets.put(Subset.Equipment, classBitset);
}
 
Example 27
Project: powsybl-core   File: GeographicalRegion.java   View source code 5 votes vote down vote up
/**
* Constructor of the class GeographicalRegion
*/
protected GeographicalRegion() {

    super.subset = Subset.Equipment;
    this.minBitsets.put(Subset.StateVariables, new BitSet(1));
    this.minBitsets.put(Subset.Topology, new BitSet(1));
    BitSet classBitset = new BitSet(1);
    this.minBitsets.put(Subset.Equipment, classBitset);
}
 
Example 28
Project: elasticsearch_my   File: MethodWriter.java   View source code 5 votes vote down vote up
public MethodWriter(int access, Method method, ClassVisitor cw, BitSet statements, CompilerSettings settings) {
    super(Opcodes.ASM5, cw.visitMethod(access, method.getName(), method.getDescriptor(), null, null),
            access, method.getName(), method.getDescriptor());

    this.statements = statements;
    this.settings = settings;
}
 
Example 29
Project: iotdb-jdbc   File: TSIService.java   View source code 5 votes vote down vote up
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, fetchResults_args struct) throws org.apache.thrift.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  BitSet optionals = new BitSet();
  if (struct.isSetReq()) {
    optionals.set(0);
  }
  oprot.writeBitSet(optionals, 1);
  if (struct.isSetReq()) {
    struct.req.write(oprot);
  }
}
 
Example 30
Project: java-android-websocket-client   File: TokenParser.java   View source code 5 votes vote down vote up
public static BitSet INIT_BITSET(final int ... b) {
    final BitSet bitset = new BitSet();
    for (final int aB : b) {
        bitset.set(aB);
    }
    return bitset;
}
 
Example 31
Project: java-android-websocket-client   File: URLCodec.java   View source code 5 votes vote down vote up
/**
 * Encodes an array of bytes into an array of URL safe 7-bit characters. Unsafe characters are escaped.
 *
 * @param urlsafe
 *            bitset of characters deemed URL safe
 * @param bytes
 *            array of bytes to convert to URL safe characters
 * @return array of bytes containing URL safe characters
 */
public static final byte[] encodeUrl(BitSet urlsafe, final byte[] bytes) {
    if (bytes == null) {
        return null;
    }
    if (urlsafe == null) {
        urlsafe = WWW_FORM_URL;
    }

    final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    for (final byte c : bytes) {
        int b = c;
        if (b < 0) {
            b = 256 + b;
        }
        if (urlsafe.get(b)) {
            if (b == ' ') {
                b = '+';
            }
            buffer.write(b);
        } else {
            buffer.write(ESCAPE_CHAR);
            final char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, RADIX));
            final char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, RADIX));
            buffer.write(hex1);
            buffer.write(hex2);
        }
    }
    return buffer.toByteArray();
}
 
Example 32
Project: digraph-parser   File: GraphParser.java   View source code 5 votes vote down vote up
@Override
public void reportAmbiguity(@NotNull Parser recognizer,
							@NotNull DFA dfa,
							int startIndex,
							int stopIndex,
							boolean exact,
							@Nullable BitSet ambigAlts,
							@NotNull ATNConfigSet configs)
{
}
 
Example 33
Project: Cobweb   File: LocalWorkerCrawlerService.java   View source code 5 votes vote down vote up
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, getWorkersStatus_result struct) throws org.apache.thrift.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  BitSet optionals = new BitSet();
  if (struct.isSetSuccess()) {
    optionals.set(0);
  }
  oprot.writeBitSet(optionals, 1);
  if (struct.isSetSuccess()) {
    oprot.writeString(struct.success);
  }
}
 
Example 34
Project: grift   File: GreeterGrpc.java   View source code 5 votes vote down vote up
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, sayHello_args struct) throws org.apache.thrift.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  BitSet optionals = new BitSet();
  if (struct.isSetRequest()) {
    optionals.set(0);
  }
  oprot.writeBitSet(optionals, 1);
  if (struct.isSetRequest()) {
    struct.request.write(oprot);
  }
}
 
Example 35
Project: iTAP-controller   File: VersionedValue.java   View source code 5 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, VersionedValue struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  struct.version = new VectorClock();
  struct.version.read(iprot);
  struct.setVersionIsSet(true);
  BitSet incoming = iprot.readBitSet(1);
  if (incoming.get(0)) {
    struct.value = iprot.readBinary();
    struct.setValueIsSet(true);
  }
}
 
Example 36
Project: iotdb-jdbc   File: TSIService.java   View source code 5 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, cancelOperation_result struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(1);
  if (incoming.get(0)) {
    struct.success = new TSCancelOperationResp();
    struct.success.read(iprot);
    struct.setSuccessIsSet(true);
  }
}
 
Example 37
Project: OpenMessageShaping   File: LZ4FrameOutputStream.java   View source code 5 votes vote down vote up
public FLG(int version, Bits... bits) {
  this.bitSet = new BitSet(8);
  this.version = version;
  if (bits != null) {
    for (Bits bit : bits) {
      bitSet.set(bit.position);
    }
  }
  validate();
}
 
Example 38
Project: powsybl-core   File: HydroPump.java   View source code 5 votes vote down vote up
/**
 * Utility to check whether this class is consistent in a "merged" context
 *
 * @return a ConsistencyCheck instance whose boolean attribute (consistent)
 *         indicates if this class is consistent and whose String attribute
 *         (message)
 *         indicates why this class is not consistent if it is not
 */
@Override
public ConsistencyCheck modelConsistency() {
    BitSet intersection = new BitSet(this.minBitset.length());
    intersection.or(this.minBitset);
    // we create a copy of minBitSet
    intersection.and(this.currentBitset);
    boolean consistent = (this.minBitset.equals(intersection));
    StringBuilder message = new StringBuilder("");

    if (!consistent) {
    message.append(getMessageForConsistency(this.minBitset));
    }
    // consistent = (super.modelConsistency().getLeft()) ? (consistent &&
    // (true)):(consistent && (false))
    // message += (super.modelConsistency(subset)).getRight();

    if (super.modelConsistency().isConsistent()) {
        consistent = consistent && (true);
        message.append((super.modelConsistency()).getMessage());
    } else {
        consistent = consistent && (false);
        message.append((super.modelConsistency()).getMessage());
    }

    return new ConsistencyCheck(consistent, message.toString());
}
 
Example 39
Project: boohee_v5.6   File: SmallPatchedDexItemFile.java   View source code 5 votes vote down vote up
public boolean isTypeListInSmallPatchedDex(String oldDexSign, int indexInPatchedDex) {
    BitSet indices = (BitSet) this.oldDexSignToTypeListIndicesInSmallPatch.get(oldDexSign);
    if (indices == null) {
        return false;
    }
    return indices.get(indexInPatchedDex);
}
 
Example 40
Project: ditb   File: Hbase.java   View source code 5 votes vote down vote up
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, append_args struct) throws org.apache.thrift.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  BitSet optionals = new BitSet();
  if (struct.isSetAppend()) {
    optionals.set(0);
  }
  oprot.writeBitSet(optionals, 1);
  if (struct.isSetAppend()) {
    struct.append.write(oprot);
  }
}