Errai 3.0.1-SNAPSHOT

org.jboss.errai.ui.shared
Class TemplateVisitor

java.lang.Object
  extended by org.jboss.errai.ui.shared.TemplateVisitor
All Implemented Interfaces:
DomVisitor
Direct Known Subclasses:
TemplateTranslationVisitor

public class TemplateVisitor
extends Object
implements DomVisitor

Visits the dom and finds elements that need translating.


Constructor Summary
TemplateVisitor(String i18nPrefix)
           
 
Method Summary
protected  String getElementKey(Element element)
           
 Map<String,String> getI18nValues()
           
protected  String getOrGenerateTranslationKey(Element element)
          Gets a translation key associated with the given element.
 boolean hasAttribute(Element element, String attributeName)
          Called to determine if an element has an attribute defined.
 boolean isTextOnly(Element element)
          Returns true if the given element has some text and no element children.
 void setI18nPrefix(String i18nPrefix)
           
 boolean visit(Element element)
          Visits an element in the dom, returns true if the visitor should continue visiting down the dom.
protected  void visitAttribute(String i18nKeyPrefix, Element element, String attributeName)
          Records the translation key/value for an attribute.
protected  void visitElement(String i18nKeyPrefix, Element element)
          Records the translation key/value for an element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateVisitor

public TemplateVisitor(String i18nPrefix)
Method Detail

visit

public boolean visit(Element element)
Description copied from interface: DomVisitor
Visits an element in the dom, returns true if the visitor should continue visiting down the dom.

Specified by:
visit in interface DomVisitor
Parameters:
element - the root element to visit

visitElement

protected void visitElement(String i18nKeyPrefix,
                            Element element)
Records the translation key/value for an element.

Parameters:
i18nKeyPrefix -
element -

visitAttribute

protected void visitAttribute(String i18nKeyPrefix,
                              Element element,
                              String attributeName)
Records the translation key/value for an attribute.

Parameters:
i18nKeyPrefix -
element -
attributeName -

getElementKey

protected String getElementKey(Element element)

getOrGenerateTranslationKey

protected String getOrGenerateTranslationKey(Element element)
Gets a translation key associated with the given element. If no key attribute exists in this element, generate and assign one.

Parameters:
element -

isTextOnly

public boolean isTextOnly(Element element)
Returns true if the given element has some text and no element children.

Parameters:
element -

hasAttribute

public boolean hasAttribute(Element element,
                            String attributeName)
Called to determine if an element has an attribute defined.

Parameters:
element -
attributeName -

setI18nPrefix

public void setI18nPrefix(String i18nPrefix)

getI18nValues

public Map<String,String> getI18nValues()

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.