1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package com.google.gwt.uibinder.elementparsers;
19
20 import org.w3c.dom.Element;
21
22 import com.google.gwt.core.ext.UnableToCompleteException;
23 import com.google.gwt.uibinder.rebind.UiBinderWriter;
24 import com.google.gwt.uibinder.rebind.XMLElement;
25 import com.google.gwt.uibinder.rebind.XMLElement.Interpreter;
26
27 public class SvgInterpreter implements XMLElement.Interpreter<String> {
28 public static SvgInterpreter newInterpreterForUiObject(
29 UiBinderWriter writer, String uiExpression, Element root) {
30 String ancestorExpression = uiExpression;
31 return new SvgInterpreter(writer, ancestorExpression, root,
32 new HtmlMessageInterpreter(writer, ancestorExpression));
33 }
34
35 private final UiBinderWriter writer;
36 private final InterpreterPipe<String> pipe;
37
38 public SvgInterpreter(UiBinderWriter writer, String ancestorExpression, Element root,
39 Interpreter<String> messageInterpreter) {
40 this.writer = writer;
41 this.pipe = new InterpreterPipe<String>();
42
43 pipe.add(new SvgFieldInterpreter(writer, ancestorExpression, root));
44 pipe.add(new ComputedAttributeInterpreter(writer));
45 pipe.add(new AttributeMessageInterpreter(writer));
46 pipe.add(messageInterpreter);
47 }
48
49 public String interpretElement(XMLElement elem)
50 throws UnableToCompleteException {
51 if (writer.isWidgetElement(elem)) {
52 writer.die("Found widget %s in an SVG context", elem);
53 }
54 return pipe.interpretElement(elem);
55 }
56 }