From 3a67af533d5218a6943d1b1a94aba5fd1bac9687 Mon Sep 17 00:00:00 2001 From: Dharani Thangarasu Date: Tue, 7 Sep 2021 17:23:26 +0530 Subject: [PATCH 1/3] Optimized the code --- dynamictable/Employee.java | 120 ++++++++++++++++ dynamictable/Employees.java | 96 ++++--------- dynamictable/WordTable.java | 122 +++------------- .../DynamicTableUsingMailmerge.java | 132 +++--------------- dynamictableusingmailmerge/StockDetails.java | 113 +++++++++------ dynamictableusingmailmerge/StockMarket.java | 41 ++++++ 6 files changed, 299 insertions(+), 325 deletions(-) create mode 100644 dynamictable/Employee.java create mode 100644 dynamictableusingmailmerge/StockMarket.java diff --git a/dynamictable/Employee.java b/dynamictable/Employee.java new file mode 100644 index 0000000..17ad208 --- /dev/null +++ b/dynamictable/Employee.java @@ -0,0 +1,120 @@ +import javax.xml.bind.annotation.*; + +public class Employee +{ + private String Name; + private String Title; + private String Address; + private String HomePhone; + private String Photo; + + @XmlElement(name = "Name") + /** + * Gets the employee name. + */ + public String getName() { + return Name; + } + + /** + * Sets the employee name. + * + * @param name Name of the employee. + */ + public void setName(String name) { + this.Name = name; + } + + @XmlElement(name = "Title") + /** + * Gets the designation of the employee. + */ + public String getTitle() { + return Title; + } + + /** + * Sets the designation of the employee. + * + * @param title Designation of the employee. + */ + public void setTitle(String title) { + this.Title = title; + } + + @XmlElement(name = "Address") + /** + * Gets the address of the employee. + */ + public String getAddress() { + return Address; + } + + /** + * Sets the address of the employee. + * + * @param address Address of the employee. + */ + public void setAddress(String address) { + this.Address = address; + } + + @XmlElement(name = "HomePhone") + /** + * Gets the contact number of the employee. + */ + public String getHomePhone() { + return HomePhone; + } + + /** + * Sets the contact number of the employee. + * + * @param homePhone Contact number of the employee. + */ + public void setHomePhone(String homePhone) { + this.HomePhone = homePhone; + } + + @XmlElement(name = "Photo") + /** + * Gets the photo of the employee. + */ + public String getPhoto() { + return Photo; + } + + /** + * Sets the photo of the employee. + * + * @param photo Photo of the employee. + */ + public void setPhoto(String photo) { + this.Photo = photo; + } + + /** + * Initializes a new instance of the Employee class with the specified name, + * title, address, contact number and photo. + * + * @param name Name of the employee. + * @param title Designation of the employee. + * @param address Address of the employee. + * @param homePhone Contact number of the employee. + * @param photo Photo of the employee. + * + */ + public Employee(String name, String title, String address, String homePhone, String photo) { + this.Name = name; + this.Title = title; + this.Address = address; + this.HomePhone = homePhone; + this.Photo = photo; + } + + /** + * Initializes a new instance of the Employee class. + */ + public Employee() { + } +} diff --git a/dynamictable/Employees.java b/dynamictable/Employees.java index 47f524a..40ced5d 100644 --- a/dynamictable/Employees.java +++ b/dynamictable/Employees.java @@ -1,76 +1,40 @@ -public class Employees -{ - private String m_name; - private String m_title; - private String m_address; - private String m_homePhone; - private String m_photo; - // Gets the employee name. - public String getName() throws Exception { - return m_name; - } - // Sets the employee name. - public String setName(String value) throws Exception { - m_name = value; - return value; - } - // Gets the designation of the employee. - public String getTitle() throws Exception { - return m_title; - } - // Sets the designation of the employee. - public String setTitle(String value) throws Exception { - m_title = value; - return value; - } - // Gets the address of the employee. - public String getAddress() throws Exception { - return m_address; - } - // Sets the address of the employee. - public String setAddress(String value) throws Exception { - m_address = value; - return value; - } - // Gets the contact number of the employee. - public String getHomePhone() throws Exception { - return m_homePhone; - } - // Sets the contact number of the employee. - public String setHomePhone(String value) throws Exception { - m_homePhone = value; - return value; - } - // Gets the photo of the employee. - public String getPhoto() throws Exception { - return m_photo; - } - // Sets the photo of the employee. - public String setPhoto(String value) throws Exception { - m_photo = value; - return value; +import java.util.List; +import javax.xml.bind.annotation.*; + +@XmlRootElement(name = "Employees") +public class Employees { + private List Employee; + + /** + * Gets the list of employees. + */ + @XmlElement(name = "Employee") + public List getEmployees() { + return Employee; } + /** - * Initializes a new instance of the Employees class with the specified name, - * title, address, contact number and photo. + * Sets the list of employees. * - * @param name Name of the employee. - * @param title Designation of the employee. - * @param address Address of the employee. - * @param homePhone Contact number of the employee. - * @param photo Photo of the employee. - * @throws Exception + * @param employee List of employee. */ - public Employees(String name, String title, String address, String homePhone, String photo) throws Exception { - m_name = name; - m_title = title; - m_address = address; - m_homePhone = homePhone; - m_photo = photo; + public void setEmployees(List employee) { + this.Employee = employee; } + /** * Initializes a new instance of the Employees class. */ - public Employees() throws Exception { + public Employees() { + } + + /** + * Initializes a new instance of the Employees class with the specified list of + * employee. + * + * @param employees List of employee. + */ + public Employees(List employees) { + this.Employee = employees; } } diff --git a/dynamictable/WordTable.java b/dynamictable/WordTable.java index 02efbc6..ffd3e24 100644 --- a/dynamictable/WordTable.java +++ b/dynamictable/WordTable.java @@ -1,25 +1,32 @@ import java.io.*; +import java.util.List; +import javax.xml.bind.*; import com.syncfusion.docio.*; import com.syncfusion.javahelper.system.*; -import com.syncfusion.javahelper.system.collections.generic.ListSupport; -import com.syncfusion.javahelper.system.io.*; -import com.syncfusion.javahelper.system.xml.*; -public class WordTable{ - public static void main(String[] args) throws Exception { +public class WordTable +{ + public static void main(String[] args) throws Exception + { + // Loads the XML file. + File file = new File(getDataDir("EmployeesList.xml")); + // Create a new instance for the JAXBContext. + JAXBContext jaxbContext = JAXBContext.newInstance(Employees.class); + // Reads the XML file. + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); + Employees employees = (Employees) jaxbUnmarshaller.unmarshal(file); + // Gets the list of employee details. + List employeeList = employees.getEmployees(); // Loads the template document. WordDocument document = new WordDocument(getDataDir("WordTable_Template.docx")); - // Creates a list of employee details. - ListSupport employeeDetails = getEmployeeDetails(); // Iterates each item in the list. - for (Employees employee : employeeDetails) + for (Employee employee : employeeList) { // Accesses the table in the document. IWTable table = document.getSections().get(0).getTables().get(0); // Initializes the paragraph and add new row to the table. IWParagraph paragraph = null; - WTableRow newRow = null; - newRow = table.addRow(); + table.addRow(); // Gets the employee photo and convert that base64 string to bytes. byte[] bytes = ConvertSupport.fromBase64String(employee.getPhoto()); ByteArrayInputStream stream = new ByteArrayInputStream(bytes); @@ -36,101 +43,6 @@ public static void main(String[] args) throws Exception { document.close(); } - /** - * - * Gets the list of employee details. - * - */ - private static ListSupport getEmployeeDetails() throws Exception { - // Gets list of employee details. - ListSupport employees = new ListSupport(Employees.class); - // Reads the xml document. - FileStreamSupport fs = new FileStreamSupport(getDataDir("EmployeesList.xml"), FileMode.Open, FileAccess.Read); - XmlReaderSupport reader = XmlReaderSupport.create(fs); - if (reader == null) - throw new Exception("reader"); - while (reader.getNodeType() != XmlNodeType.Element) - reader.read(); - if (reader.getLocalName() != "Employees") - throw new Exception(StringSupport.concat("Unexpected xml tag ", reader.getLocalName())); - reader.read(); - while (reader.getNodeType() == XmlNodeType.Whitespace) - reader.read(); - // Iterates to add the employee details in list. - while (reader.getLocalName() != "Employees") - { - if (reader.getNodeType() == XmlNodeType.Element) - { - switch (reader.getLocalName()) - { - case "Employee": - employees.add(getEmployees(reader)); - break; - } - } - else - { - reader.read(); - if ((reader.getLocalName() == "Employees") && reader.getNodeType() == XmlNodeType.EndElement) - break; - } - } - return employees; - } - - /** - * - * Gets the employees. - * - * @param reader Syncfusion's XML reader to read the XML files.. - */ - private static Employees getEmployees(XmlReaderSupport reader) throws Exception { - if (reader == null) - throw new Exception("reader"); - while (reader.getNodeType() != XmlNodeType.Element) - reader.read(); - if (reader.getLocalName() != "Employee") - throw new Exception(StringSupport.concat("Unexpected xml tag ", reader.getLocalName())); - reader.read(); - while (reader.getNodeType() == XmlNodeType.Whitespace) - reader.read(); - Employees employee = new Employees(); - while (reader.getLocalName() != "Employee") - { - if (reader.getNodeType() == XmlNodeType.Element) - { - switch (reader.getLocalName()) - { - case "Name": - employee.setName(reader.readContentAsString()); - break; - case "Title": - employee.setTitle(reader.readContentAsString()); - break; - case "Address": - employee.setAddress(reader.readContentAsString()); - break; - case "HomePhone": - employee.setHomePhone(reader.readContentAsString()); - break; - case "Photo": - employee.setPhoto(reader.readContentAsString()); - break; - default: - reader.skip(); - break; - } - } - else - { - reader.read(); - if ((reader.getLocalName() == "Employee") && reader.getNodeType() == XmlNodeType.EndElement) - break; - } - } - return employee; - } - /** * Get the file path * diff --git a/dynamictableusingmailmerge/DynamicTableUsingMailmerge.java b/dynamictableusingmailmerge/DynamicTableUsingMailmerge.java index ccec183..18cfd4d 100644 --- a/dynamictableusingmailmerge/DynamicTableUsingMailmerge.java +++ b/dynamictableusingmailmerge/DynamicTableUsingMailmerge.java @@ -1,124 +1,38 @@ import java.io.File; +import java.util.List; import com.syncfusion.docio.*; import com.syncfusion.javahelper.system.collections.generic.ListSupport; -import com.syncfusion.javahelper.system.io.*; -import com.syncfusion.javahelper.system.xml.*; +import javax.xml.bind.*; -public class DynamicTableUsingMailmerge { - - public static void main(String[] args) throws Exception { +public class DynamicTableUsingMailmerge +{ + public static void main(String[] args) throws Exception + { + // Loads the XML file. + File file = new File(getDataDir("StockDetails.xml")); + // Create a new instance for the JAXBContext. + JAXBContext jaxbContext = JAXBContext.newInstance(StockMarket.class); + // Reads the XML file. + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); + StockMarket stockMarket = (StockMarket) jaxbUnmarshaller.unmarshal(file); + // Gets the list of stock details. + List list = stockMarket.getStockDetails(); + ListSupport stockDetails = new ListSupport(StockDetails.class); + for(StockDetails stock : list) + { + //Add all items in the list to ListSupport to perform mail merge. + stockDetails.add(stock); + } // Loads the template document. WordDocument document = new WordDocument(getDataDir("Template.docx"), FormatType.Docx); - // Creates MailMergeDataTable. - MailMergeDataTable mailMergeDataTableStock = getMailMergeDataTableStock(); + MailMergeDataTable dataTable = new MailMergeDataTable("StockDetails", stockDetails); // Executes Mail Merge with group. - document.getMailMerge().executeGroup(mailMergeDataTableStock); + document.getMailMerge().executeGroup(dataTable); // Saves and closes the document. document.save("Result.docx", FormatType.Docx); document.close(); } - /** - * - * Gets the mail merge data table. - * - */ - private static MailMergeDataTable getMailMergeDataTableStock() throws Exception { - // Gets list of stock details. - ListSupport stockDetails = new ListSupport(StockDetails.class); - FileStreamSupport fs = new FileStreamSupport(getDataDir("StockDetails.xml"), FileMode.Open, FileAccess.Read); - // Reads the xml document. - XmlReaderSupport reader = XmlReaderSupport.create(fs); - if (reader == null) - throw new Exception("reader"); - while (reader.getNodeType().getEnumValue() != XmlNodeType.Element.getEnumValue()) - reader.read(); - if (!(reader.getLocalName() == "StockMarket")) - throw new Exception("Unexpected xml tag " + reader.getLocalName()); - reader.read(); - while (reader.getNodeType().getEnumValue() == XmlNodeType.Whitespace.getEnumValue()) - reader.read(); - // Iterates to add the stock details in list. - while (!(reader.getLocalName() == "StockMarket")) - { - if (reader.getNodeType().getEnumValue() == XmlNodeType.Element.getEnumValue()) - { - switch ((reader.getLocalName()) == null ? "string_null_value" : (reader.getLocalName())) - { - case "StockDetails": - stockDetails.add(getStockDetails(reader)); - break; - } - } - else - { - reader.read(); - if ((reader.getLocalName() == "StockMarket") - && reader.getNodeType().getEnumValue() == XmlNodeType.EndElement.getEnumValue()) - break; - } - } - // Creates an instance of MailMergeDataTable by specifying mail merge group name and IEnumerable collection. - MailMergeDataTable dataTable = new MailMergeDataTable("StockDetails", stockDetails); - reader.close(); - fs.close(); - return dataTable; - } - - /** - * - * Gets the StockDetails. - * - * @param reader Syncfusion's XML reader to read the XML files. - */ - private static StockDetails getStockDetails(XmlReaderSupport reader) throws Exception { - if (reader == null) - throw new Exception("reader"); - while (reader.getNodeType().getEnumValue() != XmlNodeType.Element.getEnumValue()) - reader.read(); - if (!(reader.getLocalName() == "StockDetails")) - throw new Exception("Unexpected xml tag " + reader.getLocalName()); - reader.read(); - while (reader.getNodeType().getEnumValue() == XmlNodeType.Whitespace.getEnumValue()) - reader.read(); - StockDetails stockDetails = new StockDetails(); - while (!(reader.getLocalName() == "StockDetails")) - { - if (reader.getNodeType().getEnumValue() == XmlNodeType.Element.getEnumValue()) - { - switch ((reader.getLocalName()) == null ? "string_null_value" : (reader.getLocalName())) - { - case "TradeNo": - stockDetails.setTradeNo(reader.readContentAsString()); - break; - case "CompanyName": - stockDetails.setCompanyName(reader.readContentAsString()); - break; - case "CostPrice": - stockDetails.setCostPrice(reader.readContentAsString()); - break; - case "SharesCount": - stockDetails.setSharesCount(reader.readContentAsString()); - break; - case "SalesPrice": - stockDetails.setSalesPrice(reader.readContentAsString()); - break; - default: - reader.skip(); - break; - } - } - else - { - reader.read(); - if ((reader.getLocalName() == "StockDetails") - && reader.getNodeType().getEnumValue() == XmlNodeType.EndElement.getEnumValue()) - break; - } - } - return stockDetails; - } - /** * Get the file path * diff --git a/dynamictableusingmailmerge/StockDetails.java b/dynamictableusingmailmerge/StockDetails.java index afa4669..a92251c 100644 --- a/dynamictableusingmailmerge/StockDetails.java +++ b/dynamictableusingmailmerge/StockDetails.java @@ -1,76 +1,104 @@ +import javax.xml.bind.annotation.XmlElement; + public class StockDetails { - private String m_tradeNo; - private String m_companyName; - private String m_costPrice; - private String m_sharesCount; - private String m_salesPrice; + private String TradeNo; + private String CompanyName; + private String CostPrice; + private String SharesCount; + private String SalesPrice; + @XmlElement(name = "TradeNo") /** * Gets the trade number of the share. */ - public String getTradeNo() throws Exception { - return m_tradeNo; + public String getTradeNo() { + return TradeNo; } + /** * Sets the trade number of the share. + * + * @param tradeNo Trade number of the share. */ - public String setTradeNo(String value) throws Exception { - m_tradeNo = value; - return value; + public void setTradeNo(String tradeNo) { + this.TradeNo = tradeNo; } + + @XmlElement(name = "CompanyName") /** * Gets the company name of the share. */ - public String getCompanyName() throws Exception { - return m_companyName; + public String getCompanyName() { + return CompanyName; } + /** - * Sets the company name of the share. + * Sets company name of the share. + * + * @param companyName Company name of the share. */ - public String setCompanyName(String value) throws Exception { - m_companyName = value; - return value; + public void setCompanyName(String companyName) { + this.CompanyName = companyName; } + + @XmlElement(name = "SharesCount") /** - * Gets the cost price of the share. + * Gets the total shares count. */ - public String getCostPrice() throws Exception { - return m_costPrice; + public String getSharesCount() { + return SharesCount; } + /** - * Sets the cost price of the share. + * Sets the total shares count. + * + * @param sharesCount Total shares count. */ - public String setCostPrice(String value) throws Exception { - m_costPrice = value; - return value; + public void setSharesCount(String sharesCount) { + this.SharesCount = sharesCount; } + + @XmlElement(name = "CostPrice") /** - * Gets the total number of the share. + * Gets the cost price of the share. */ - public String getSharesCount() throws Exception { - return m_sharesCount; + public String getCostPrice() { + return CostPrice; } + /** - * Sets the total number of the share. + * Sets the cost price of the share. + * + * @param costPrice Cost price of the share. */ - public String setSharesCount(String value) throws Exception { - m_sharesCount = value; - return value; + public void setCostPrice(String costPrice) { + this.CostPrice = costPrice; } + + @XmlElement(name = "SalesPrice") /** * Gets the sales price of the share. */ - public String getSalesPrice() throws Exception { - return m_salesPrice; + public String getSalesPrice() { + return SalesPrice; } + /** * Sets the sales price of the share. + * + * @param salesPrice Sales price of the share. + */ + public void setSalesPrice(String salesPrice) { + this.SalesPrice = salesPrice; + } + + /** + * Initializes a new instance of the StockDetails class. */ - public String setSalesPrice(String value) throws Exception { - m_salesPrice = value; - return value; + public StockDetails() throws Exception { } + /** * Initializes a new instance of the StockDetails class with the specified trade * number, company name, cost price, share count and sales price. @@ -83,15 +111,10 @@ public String setSalesPrice(String value) throws Exception { */ public StockDetails(String tradeNo, String companyName, String costPrice, String sharesCount, String salesPrice) throws Exception { - m_tradeNo = tradeNo; - m_companyName = companyName; - m_costPrice = costPrice; - m_sharesCount = sharesCount; - m_salesPrice = salesPrice; - } - /** - * Initializes a new instance of the StockDetails class. - */ - public StockDetails() throws Exception { + this.TradeNo = tradeNo; + this.CompanyName = companyName; + this.CostPrice = costPrice; + this.SharesCount = sharesCount; + this.SalesPrice = salesPrice; } } diff --git a/dynamictableusingmailmerge/StockMarket.java b/dynamictableusingmailmerge/StockMarket.java new file mode 100644 index 0000000..9b35d71 --- /dev/null +++ b/dynamictableusingmailmerge/StockMarket.java @@ -0,0 +1,41 @@ +import java.util.List; +import javax.xml.bind.annotation.*; + +@XmlRootElement(name = "StockMarket") +public class StockMarket +{ + private List StockDetails; + + @XmlElement(name = "StockDetails") + /** + * Gets the list of stock details. + */ + public List getStockDetails() { + return StockDetails; + } + + /** + * Sets the list of stock details. + * + * @param stockDetails List of stock details. + */ + public void setStockDetails(List listStockDetails) { + this.StockDetails = listStockDetails; + } + + /** + * Initializes a new instance of the StockMarket class. + */ + public StockMarket() { + } + + /** + * Initializes a new instance of the StockMarket class with specified list of + * stock details. + * + * @param stockDetails List of stock details. + */ + public StockMarket(List stockDetails) { + this.StockDetails = stockDetails; + } +} From 0f089c3d414a29bbdc7f4e845a2b0ea9784d4aa9 Mon Sep 17 00:00:00 2001 From: Dharani Thangarasu Date: Tue, 7 Sep 2021 17:27:48 +0530 Subject: [PATCH 2/3] Removed unwanted spacings --- dynamictable/Employee.java | 13 ------------- dynamictable/Employees.java | 5 ----- dynamictableusingmailmerge/StockDetails.java | 13 ------------- dynamictableusingmailmerge/StockMarket.java | 5 ----- 4 files changed, 36 deletions(-) diff --git a/dynamictable/Employee.java b/dynamictable/Employee.java index 17ad208..87b0012 100644 --- a/dynamictable/Employee.java +++ b/dynamictable/Employee.java @@ -1,5 +1,4 @@ import javax.xml.bind.annotation.*; - public class Employee { private String Name; @@ -7,7 +6,6 @@ public class Employee private String Address; private String HomePhone; private String Photo; - @XmlElement(name = "Name") /** * Gets the employee name. @@ -15,7 +13,6 @@ public class Employee public String getName() { return Name; } - /** * Sets the employee name. * @@ -24,7 +21,6 @@ public String getName() { public void setName(String name) { this.Name = name; } - @XmlElement(name = "Title") /** * Gets the designation of the employee. @@ -32,7 +28,6 @@ public void setName(String name) { public String getTitle() { return Title; } - /** * Sets the designation of the employee. * @@ -41,7 +36,6 @@ public String getTitle() { public void setTitle(String title) { this.Title = title; } - @XmlElement(name = "Address") /** * Gets the address of the employee. @@ -49,7 +43,6 @@ public void setTitle(String title) { public String getAddress() { return Address; } - /** * Sets the address of the employee. * @@ -58,7 +51,6 @@ public String getAddress() { public void setAddress(String address) { this.Address = address; } - @XmlElement(name = "HomePhone") /** * Gets the contact number of the employee. @@ -66,7 +58,6 @@ public void setAddress(String address) { public String getHomePhone() { return HomePhone; } - /** * Sets the contact number of the employee. * @@ -75,7 +66,6 @@ public String getHomePhone() { public void setHomePhone(String homePhone) { this.HomePhone = homePhone; } - @XmlElement(name = "Photo") /** * Gets the photo of the employee. @@ -83,7 +73,6 @@ public void setHomePhone(String homePhone) { public String getPhoto() { return Photo; } - /** * Sets the photo of the employee. * @@ -92,7 +81,6 @@ public String getPhoto() { public void setPhoto(String photo) { this.Photo = photo; } - /** * Initializes a new instance of the Employee class with the specified name, * title, address, contact number and photo. @@ -111,7 +99,6 @@ public Employee(String name, String title, String address, String homePhone, Str this.HomePhone = homePhone; this.Photo = photo; } - /** * Initializes a new instance of the Employee class. */ diff --git a/dynamictable/Employees.java b/dynamictable/Employees.java index 40ced5d..a7b89f5 100644 --- a/dynamictable/Employees.java +++ b/dynamictable/Employees.java @@ -1,10 +1,8 @@ import java.util.List; import javax.xml.bind.annotation.*; - @XmlRootElement(name = "Employees") public class Employees { private List Employee; - /** * Gets the list of employees. */ @@ -12,7 +10,6 @@ public class Employees { public List getEmployees() { return Employee; } - /** * Sets the list of employees. * @@ -21,13 +18,11 @@ public List getEmployees() { public void setEmployees(List employee) { this.Employee = employee; } - /** * Initializes a new instance of the Employees class. */ public Employees() { } - /** * Initializes a new instance of the Employees class with the specified list of * employee. diff --git a/dynamictableusingmailmerge/StockDetails.java b/dynamictableusingmailmerge/StockDetails.java index a92251c..494869e 100644 --- a/dynamictableusingmailmerge/StockDetails.java +++ b/dynamictableusingmailmerge/StockDetails.java @@ -1,5 +1,4 @@ import javax.xml.bind.annotation.XmlElement; - public class StockDetails { private String TradeNo; @@ -7,7 +6,6 @@ public class StockDetails private String CostPrice; private String SharesCount; private String SalesPrice; - @XmlElement(name = "TradeNo") /** * Gets the trade number of the share. @@ -15,7 +13,6 @@ public class StockDetails public String getTradeNo() { return TradeNo; } - /** * Sets the trade number of the share. * @@ -24,7 +21,6 @@ public String getTradeNo() { public void setTradeNo(String tradeNo) { this.TradeNo = tradeNo; } - @XmlElement(name = "CompanyName") /** * Gets the company name of the share. @@ -32,7 +28,6 @@ public void setTradeNo(String tradeNo) { public String getCompanyName() { return CompanyName; } - /** * Sets company name of the share. * @@ -41,7 +36,6 @@ public String getCompanyName() { public void setCompanyName(String companyName) { this.CompanyName = companyName; } - @XmlElement(name = "SharesCount") /** * Gets the total shares count. @@ -49,7 +43,6 @@ public void setCompanyName(String companyName) { public String getSharesCount() { return SharesCount; } - /** * Sets the total shares count. * @@ -58,7 +51,6 @@ public String getSharesCount() { public void setSharesCount(String sharesCount) { this.SharesCount = sharesCount; } - @XmlElement(name = "CostPrice") /** * Gets the cost price of the share. @@ -66,7 +58,6 @@ public void setSharesCount(String sharesCount) { public String getCostPrice() { return CostPrice; } - /** * Sets the cost price of the share. * @@ -75,7 +66,6 @@ public String getCostPrice() { public void setCostPrice(String costPrice) { this.CostPrice = costPrice; } - @XmlElement(name = "SalesPrice") /** * Gets the sales price of the share. @@ -83,7 +73,6 @@ public void setCostPrice(String costPrice) { public String getSalesPrice() { return SalesPrice; } - /** * Sets the sales price of the share. * @@ -92,13 +81,11 @@ public String getSalesPrice() { public void setSalesPrice(String salesPrice) { this.SalesPrice = salesPrice; } - /** * Initializes a new instance of the StockDetails class. */ public StockDetails() throws Exception { } - /** * Initializes a new instance of the StockDetails class with the specified trade * number, company name, cost price, share count and sales price. diff --git a/dynamictableusingmailmerge/StockMarket.java b/dynamictableusingmailmerge/StockMarket.java index 9b35d71..f1d4e42 100644 --- a/dynamictableusingmailmerge/StockMarket.java +++ b/dynamictableusingmailmerge/StockMarket.java @@ -1,11 +1,9 @@ import java.util.List; import javax.xml.bind.annotation.*; - @XmlRootElement(name = "StockMarket") public class StockMarket { private List StockDetails; - @XmlElement(name = "StockDetails") /** * Gets the list of stock details. @@ -13,7 +11,6 @@ public class StockMarket public List getStockDetails() { return StockDetails; } - /** * Sets the list of stock details. * @@ -22,13 +19,11 @@ public List getStockDetails() { public void setStockDetails(List listStockDetails) { this.StockDetails = listStockDetails; } - /** * Initializes a new instance of the StockMarket class. */ public StockMarket() { } - /** * Initializes a new instance of the StockMarket class with specified list of * stock details. From 138ad18ffc548dcaa4e6e17cc0c8133b8198a75f Mon Sep 17 00:00:00 2001 From: Dharani Thangarasu Date: Tue, 7 Sep 2021 17:32:32 +0530 Subject: [PATCH 3/3] Modified the alignment --- dynamictable/Employee.java | 36 +++++++++++++------- dynamictable/Employees.java | 15 +++++--- dynamictableusingmailmerge/StockDetails.java | 35 ++++++++++++------- dynamictableusingmailmerge/StockMarket.java | 12 ++++--- 4 files changed, 65 insertions(+), 33 deletions(-) diff --git a/dynamictable/Employee.java b/dynamictable/Employee.java index 87b0012..803a75a 100644 --- a/dynamictable/Employee.java +++ b/dynamictable/Employee.java @@ -10,7 +10,8 @@ public class Employee /** * Gets the employee name. */ - public String getName() { + public String getName() + { return Name; } /** @@ -18,14 +19,16 @@ public String getName() { * * @param name Name of the employee. */ - public void setName(String name) { + public void setName(String name) + { this.Name = name; } @XmlElement(name = "Title") /** * Gets the designation of the employee. */ - public String getTitle() { + public String getTitle() + { return Title; } /** @@ -33,14 +36,16 @@ public String getTitle() { * * @param title Designation of the employee. */ - public void setTitle(String title) { + public void setTitle(String title) + { this.Title = title; } @XmlElement(name = "Address") /** * Gets the address of the employee. */ - public String getAddress() { + public String getAddress() + { return Address; } /** @@ -48,14 +53,16 @@ public String getAddress() { * * @param address Address of the employee. */ - public void setAddress(String address) { + public void setAddress(String address) + { this.Address = address; } @XmlElement(name = "HomePhone") /** * Gets the contact number of the employee. */ - public String getHomePhone() { + public String getHomePhone() + { return HomePhone; } /** @@ -63,14 +70,16 @@ public String getHomePhone() { * * @param homePhone Contact number of the employee. */ - public void setHomePhone(String homePhone) { + public void setHomePhone(String homePhone) + { this.HomePhone = homePhone; } @XmlElement(name = "Photo") /** * Gets the photo of the employee. */ - public String getPhoto() { + public String getPhoto() + { return Photo; } /** @@ -78,7 +87,8 @@ public String getPhoto() { * * @param photo Photo of the employee. */ - public void setPhoto(String photo) { + public void setPhoto(String photo) + { this.Photo = photo; } /** @@ -92,7 +102,8 @@ public void setPhoto(String photo) { * @param photo Photo of the employee. * */ - public Employee(String name, String title, String address, String homePhone, String photo) { + public Employee(String name, String title, String address, String homePhone, String photo) + { this.Name = name; this.Title = title; this.Address = address; @@ -102,6 +113,7 @@ public Employee(String name, String title, String address, String homePhone, Str /** * Initializes a new instance of the Employee class. */ - public Employee() { + public Employee() + { } } diff --git a/dynamictable/Employees.java b/dynamictable/Employees.java index a7b89f5..d16e5c5 100644 --- a/dynamictable/Employees.java +++ b/dynamictable/Employees.java @@ -1,13 +1,15 @@ import java.util.List; import javax.xml.bind.annotation.*; @XmlRootElement(name = "Employees") -public class Employees { +public class Employees +{ private List Employee; /** * Gets the list of employees. */ @XmlElement(name = "Employee") - public List getEmployees() { + public List getEmployees() + { return Employee; } /** @@ -15,13 +17,15 @@ public List getEmployees() { * * @param employee List of employee. */ - public void setEmployees(List employee) { + public void setEmployees(List employee) + { this.Employee = employee; } /** * Initializes a new instance of the Employees class. */ - public Employees() { + public Employees() + { } /** * Initializes a new instance of the Employees class with the specified list of @@ -29,7 +33,8 @@ public Employees() { * * @param employees List of employee. */ - public Employees(List employees) { + public Employees(List employees) + { this.Employee = employees; } } diff --git a/dynamictableusingmailmerge/StockDetails.java b/dynamictableusingmailmerge/StockDetails.java index 494869e..70c97e5 100644 --- a/dynamictableusingmailmerge/StockDetails.java +++ b/dynamictableusingmailmerge/StockDetails.java @@ -10,7 +10,8 @@ public class StockDetails /** * Gets the trade number of the share. */ - public String getTradeNo() { + public String getTradeNo() + { return TradeNo; } /** @@ -18,14 +19,16 @@ public String getTradeNo() { * * @param tradeNo Trade number of the share. */ - public void setTradeNo(String tradeNo) { + public void setTradeNo(String tradeNo) + { this.TradeNo = tradeNo; } @XmlElement(name = "CompanyName") /** * Gets the company name of the share. */ - public String getCompanyName() { + public String getCompanyName() + { return CompanyName; } /** @@ -33,14 +36,16 @@ public String getCompanyName() { * * @param companyName Company name of the share. */ - public void setCompanyName(String companyName) { + public void setCompanyName(String companyName) + { this.CompanyName = companyName; } @XmlElement(name = "SharesCount") /** * Gets the total shares count. */ - public String getSharesCount() { + public String getSharesCount() + { return SharesCount; } /** @@ -48,14 +53,16 @@ public String getSharesCount() { * * @param sharesCount Total shares count. */ - public void setSharesCount(String sharesCount) { + public void setSharesCount(String sharesCount) + { this.SharesCount = sharesCount; } @XmlElement(name = "CostPrice") /** * Gets the cost price of the share. */ - public String getCostPrice() { + public String getCostPrice() + { return CostPrice; } /** @@ -63,14 +70,16 @@ public String getCostPrice() { * * @param costPrice Cost price of the share. */ - public void setCostPrice(String costPrice) { + public void setCostPrice(String costPrice) + { this.CostPrice = costPrice; } @XmlElement(name = "SalesPrice") /** * Gets the sales price of the share. */ - public String getSalesPrice() { + public String getSalesPrice() + { return SalesPrice; } /** @@ -78,13 +87,15 @@ public String getSalesPrice() { * * @param salesPrice Sales price of the share. */ - public void setSalesPrice(String salesPrice) { + public void setSalesPrice(String salesPrice) + { this.SalesPrice = salesPrice; } /** * Initializes a new instance of the StockDetails class. */ - public StockDetails() throws Exception { + public StockDetails() + { } /** * Initializes a new instance of the StockDetails class with the specified trade @@ -97,7 +108,7 @@ public StockDetails() throws Exception { * @param salesPrice Sales price of the share. */ public StockDetails(String tradeNo, String companyName, String costPrice, String sharesCount, String salesPrice) - throws Exception { + { this.TradeNo = tradeNo; this.CompanyName = companyName; this.CostPrice = costPrice; diff --git a/dynamictableusingmailmerge/StockMarket.java b/dynamictableusingmailmerge/StockMarket.java index f1d4e42..ac094e7 100644 --- a/dynamictableusingmailmerge/StockMarket.java +++ b/dynamictableusingmailmerge/StockMarket.java @@ -8,7 +8,8 @@ public class StockMarket /** * Gets the list of stock details. */ - public List getStockDetails() { + public List getStockDetails() + { return StockDetails; } /** @@ -16,13 +17,15 @@ public List getStockDetails() { * * @param stockDetails List of stock details. */ - public void setStockDetails(List listStockDetails) { + public void setStockDetails(List listStockDetails) + { this.StockDetails = listStockDetails; } /** * Initializes a new instance of the StockMarket class. */ - public StockMarket() { + public StockMarket() + { } /** * Initializes a new instance of the StockMarket class with specified list of @@ -30,7 +33,8 @@ public StockMarket() { * * @param stockDetails List of stock details. */ - public StockMarket(List stockDetails) { + public StockMarket(List stockDetails) + { this.StockDetails = stockDetails; } }