Java源码示例:com.google.gwt.xml.client.Element
示例1
public XmlDebugPanel(TreeTableModel model) {
this.model = model;
nodes = new IdentityHashMap<Object, Element>();
document = XMLParser.createDocument();
root = document.createElement("debug-panel");
initWidget(textArea = new TextArea());
textArea.ensureDebugId("debug-panel-xml");
textArea.setStyleName(Utils.style() + "-xml");
// Build the XML document based on the current state.
document.appendChild(root);
nodes.put(model.getRoot(), root);
build(model.getRoot());
model.addTreeTableModelListener(this);
}
示例2
public Dialog unmarshall(String xml)
{
try {
Document document = XMLParser.parse(xml);
Element root = document.getDocumentElement();
// model
Builder builder = new Builder();
dfsElement(builder, DOMUtils.getFirstChildElement(root));
// dialog
Dialog dialog = new Dialog(new QName(root.getNamespaceURI(), root.getAttribute("id")), builder.build());
return dialog;
} catch (RuntimeException e) {
Window.alert("Faile to parse XML: "+e.getMessage());
throw e;
}
}
示例3
@Override
public void endVisit(Container container) {
if(stack.size()>1){
Node el = stack.pop();
stack.peek().appendChild(el);
}
else if(stack.size()==1)
{
Node root = stack.pop();
Element dialogEl = DOMUtils.createElementNS(document, dialog.getId().getNamespaceURI(), "dialog");
dialogEl.setAttribute("id", dialog.getId().getLocalPart());
dialogEl.appendChild(root);
document.appendChild(dialogEl);
}
else
{
throw new RuntimeException("Parse error");
}
}
示例4
@Override
public Element toXML(Document document, InteractionUnit unit) {
Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
el.setAttribute("id", unit.getId().getLocalPart());
el.setAttribute("label", unit.getLabel());
if(unit instanceof Container)
{
Container container = (Container)unit;
if(container.getTemporalOperator()!=null) {
el.setAttribute("operator", container.getTemporalOperator().toString());
}
}
return el;
}
示例5
public Set<String> getBlockTypeSet() {
Set<String> blockTypes = new HashSet<String>();
String xmlString = blocksArea.getBlocksContent();
Document blockDoc = XMLParser.parse(xmlString);
NodeList blockElements = blockDoc.getElementsByTagName("block");
for (int i = 0; i < blockElements.getLength(); ++i) {
Element blockElem = (Element) blockElements.item(i);
blockTypes.add(blockElem.getAttribute("type"));
}
return blockTypes;
}
示例6
private void parseTest(Node test, Test t) {
Element testEl = (Element) test;
HashMap<Integer, String> args = new HashMap<>();
t.exception = testEl.getAttribute("expect");
Element op = (Element) testEl.getElementsByTagName("op").item(0);
NamedNodeMap attrs = op.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
Node attr = attrs.item(i);
String name = attr.getNodeName();
switch (name) {
case "name":
t.operation = attr.getNodeValue();
break;
default:
if (name.startsWith("arg")) {
int argIdx = Integer.valueOf(name.replace("arg", ""));
args.put(argIdx, attr.getNodeValue());
} else {
// sLogger.severe("-------" + name + "-------");
}
break;
}
}
for (int i = 1; i <= args.size(); i++) {
String argN = args.get(i);
t.arguments.add(argN);
}
t.result = op.getChildNodes().item(0).getNodeValue().trim();
}
示例7
public void nodeAdded(Object parent, Object node, int index) {
Element parentNode = nodes.get(parent);
Element childNode = document.createElement("event");
for (int i = 0; i < model.getColumnCount(); i++) {
childNode.setAttribute(getAttributeName(i), getAttributeValue(node, i));
}
parentNode.appendChild(childNode);
nodes.put(node, childNode);
updateTextArea();
}
示例8
public void nodeRemoved(Object parent, Object node, int index) {
Element parentNode = parent == null ? root : nodes.get(parent);
Element childNode = nodes.get(node);
parentNode.removeChild(childNode);
nodes.remove(node);
updateTextArea();
}
示例9
@Override
public void startVisit(Container container) {
String name = container.getStereotype()!=null ?
container.getStereotype().toString().toLowerCase() : "container";
Element el = getAdapter(name).toXML(document, container);
marshallMapping(container, el);
stack.push(el);
}
示例10
@Override
public void visit(InteractionUnit unit) {
String name = unit.getStereotype()!=null ?
unit.getStereotype().toString().toLowerCase() : resolveType(unit);
Element el = getAdapter(name).toXML(document, unit);
marshallMapping(unit, el);
if(stack.isEmpty())
throw new RuntimeException("Parse error");
stack.peek().appendChild(el);
}
示例11
private void marshallMapping(InteractionUnit unit, Element target)
{
if(unit.hasMapping(MappingType.DMR))
{
DMRMapping mapping = (DMRMapping) unit.getMapping(MappingType.DMR);
Element el = getAdapter("dmr").toXML(document, mapping);
target.appendChild(el);
}
}
示例12
@Override
public Element toXML(Document document, InteractionUnit unit) {
Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
el.setAttribute("id", unit.getId().getLocalPart());
el.setAttribute("label", unit.getLabel());
return el;
}
示例13
@Override
public Element toXML(Document document, InteractionUnit unit) {
Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
el.setAttribute("id", unit.getId().getLocalPart());
el.setAttribute("label", unit.getLabel());
return el;
}
示例14
@Override
public Element toXML(Document document, InteractionUnit unit) {
Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
el.setAttribute("id", unit.getId().getLocalPart());
el.setAttribute("label", unit.getLabel());
return el;
}
示例15
@Override
public Element toXML(Document document, InteractionUnit unit) {
Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
el.setAttribute("id", unit.getId().getLocalPart());
el.setAttribute("label", unit.getLabel());
return el;
}
示例16
@Override
public Element toXML(Document document, InteractionUnit unit) {
Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
el.setAttribute("id", unit.getId().getLocalPart());
el.setAttribute("label", unit.getLabel());
return el;
}
示例17
@Override
public Element toXML(Document document, InteractionUnit unit) {
Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), elementName);
el.setAttribute("id", unit.getId().getLocalPart());
el.setAttribute("label", unit.getLabel());
if(unit instanceof Container)
{
Container container = (Container)unit;
if(container.getTemporalOperator()!=null) {
el.setAttribute("operator", container.getTemporalOperator().toString());
}
}
else if(unit instanceof Trigger)
{
Trigger trigger = (Trigger)unit;
el.setAttribute("type", trigger.getType().toString());
}
else if(unit instanceof Link)
{
Link link = (Link)unit;
el.setAttribute("target", link.getTarget().toString());
}
return el;
}
示例18
@Override
public Element toXML(Document document, InteractionUnit unit) {
Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
el.setAttribute("id", unit.getId().getLocalPart());
el.setAttribute("label", unit.getLabel());
return el;
}
示例19
public TestRun read(String s) {
Document doc = XMLParser.parse(s);
TestRun tr = new TestRun();
Element run = doc.getDocumentElement();
NodeList runChildren = run.getChildNodes();
for (int i = 0; i < runChildren.getLength(); i++) {
Node runChild = runChildren.item(i);
String name = runChild.getNodeName();
switch (name) {
case "desc":
tr.description = trim(runChild.getChildNodes().item(0)
.getNodeValue());
break;
case "precisionModel":
tr.precisionModel = trim(((Element) runChild)
.getAttribute("type"));
break;
case "resultMatcher":
tr.resultMatcher = trim(runChild.getChildNodes().item(0)
.getNodeValue());
break;
case "geometryOperation":
tr.geometryOperation = trim(runChild.getChildNodes().item(0)
.getNodeValue());
break;
case "case":
TestCase tc = new TestCase();
tr.testCases.add(tc);
parseTestCase(runChild, tc);
break;
default:
// sLogger.severe("-------" + name + "-------");
break;
}
}
return tr;
}
示例20
public void valueChanged(Object node, int columnIndex) {
Element element = nodes.get(node);
element.setAttribute(getAttributeName(columnIndex), getAttributeValue(node, columnIndex));
updateTextArea();
}
示例21
public static Element createElementNS(Document doc, String ns, String name)
{
return (Element)NodeImpl.build(_createElementNS(getJSObj(doc), ns, name));
}
示例22
Element toXML(Document doc, T unit);