53 lines
1.3 KiB
Java
53 lines
1.3 KiB
Java
package org.hwo.servicelink.register.basetypes;
|
|
|
|
import javax.xml.xpath.XPath;
|
|
import javax.xml.xpath.XPathConstants;
|
|
import javax.xml.xpath.XPathFactory;
|
|
|
|
import org.hwo.servicelink.register.RegisterType;
|
|
import org.hwo.servicelink.register.ServiceRegisterList;
|
|
import org.w3c.dom.Node;
|
|
import org.w3c.dom.NodeList;
|
|
|
|
public class BitField extends RegisterType{
|
|
|
|
org.hwo.bitfields.BitField bitfield;
|
|
|
|
public BitField() {
|
|
super("BitField");
|
|
this.bitfield = new org.hwo.bitfields.BitField();
|
|
}
|
|
|
|
@Override
|
|
public void createFromTypeNode(Node typeNode) {
|
|
try {
|
|
Node fieldsNode = (Node)getXPath().evaluate("Fields", typeNode, XPathConstants.NODE);
|
|
this.bitfield.fieldsFromXML(fieldsNode);
|
|
} catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getDisplayValue(Object regValue) {
|
|
return this.bitfield.toText(valueAsInteger(regValue));
|
|
}
|
|
|
|
@Override
|
|
public RegisterType createRegisterTypeInstance(ServiceRegisterList serviceRegisterList, Node registerNode) {
|
|
RegisterType rt = super.createRegisterTypeInstance(serviceRegisterList, registerNode);
|
|
try {
|
|
Node fieldsNode = (Node)getXPath().evaluate("Fields", registerNode, XPathConstants.NODE);
|
|
if (fieldsNode != null){
|
|
bitfield.fieldsFromXML(fieldsNode);
|
|
}
|
|
} catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
|
|
|
|
}
|