on 2021 Feb 09 12:37 PM
Hi arvind-kumar-avinash and Experts,
Could you please assist me to understand the below, I have searched a lot of places to understand this. But I am not getting the exact answer.
Thanks in Advance!
By,
HV
Request clarification before answering.
Q. What is the exact difference between decorator and translator?
Ans. The formal name of decorator is cellDecorator. As the name suggests, it can be used to decorate (e.g. append/prepend/trim some value) the value of an attribute before it is translated e.g. if you want to trim all trailing/leading zeros from the value of an attribute. Another example can be appending user's country name (e.g. _US or _UK) to the values of the uid attribute of an itemtype. It's like putting a marker/flag to an attribute for easily identifying and classifying the values.
As already mentioned above, the translation comes next to decoration (if any). A translator is used to translate the value of an attribute (which may have been decorated by using some decorator) to a new value e.g. encoding a password before storing it into the database.
Can I not simply use translator then?
Of course, you can i.e. whatever you accomplish using a decorator before the value is sent to a translator, can be done in the translator itself but having a decorator promotes reusability and gives you more control on processing the values e.g. you can plugin a decorator to a translator on a need basis. In presence of the decorator, first the decoration will happen and then the translation; while in absence of the decorator the translation will happen directly.
Q. Which is the best one to use in impex?
Ans. As mentioned above, they are not competing things; rather, they are the stages in the ImpEx process pipeline.
Check this chapter to learn more about them.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi arvind-kumar-avinash ,
Thank you so much for your detailed answer. Now I am clear.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.