Author: mturk Date: Sat Apr 25 07:39:06 2009 New Revision: 768491 URL: http://svn.apache.org/viewvc?rev=768491&view=rev Log: Add Descriptor.toString
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor32.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor64.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java?rev=768491&r1=768490&r2=768491&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java Sat Apr 25 07:39:06 2009 @@ -123,6 +123,17 @@ * descriptors being pointed to by these objects are also * equal. Returns false otherwise. */ + @Override public abstract boolean equals(Object other); + /** + * Returns a string representation of the Descriptor. + * The returned string is hexadecimal representation of the underlying + * descriptor for the {...@code pointer} type descriptors and integer for + * {...@code posix} descriptor types . + * @return a string representation of the descriptor. + */ + @Override + public abstract String toString(); + } Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor32.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor32.java?rev=768491&r1=768490&r2=768491&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor32.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor32.java Sat Apr 25 07:39:06 2009 @@ -65,4 +65,18 @@ return false; } + public String toString() + { + if (PHANDLE != 0) { + String h = Integer.toHexString(PHANDLE); + return "0x" + ("00000000" + h).substring(h.length()); + } + else if (IHANDLE >= 0) { + return Integer.toString(IHANDLE); + } + else { + return "(nil)"; + } + } + } Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor64.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor64.java?rev=768491&r1=768490&r2=768491&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor64.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor64.java Sat Apr 25 07:39:06 2009 @@ -65,4 +65,18 @@ return false; } + public String toString() + { + if (PHANDLE != 0) { + String h = Long.toHexString(PHANDLE); + return "0x" + ("0000000000000000" + h).substring(h.length()); + } + else if (IHANDLE >= 0) { + return Integer.toString(IHANDLE); + } + else { + return "(nil)"; + } + } + } Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java?rev=768491&r1=768490&r2=768491&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java Sat Apr 25 07:39:06 2009 @@ -93,6 +93,7 @@ * pointers being pointed to by these objects are also * equal. Returns false otherwise. */ + @Override public abstract boolean equals(Object other); /** @@ -249,6 +250,7 @@ * pointer. * @return a hexadecimal representation of the pointer. */ + @Override public abstract String toString(); } Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java?rev=768491&r1=768490&r2=768491&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer32.java Sat Apr 25 07:39:06 2009 @@ -161,8 +161,13 @@ public String toString() { - String h = Integer.toHexString(POINTER); - return "0x" + ("00000000" + h).substring(h.length()); + if (POINTER != 0) { + String h = Integer.toHexString(POINTER); + return "0x" + ("00000000" + h).substring(h.length()); + } + else { + return "(nil)"; + } } } Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java?rev=768491&r1=768490&r2=768491&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer64.java Sat Apr 25 07:39:06 2009 @@ -161,8 +161,13 @@ public String toString() { - String h = Long.toHexString(POINTER); - return "0x" + ("0000000000000000" + h).substring(h.length()); + if (POINTER != 0L) { + String h = Long.toHexString(POINTER); + return "0x" + ("0000000000000000" + h).substring(h.length()); + } + else { + return "(nil)"; + } } }