Package org.tquadrat.foundation.i18n.ap
Class TextCollector
java.lang.Object
@ClassVersion(sourceVersion="$Id: TextCollector.java 1062 2023-09-25 23:11:41Z tquadrat $")
@API(status=INTERNAL,
since="0.1.0")
public class TextCollector
extends SimpleElementVisitor9<Void,Map<Locale,SortedMap<String,TextEntry>>>
A visitor class that collects the texts for resource bundle properties
files from the annotations.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: TextCollector.java 1062 2023-09-25 23:11:41Z tquadrat $
- Since:
- 0.0.2
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.i18n.ap.TextCollector"
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Elements
Some helper utilities for the work withElement
instances.private final APHelper
The processing environment.private final String
The prefix for the message ids.Fields inherited from class javax.lang.model.util.SimpleElementVisitor6
DEFAULT_VALUE
-
Constructor Summary
ConstructorsConstructorDescriptionTextCollector
(APHelper environment, String messagePrefix) Creates a newTextCollector
instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate final void
addTextEntry
(Map<Locale, SortedMap<String, TextEntry>> texts, Element element, String key, String description, String className, boolean isMessage, Translation[] translations) Adds the text entries to the texts map.private final void
processTextAnnotation
(Map<Locale, SortedMap<String, TextEntry>> texts, Element element, Text annotation, String className) Processes a text annotation.final Void
visitExecutable
(ExecutableElement element, Map<Locale, SortedMap<String, TextEntry>> texts) final Void
visitVariable
(VariableElement element, Map<Locale, SortedMap<String, TextEntry>> texts) Methods inherited from class javax.lang.model.util.SimpleElementVisitor9
visitModule
Methods inherited from class javax.lang.model.util.SimpleElementVisitor6
defaultAction, visitPackage, visitType, visitTypeParameter
Methods inherited from class javax.lang.model.util.AbstractElementVisitor6
visit, visit, visitRecordComponent, visitUnknown
-
Field Details
-
m_ElementUtils
Some helper utilities for the work withElement
instances. -
m_MessagePrefix
The prefix for the message ids. -
m_Environment
The processing environment.
-
-
Constructor Details
-
TextCollector
Creates a newTextCollector
instance.- Parameters:
environment
- The processing environment for the annotation processor.messagePrefix
- The configured message prefix.
-
-
Method Details
-
addTextEntry
private final void addTextEntry(Map<Locale, SortedMap<String, TextEntry>> texts, Element element, String key, String description, String className, boolean isMessage, Translation[] translations) Adds the text entries to the texts map.- Parameters:
texts
- The texts map.element
- The annotated element.key
- The resource bundle key.description
- The description for the text.className
- The fully qualified name of the class that defines the text.isMessage
-true
if the text is a message,false
otherwise.translations
- The texts in the various languages.
-
processTextAnnotation
private final void processTextAnnotation(Map<Locale, SortedMap<String, TextEntry>> texts, Element element, Text annotation, String className) Processes a text annotation.- Parameters:
texts
- The texts map.element
- The annotated element.annotation
- The text annotation.className
- The fully qualified name of the class that defines the text.
-
visitExecutable
public final Void visitExecutable(ExecutableElement element, Map<Locale, SortedMap<String, TextEntry>> texts) - Specified by:
visitExecutable
in interfaceElementVisitor<Void,
Map<Locale, SortedMap<String, TextEntry>>> - Overrides:
visitExecutable
in classSimpleElementVisitor6<Void,
Map<Locale, SortedMap<String, TextEntry>>>
-
visitVariable
public final Void visitVariable(VariableElement element, Map<Locale, SortedMap<String, TextEntry>> texts) - Specified by:
visitVariable
in interfaceElementVisitor<Void,
Map<Locale, SortedMap<String, TextEntry>>> - Overrides:
visitVariable
in classSimpleElementVisitor7<Void,
Map<Locale, SortedMap<String, TextEntry>>>
-