Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
Description
The method write(IndentationTarget pTarget, Object pObject) in IndentationEngineImpl throws a ClassCastException when object type is a primitive array. The solution is (AFAIK) to use reflection. The patch:
Index: IndentationEngineImpl.java
===================================================================
RCS file: /home/cvspublic/ws-jaxme/src/js/org/apache/ws/jaxme/js/IndentationEngineImpl.java,v
retrieving revision 1.3
diff -u -r1.3 IndentationEngineImpl.java
— IndentationEngineImpl.java 16 Feb 2004 23:39:55 -0000 1.3
+++ IndentationEngineImpl.java 19 Apr 2005 07:06:40 -0000
@@ -18,6 +18,7 @@
import java.io.IOException;
import java.io.StringWriter;
+import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -278,11 +279,11 @@
public void write(IndentationTarget pTarget, Object pObject)
throws IOException {
if (pObject.getClass().isArray()) {
- Object[] objects = (Object[]) pObject;
- for (int i = 0; i < objects.length; i++) { - write(pTarget, objects[i]); - }
- } else if (pObject instanceof JavaSourceObject)
Unknown macro: {+ int arrayLength = Array.getLength(pObject);+ for (int i = 0; i < arrayLength; i++) { + write(pTarget, Array.get(pObject, i)); + }+ }
else if (pObject instanceof JavaSourceObject)
{ pTarget.write(((JavaSourceObject) pObject).getName()); }else if (pObject instanceof List) {
for (Iterator iter = ((List) pObject).iterator(); iter.hasNext(); ) {