package org.hwo.bitfields; import java.util.ArrayList; import java.util.List; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class BitField { private Integer value; private List fields; public BitField() { this.fields = new ArrayList(); initialize(); } public BitField(Element fieldsNode) { this.fields = new ArrayList(); NodeList fields = fieldsNode.getElementsByTagName("Field"); for (int i=0;i 0) sb.append(", "); sb.append(st); } } } return sb.toString(); } public synchronized Integer getValue() { return this.value; } public synchronized void setValue(Integer value) { this.value = value; } public synchronized int getValue(int start,int len) { if (value == null) return 0; return (value >> start) & (-1 >> (Integer.SIZE - len)); } public synchronized void setValue(int value,int start,int len) { if (this.value == null) this.value = 0; this.value &= ~((-1 >> (Integer.SIZE - len)) << start); this.value |= (value & (-1 >> (Integer.SIZE - len))) << start; } }