diff options
author | Elliott Hughes <enh@google.com> | 2014-04-29 17:59:30 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-04-30 11:31:05 -0700 |
commit | fe77f817b540f2a66c17486a618bb9083a22070e (patch) | |
tree | 6d17f76b99bb16a976ec5b137b15688ed2b9667d /luni/src/main/java/android | |
parent | 97e35de30fcddd7eaa0d6eb7a100bcf9bdd824a1 (diff) | |
download | libcore-fe77f817b540f2a66c17486a618bb9083a22070e.zip libcore-fe77f817b540f2a66c17486a618bb9083a22070e.tar.gz libcore-fe77f817b540f2a66c17486a618bb9083a22070e.tar.bz2 |
Make sure every struct has a toString.
Also add some missing finals.
Change-Id: I80a779d7340608d55d5ffcc73e2d411dc1bc1cc9
Diffstat (limited to 'luni/src/main/java/android')
12 files changed, 144 insertions, 106 deletions
diff --git a/luni/src/main/java/android/system/StructAddrinfo.java b/luni/src/main/java/android/system/StructAddrinfo.java index 9862190..2425946 100644 --- a/luni/src/main/java/android/system/StructAddrinfo.java +++ b/luni/src/main/java/android/system/StructAddrinfo.java @@ -17,6 +17,7 @@ package android.system; import java.net.InetAddress; +import libcore.util.Objects; /** * Information returned/taken by getaddrinfo(3). Corresponds to C's {@code struct addrinfo} from @@ -27,27 +28,31 @@ import java.net.InetAddress; * @hide */ public final class StructAddrinfo { - /** Flags describing the kind of lookup to be done. (Such as AI_ADDRCONFIG.) */ - public int ai_flags; + /** Flags describing the kind of lookup to be done. (Such as AI_ADDRCONFIG.) */ + public int ai_flags; - /** Desired address family for results. (Such as AF_INET6 for IPv6. AF_UNSPEC means "any".) */ - public int ai_family; + /** Desired address family for results. (Such as AF_INET6 for IPv6. AF_UNSPEC means "any".) */ + public int ai_family; - /** Socket type. (Such as SOCK_DGRAM. 0 means "any".) */ - public int ai_socktype; + /** Socket type. (Such as SOCK_DGRAM. 0 means "any".) */ + public int ai_socktype; - /** Protocol. (Such as IPPROTO_IPV6 IPv6. 0 means "any".) */ - public int ai_protocol; + /** Protocol. (Such as IPPROTO_IPV6 IPv6. 0 means "any".) */ + public int ai_protocol; - /** Address length. (Not useful in Java.) */ - // public int ai_addrlen; + /** Address length. (Not useful in Java.) */ + // public int ai_addrlen; - /** Address. */ - public InetAddress ai_addr; + /** Address. */ + public InetAddress ai_addr; - /** Canonical name of service location (if AI_CANONNAME provided in ai_flags). */ - // public String ai_canonname; + /** Canonical name of service location (if AI_CANONNAME provided in ai_flags). */ + // public String ai_canonname; - /** Next element in linked list. */ - public StructAddrinfo ai_next; + /** Next element in linked list. */ + public StructAddrinfo ai_next; + + @Override public String toString() { + return Objects.toString(this); + } } diff --git a/luni/src/main/java/android/system/StructFlock.java b/luni/src/main/java/android/system/StructFlock.java index 4908420..92cd95a 100644 --- a/luni/src/main/java/android/system/StructFlock.java +++ b/luni/src/main/java/android/system/StructFlock.java @@ -16,6 +16,8 @@ package android.system; +import libcore.util.Objects; + /** * Information returned/taken by fcntl(2) F_GETFL and F_SETFL. Corresponds to C's * {@code struct flock} from @@ -24,18 +26,22 @@ package android.system; * @hide */ public final class StructFlock { - /** The operation type, one of F_RDLCK, F_WRLCK, or F_UNLCK. */ - public short l_type; + /** The operation type, one of F_RDLCK, F_WRLCK, or F_UNLCK. */ + public short l_type; + + /** How to interpret l_start, one of SEEK_CUR, SEEK_END, SEEK_SET. */ + public short l_whence; - /** How to interpret l_start, one of SEEK_CUR, SEEK_END, SEEK_SET. */ - public short l_whence; + /** Start offset. */ + public long l_start; /*off_t*/ - /** Start offset. */ - public long l_start; /*off_t*/ + /** Byte count to operate on. */ + public long l_len; /*off_t*/ - /** Byte count to operate on. */ - public long l_len; /*off_t*/ + /** Process blocking our lock (filled in by F_GETLK, otherwise unused). */ + public int l_pid; /*pid_t*/ - /** Process blocking our lock (filled in by F_GETLK, otherwise unused). */ - public int l_pid; /*pid_t*/ + @Override public String toString() { + return Objects.toString(this); + } } diff --git a/luni/src/main/java/android/system/StructGroupReq.java b/luni/src/main/java/android/system/StructGroupReq.java index f7e7d0f..8ed5950 100644 --- a/luni/src/main/java/android/system/StructGroupReq.java +++ b/luni/src/main/java/android/system/StructGroupReq.java @@ -17,6 +17,7 @@ package android.system; import java.net.InetAddress; +import libcore.util.Objects; /** * Corresponds to C's {@code struct group_req}. @@ -24,15 +25,15 @@ import java.net.InetAddress; * @hide */ public final class StructGroupReq { - public final int gr_interface; - public final InetAddress gr_group; + public final int gr_interface; + public final InetAddress gr_group; - public StructGroupReq(int gr_interface, InetAddress gr_group) { - this.gr_interface = gr_interface; - this.gr_group = gr_group; - } + public StructGroupReq(int gr_interface, InetAddress gr_group) { + this.gr_interface = gr_interface; + this.gr_group = gr_group; + } - @Override public String toString() { - return "StructGroupReq[gr_interface=" + gr_interface + ",gr_group=" + gr_group + "]"; - } + @Override public String toString() { + return Objects.toString(this); + } } diff --git a/luni/src/main/java/android/system/StructGroupSourceReq.java b/luni/src/main/java/android/system/StructGroupSourceReq.java index f3958ad..c300338 100644 --- a/luni/src/main/java/android/system/StructGroupSourceReq.java +++ b/luni/src/main/java/android/system/StructGroupSourceReq.java @@ -17,6 +17,7 @@ package android.system; import java.net.InetAddress; +import libcore.util.Objects; /** * Corresponds to C's {@code struct group_source_req}. @@ -24,11 +25,8 @@ import java.net.InetAddress; * @hide */ public final class StructGroupSourceReq { - public final int gsr_interface; - public final InetAddress gsr_group; - public final InetAddress gsr_source; public StructGroupSourceReq(int gsr_interface, InetAddress gsr_group, InetAddress gsr_source) { @@ -37,9 +35,7 @@ public final class StructGroupSourceReq { this.gsr_source = gsr_source; } - @Override - public String toString() { - return "StructGroupSourceReq[gsr_interface=" + gsr_interface + ",gsr_group=" + gsr_group - + ",gsr_source=" + gsr_source + "]"; + @Override public String toString() { + return Objects.toString(this); } } diff --git a/luni/src/main/java/android/system/StructLinger.java b/luni/src/main/java/android/system/StructLinger.java index 8c65336..55ffc5c 100644 --- a/luni/src/main/java/android/system/StructLinger.java +++ b/luni/src/main/java/android/system/StructLinger.java @@ -16,6 +16,8 @@ package android.system; +import libcore.util.Objects; + /** * Corresponds to C's {@code struct linger} from * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html"><sys/socket.h></a> @@ -23,22 +25,22 @@ package android.system; * @hide */ public final class StructLinger { - /** Whether or not linger is enabled. Non-zero is on. */ - public final int l_onoff; + /** Whether or not linger is enabled. Non-zero is on. */ + public final int l_onoff; - /** Linger time in seconds. */ - public final int l_linger; + /** Linger time in seconds. */ + public final int l_linger; - public StructLinger(int l_onoff, int l_linger) { - this.l_onoff = l_onoff; - this.l_linger = l_linger; - } + public StructLinger(int l_onoff, int l_linger) { + this.l_onoff = l_onoff; + this.l_linger = l_linger; + } - public boolean isOn() { - return l_onoff != 0; - } + public boolean isOn() { + return l_onoff != 0; + } - @Override public String toString() { - return "StructLinger[l_onoff=" + l_onoff + ",l_linger=" + l_linger + "]"; - } + @Override public String toString() { + return Objects.toString(this); + } } diff --git a/luni/src/main/java/android/system/StructPasswd.java b/luni/src/main/java/android/system/StructPasswd.java index 9a94d3d..303973e 100644 --- a/luni/src/main/java/android/system/StructPasswd.java +++ b/luni/src/main/java/android/system/StructPasswd.java @@ -16,6 +16,8 @@ package android.system; +import libcore.util.Objects; + /** * Information returned by getpwnam(3) and getpwuid(3). Corresponds to C's * {@code struct passwd} from @@ -24,17 +26,21 @@ package android.system; * @hide */ public final class StructPasswd { - public String pw_name; - public int pw_uid; /* uid_t */ - public int pw_gid; /* gid_t */ - public String pw_dir; - public String pw_shell; + public final String pw_name; + public final int pw_uid; + public final int pw_gid; + public final String pw_dir; + public final String pw_shell; + + public StructPasswd(String pw_name, int pw_uid, int pw_gid, String pw_dir, String pw_shell) { + this.pw_name = pw_name; + this.pw_uid = pw_uid; + this.pw_gid = pw_gid; + this.pw_dir = pw_dir; + this.pw_shell = pw_shell; + } - public StructPasswd(String pw_name, int pw_uid, int pw_gid, String pw_dir, String pw_shell) { - this.pw_name = pw_name; - this.pw_uid = pw_uid; - this.pw_gid = pw_gid; - this.pw_dir = pw_dir; - this.pw_shell = pw_shell; - } + @Override public String toString() { + return Objects.toString(this); + } } diff --git a/luni/src/main/java/android/system/StructPollfd.java b/luni/src/main/java/android/system/StructPollfd.java index 9e65989..b9526bf 100644 --- a/luni/src/main/java/android/system/StructPollfd.java +++ b/luni/src/main/java/android/system/StructPollfd.java @@ -17,6 +17,7 @@ package android.system; import java.io.FileDescriptor; +import libcore.util.Objects; /** * Corresponds to C's {@code struct pollfd} from @@ -25,26 +26,26 @@ import java.io.FileDescriptor; * @hide */ public final class StructPollfd { - /** The file descriptor to poll. */ - public FileDescriptor fd; + /** The file descriptor to poll. */ + public FileDescriptor fd; - /** - * The events we're interested in. POLLIN corresponds to being in select(2)'s read fd set, - * POLLOUT to the write fd set. - */ - public short events; + /** + * The events we're interested in. POLLIN corresponds to being in select(2)'s read fd set, + * POLLOUT to the write fd set. + */ + public short events; - /** The events that actually happened. */ - public short revents; + /** The events that actually happened. */ + public short revents; - /** - * A non-standard extension that lets callers conveniently map back to the object - * their fd belongs to. This is used by Selector, for example, to associate each - * FileDescriptor with the corresponding SelectionKey. - */ - public Object userData; + /** + * A non-standard extension that lets callers conveniently map back to the object + * their fd belongs to. This is used by Selector, for example, to associate each + * FileDescriptor with the corresponding SelectionKey. + */ + public Object userData; - @Override public String toString() { - return "StructPollfd[fd=" + fd + ",events=" + events + ",revents=" + revents + "]"; - } + @Override public String toString() { + return Objects.toString(this); + } } diff --git a/luni/src/main/java/android/system/StructStat.java b/luni/src/main/java/android/system/StructStat.java index f5241e1..92e8512 100644 --- a/luni/src/main/java/android/system/StructStat.java +++ b/luni/src/main/java/android/system/StructStat.java @@ -16,6 +16,8 @@ package android.system; +import libcore.util.Objects; + /** * File information returned by fstat(2), lstat(2), and stat(2). Corresponds to C's * {@code struct stat} from @@ -89,4 +91,8 @@ public final class StructStat { this.st_blksize = st_blksize; this.st_blocks = st_blocks; } + + @Override public String toString() { + return Objects.toString(this); + } } diff --git a/luni/src/main/java/android/system/StructStatVfs.java b/luni/src/main/java/android/system/StructStatVfs.java index 426afcc..1d398af 100644 --- a/luni/src/main/java/android/system/StructStatVfs.java +++ b/luni/src/main/java/android/system/StructStatVfs.java @@ -16,6 +16,8 @@ package android.system; +import libcore.util.Objects; + /** * File information returned by fstatvfs(2) and statvfs(2). * @@ -70,4 +72,8 @@ public final class StructStatVfs { this.f_flag = f_flag; this.f_namemax = f_namemax; } + + @Override public String toString() { + return Objects.toString(this); + } } diff --git a/luni/src/main/java/android/system/StructTimeval.java b/luni/src/main/java/android/system/StructTimeval.java index c31ab3a..8a155b4 100644 --- a/luni/src/main/java/android/system/StructTimeval.java +++ b/luni/src/main/java/android/system/StructTimeval.java @@ -16,6 +16,8 @@ package android.system; +import libcore.util.Objects; + /** * Corresponds to C's {@code struct timeval} from * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_time.h.html"><sys/time.h></a> @@ -34,7 +36,6 @@ public final class StructTimeval { this.tv_usec = tv_usec; } - public static StructTimeval fromMillis(long millis) { long tv_sec = millis / 1000; long tv_usec = (millis - (tv_sec * 1000)) * 1000; @@ -46,6 +47,6 @@ public final class StructTimeval { } @Override public String toString() { - return "StructTimeval[tv_sec=" + tv_sec + ",tv_usec=" + tv_usec + "]"; + return Objects.toString(this); } } diff --git a/luni/src/main/java/android/system/StructUcred.java b/luni/src/main/java/android/system/StructUcred.java index 563a904..a1e3cd6 100644 --- a/luni/src/main/java/android/system/StructUcred.java +++ b/luni/src/main/java/android/system/StructUcred.java @@ -16,6 +16,8 @@ package android.system; +import libcore.util.Objects; + /** * Corresponds to C's {@code struct ucred}. * @@ -38,6 +40,6 @@ public final class StructUcred { } @Override public String toString() { - return "StructUcred[pid=" + pid + ",uid=" + uid + ",gid=" + gid + "]"; + return Objects.toString(this); } } diff --git a/luni/src/main/java/android/system/StructUtsname.java b/luni/src/main/java/android/system/StructUtsname.java index 21e08bb..2b7937c 100644 --- a/luni/src/main/java/android/system/StructUtsname.java +++ b/luni/src/main/java/android/system/StructUtsname.java @@ -16,6 +16,8 @@ package android.system; +import libcore.util.Objects; + /** * Information returned by uname(2). Corresponds to C's * {@code struct utsname} from @@ -24,26 +26,30 @@ package android.system; * @hide */ public final class StructUtsname { - /** The OS name, such as "Linux". */ - public final String sysname; + /** The OS name, such as "Linux". */ + public final String sysname; + + /** The machine's unqualified name on some implementation-defined network. */ + public final String nodename; - /** The machine's unqualified name on some implementation-defined network. */ - public final String nodename; + /** The OS release, such as "2.6.35-27-generic". */ + public final String release; - /** The OS release, such as "2.6.35-27-generic". */ - public final String release; + /** The OS version, such as "#48-Ubuntu SMP Tue Feb 22 20:25:29 UTC 2011". */ + public final String version; - /** The OS version, such as "#48-Ubuntu SMP Tue Feb 22 20:25:29 UTC 2011". */ - public final String version; + /** The machine architecture, such as "armv7l" or "x86_64". */ + public final String machine; - /** The machine architecture, such as "armv7l" or "x86_64". */ - public final String machine; + public StructUtsname(String sysname, String nodename, String release, String version, String machine) { + this.sysname = sysname; + this.nodename = nodename; + this.release = release; + this.version = version; + this.machine = machine; + } - public StructUtsname(String sysname, String nodename, String release, String version, String machine) { - this.sysname = sysname; - this.nodename = nodename; - this.release = release; - this.version = version; - this.machine = machine; - } + @Override public String toString() { + return Objects.toString(this); + } } |