@Entity public class Entry { String message; @Column(name = "log_time") Date time; }
@Entity public class LogEntry { @Column(name = "`level`") String level; @Column(name = "`exception`", length = 4000) String exception; // etc. }
@Entity public class Entry { String message; @Column(name = "log_time") Date time; }
@Entity public class LogEntry { @Column(name = "`level`") String level; @Column(name = "`exception`", length = 4000) String exception; // etc. }
Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. D:\>cd bekap D:\bekap>dir Volume in drive D is Dadu Volume Serial Number is 1293-1777 Directory of D:\bekap File Not Found D:\bekap>cd mybackup D:\bekap\mybackup>dir Volume in drive D is Dadu Volume Serial Number is 1293-1777 Directory of D:\bekap\mybackup 2009-08-11 15:22 <DIR> . 2009-08-11 15:22 <DIR> .. 2009-08-11 15:22 0 .bekapkeren2 2009-08-11 15:22 35,616,973 .cache.ser 2009-08-07 17:43 <DIR> data 2009-08-11 15:21 <DIR> fs 2 File(s) 35,616,973 bytes 4 Dir(s) 82,628,956,160 bytes free
How can we have multiple return values in Java? We cannot formally have it, since each method can only have no return value (void) or single return value (int, long, Object, String, etc.)
One of the solution to emulate it is to create a class that contains two fields, one for each return value. But that will make you tired because you need to create it every time you need it (not including the time used to think what the class name should be).
In my case, I solved this problem by using a Pointer class. It works similar to C in which you can have multiple return values by passing a pointer to a value that will be modified to the function arguments like: size = fread(pbuf, size, count, pfile);
The pointer class is as follows:
public class Pointer<T> { public T value; public static <T> Pointer<T> create() { return new Pointer<T>(); } }
Let's say you have a method that needs to return two values: result and error code. The method for our example will be:
byte[] downloadFile(String url, Pointer<Integer> errorCode) { ...(really download)... if (errorCode != null) { errorCode.value = 200; // example only } }
To use the method, we first create the pointer to store the error code as follows:
Pointer<Integer> errorCode = Pointer.create(); byte[] file = downloadFile("http://biginteger.blogspot.com/", errorCode); System.out.printf("File downloaded (%d bytes) with error code %d", file.length, errorCode.value);
The reason of the create() is to eliminate repeated typing of the type parameter:
Pointer<Integer> errorCode = new Pointer<Integer>();
GWT represents locale as a client property whose value can be set either using a meta tag embedded in the host page or in the query string of the host page's URL.
var getCookie = function(c_name) { if (document.cookie.length > 0) { c_start = document.cookie.indexOf(c_name + "="); if (c_start != -1) { c_start = c_start + c_name.length+1; c_end = document.cookie.indexOf(";", c_start); if (c_end == -1) c_end = document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; } var locale = getCookie("locale"); if (! locale) { locale = "id"; } document.write("<meta name='gwt:property' content='locale=" + locale + "' />");
function setLocale(locale) { document.cookie = "locale=" + escape(locale); document.location.href = document.location.href; }