JAXB and constructors

JAXB can support this case using an XML Adapter. Consider you have the following object with no zero-arg constructor: package blog.immutable; public class Customer { private final String name; private final Address address; public Customer(String name, Address address) { this.name = name; this.address = address; } public String getName() { return name; } public Address … Read more

How to create a dynamic file + link for download in Javascript? [duplicate]

Here’s a solution I’ve created, that allows you to create and download a file in a single click: <html> <body> <button onclick=’download_file(“my_file.txt”, dynamic_text())’>Download</button> <script> function dynamic_text() { return “create your dynamic text here”; } function download_file(name, contents, mime_type) { mime_type = mime_type || “text/plain”; var blob = new Blob([contents], {type: mime_type}); var dlink = document.createElement(‘a’); … Read more

Is this Factory Method creation pattern?

I would agree to call the method a “Factory Method”, though the design is not strictly a “Factory Method Pattern”. Here is a key point (from Wikipedia): …The Factory method lets a class defer instantiation to subclasses.” Since your class is static and method static (hence non-virtual), there is no “deferring” possible. Conceptually, notice also, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)