本文整理汇总了Java中java.util.BitSet.length方法的典型用法代码示例。如果您正苦于以下问题:Java BitSet.length方法的具体用法?Java BitSet.length怎么用?Java BitSet.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.BitSet
的用法示例。
在下文中一共展示了BitSet.length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMessageForConsistency
import java.util.BitSet; //导入方法依赖的package包/类
/**
* 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 \"GeographicalRegion\" 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\"Regions\" needs to be set\n");
}
return message.toString();
}
示例2: getMessageForConsistency
import java.util.BitSet; //导入方法依赖的package包/类
/**
* 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();
}
示例3: getMessageForConsistency
import java.util.BitSet; //导入方法依赖的package包/类
/**
* 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 \"Switch\" 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);
return message.toString();
}
示例4: marshal
import java.util.BitSet; //导入方法依赖的package包/类
@Override
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
final BitSet bitSet = (BitSet)source;
final StringBuilder buffer = new StringBuilder();
boolean seenFirst = false;
for (int i = 0; i < bitSet.length(); i++) {
if (bitSet.get(i)) {
if (seenFirst) {
buffer.append(',');
} else {
seenFirst = true;
}
buffer.append(i);
}
}
writer.setValue(buffer.toString());
}
示例5: getMessageForConsistency
import java.util.BitSet; //导入方法依赖的package包/类
/**
* 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 \"EnergyConsumer\" 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\"LoadResponse\" needs to be set\n");
}
return message.toString();
}
示例6: main
import java.util.BitSet; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
BitSet a = new BitSet();
BitSet b = new BitSet();
a.set(0);
a.set(70);
b.set(40);
a.and(b);
if (a.length() != 0)
throw new RuntimeException("Incorrect length after and().");
}
示例7: insertAt
import java.util.BitSet; //导入方法依赖的package包/类
/** Inserts specified amount of bits into the set.
*/
private static BitSet insertAt (BitSet b, int at, int len, int size) {
BitSet before = b.get (0, at);
BitSet res = new BitSet (size);
res.or (before);
int max = b.length ();
while (at < max) {
res.set (at + len, b.get (at));
at++;
}
return res;
}
示例8: removeAt
import java.util.BitSet; //导入方法依赖的package包/类
/** Removes specified amount of bits from the set.
*/
private static BitSet removeAt (BitSet b, int at, int len, int newSize) {
BitSet clone = (BitSet)b.clone ();
int max = b.length ();
while (at < max) {
clone.set (at, b.get (at + len));
at++;
}
clone.set (newSize, b.size (), false);
return clone;
}
示例9: assertIndex
import java.util.BitSet; //导入方法依赖的package包/类
private void assertIndex(final BitSet expected) throws IOException, InterruptedException {
for (int i=0; i < expected.length(); i++) {
final Collection<? extends IndexDocument> res = index.query("bin", Integer.toBinaryString(i), Queries.QueryKind.EXACT, "bin","oct");
boolean should = expected.get(i);
assertEquals(should, res.size()==1);
if (should) {
assertEquals(res.iterator().next().getValue("bin"), Integer.toBinaryString(i));
assertEquals(res.iterator().next().getValue("oct"), Integer.toOctalString(i));
}
}
}
示例10: write
import java.util.BitSet; //导入方法依赖的package包/类
public void write(JsonWriter out, BitSet src) throws IOException {
if (src == null) {
out.nullValue();
return;
}
out.beginArray();
for (int i = 0; i < src.length(); i++) {
int value = (src.get(i)) ? 1 : 0;
out.value(value);
}
out.endArray();
}
示例11: getMessageForConsistency
import java.util.BitSet; //导入方法依赖的package包/类
/**
* 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 \"ControlAreaGeneratingUnit\" 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\"GeneratingUnit\" needs to be set\n");
}
if (isNotSet.get(1)) {
message.append("\t\"ControlArea\" needs to be set\n");
}
return message.toString();
}
示例12: convert
import java.util.BitSet; //导入方法依赖的package包/类
private static long convert(BitSet bits) {
long value = 0L;
for (int i = 0; i < bits.length(); ++i) {
value += bits.get(i) ? (1L << i) : 0L;
}
return value;
}
示例13: getMessageForConsistency
import java.util.BitSet; //导入方法依赖的package包/类
/**
* 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 \"IdentifiedObject\" 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\"description\" needs to be set\n");
}
if (isNotSet.get(1)) {
message.append("\t\"aliasName\" needs to be set\n");
}
if (isNotSet.get(2)) {
message.append("\t\"name\" needs to be set\n");
}
return message.toString();
}
示例14: getMessageForConsistency
import java.util.BitSet; //导入方法依赖的package包/类
/**
* 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 \"SubGeographicalRegion\" 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\"Region\" needs to be set\n");
}
if (isNotSet.get(1)) {
message.append("\t\"Substations\" needs to be set\n");
}
return message.toString();
}
示例15: getMessageForConsistency
import java.util.BitSet; //导入方法依赖的package包/类
/**
* 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 \"SvTapStep\" 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\"continuousPosition\" needs to be set\n");
}
if (isNotSet.get(1)) {
message.append("\t\"TapChanger\" needs to be set\n");
}
return message.toString();
}