Creating a Bean
-
From the repository tree view, expand the Code node and right click the Beans node. In the contextual menu, select Create Bean.
-
The [New Bean] wizard opens. In the Name field, type in a name for the bean, for
example, PrintConvertToBean. Click Finish to close the wizard. -
Enter the following code in the design workspace.
12345678910111213141516171819202122232425262728293031package beans;import org.w3c.dom.Document;import org.w3c.dom.Element;import org.w3c.dom.NodeList;public class PrintConvertToBean {/*** print input message* @param message*/public static void helloExample(Document message) {if (message == null) {System.out.println("There's no message here!");return;}Element rootElement = message.getDocumentElement();if (rootElement == null) {System.out.println("There's no root element here!");return;}System.out.println("The root element name is:"+ rootElement.getNodeName());System.out.println("The book categories are:");NodeList types = rootElement.getElementsByTagName("category");for(int i = 0;i<types.getLength();i++){Element child = (Element) types.item(i);System.out.println(child.getFirstChild().getNodeValue());}}}
- Press Ctrl+S to save your bean.
For more information about creating and using Java Beans, see
Talend Studio User
Guide.
Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Login
0 Comments