@Test public void attribute() { TypeCoercer typeCoercer = mockTypeCoercer(); BindingSource bindingSource = mockBindingSource(); MarkupWriter writer = new MarkupWriterImpl(xmlModel); Location l = mockLocation(); RenderQueue queue = mockRenderQueue(); replay(); PageElementFactory factory = new PageElementFactoryImpl(typeCoercer, bindingSource); AttributeToken token = new AttributeToken(null, "name", "value", l); RenderCommand element = factory.newAttributeElement(null, token); writer.element("root"); element.render(writer, queue); verify(); assertEquals(writer.toString(), "<?xml version=\"1.0\"?>\n<root name=\"value\"/>"); }
public RenderCommand newAttributeElement(ComponentResources componentResources, final AttributeToken token) { final StringProvider provider = parseAttributeExpansionExpression(token.value, componentResources, token.getLocation()); return new RenderCommand() { public void render(MarkupWriter writer, RenderQueue queue) { writer.attributeNS(token.namespaceURI, token.name, provider.provideString()); } public String toString() { return String.format("AttributeNS[%s %s \"%s\"]", token.namespaceURI, token.name, token.value); } }; }
PageElementFactoryImpl implements PageElementFactory { public RenderCommand newAttributeElement(ComponentResources componentResources, final AttributeToken token) { final StringProvider provider = parseAttributeExpansionExpression(token.value, componentResources, token.getLocation()); return new RenderCommand() { public void render(MarkupWriter writer, RenderQueue queue) { writer.attributeNS(token.namespaceURI, token.name, provider.provideString()); } public String toString() { return String.format("AttributeNS[%s %s \"%s\"]", token.namespaceURI, token.name, token.value); } }; } }
PageElementFactoryImpl implements PageElementFactory { public RenderCommand newAttributeElement(ComponentResources componentResources, final AttributeToken token) { final StringProvider provider = parseAttributeExpansionExpression(token.value, componentResources, token.getLocation()); return new RenderCommand() { public void render(MarkupWriter writer, RenderQueue queue) { writer.attributeNS(token.namespaceURI, token.name, provider.provideString()); } public String toString() { return String.format("AttributeNS[%s %s \"%s\"]", token.namespaceURI, token.name, token.value); } }; } PageElementFactoryImpl(TypeCoercer typeCoercer, BindingSource bindingSource); }
PageElementFactoryImpl implements PageElementFactory { public RenderCommand newAttributeElement(ComponentResources componentResources, final AttributeToken token) { final StringProvider provider = parseAttributeExpansionExpression(token.value, componentResources, token.getLocation()); return new RenderCommand() { public void render(MarkupWriter writer, RenderQueue queue) { writer.attributeNS(token.namespaceURI, token.name, provider.provideString()); } public String toString() { return String.format("AttributeNS[%s %s \"%s\"]", token.namespaceURI, token.name, token.value); } }; } PageElementFactoryImpl(TypeCoercer typeCoercer, BindingSource bindingSource); RenderCommand newAttributeElement(ComponentResources componentResources, final AttributeToken token); RenderCommand newExpansionElement(ComponentResources componentResources, ExpansionToken token); Binding newBinding(String parameterName, ComponentResources loadingComponentResources,
                              ComponentResources embeddedComponentResources, String defaultBindingPrefix,
                              String expression, Location location); }
PageElementFactoryImpl implements PageElementFactory { public RenderCommand newAttributeElement(ComponentResources componentResources, final AttributeToken token) { final StringProvider provider = parseAttributeExpansionExpression(token.value, componentResources, token.getLocation()); return new RenderCommand() { public void render(MarkupWriter writer, RenderQueue queue) { writer.attributeNS(token.namespaceURI, token.name, provider.provideString()); } public String toString() { return String.format("AttributeNS[%s %s \"%s\"]", token.namespaceURI, token.name, token.value); } }; } PageElementFactoryImpl(TypeCoercer typeCoercer, BindingSource bindingSource); RenderCommand newAttributeElement(ComponentResources componentResources, final AttributeToken token); RenderCommand newExpansionElement(ComponentResources componentResources, ExpansionToken token); Binding newBinding(String parameterName, ComponentResources loadingComponentResources,
                              ComponentResources embeddedComponentResources, String defaultBindingPrefix,
                              String expression, Location location);  }