Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 37314 invoked from network); 13 Nov 2002 19:12:04 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 13 Nov 2002 19:12:04 -0000 Received: (qmail 6541 invoked by uid 97); 13 Nov 2002 19:13:00 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 6439 invoked by uid 97); 13 Nov 2002 19:12:59 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 6347 invoked by uid 98); 13 Nov 2002 19:12:59 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Message-ID: <007201c28b48$8a9ce740$920a12ac@MFX01> From: "Eugen Kuleshov" To: Subject: [digester] SetNextRule problem Date: Wed, 13 Nov 2002 14:11:59 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hello, I've been playing with Digester for quite a while. I use it to make na XML binding to the proprietory Java object model which is already exists. There is a lot of challenges in this process, because object model was designed without having such a task in mind. I have the case, when one of the methods requires array of some particular type to be passed as a parameter. Unfortunately I can only create java.util.LinkedList with the same content and then I was thinking to use SetNextRule to call that method. This works for the similar situation with the CallMethodRule and Digester is using the registered convertors to handle different types. Unfortunately SetNextRule does not using convertors for the same situation. This is should be very simple to fix (see end() method of SetNextRule below). ---- /** * Process the end of this element. */ public void end() throws Exception { // Identify the objects to be used Object child = digester.peek(0); Object parent = digester.peek(1); if (digester.log.isDebugEnabled()) { if (parent == null) { digester.log.debug("[SetNextRule]{" + digester.match + "} Call [NULL PARENT]." + methodName + "(" + child + ")"); } else { digester.log.debug("[SetNextRule]{" + digester.match + "} Call " + parent.getClass().getName() + "." + methodName + "(" + child + ")"); } } // Call the specified method Class paramTypes[] = new Class[1]; if (paramType != null) { paramTypes[0] = digester.getClassLoader().loadClass(paramType); } else { paramTypes[0] = child.getClass(); } // Convert parameter to the required type if( !paramTypes[ 0].isAssignableFrom( child.getClass())) child = ConvertUtils.convert( child, paramTypes[ 0]); if (useExactMatch) { MethodUtils.invokeExactMethod(parent, methodName, new Object[]{ child }, paramTypes); } else { MethodUtils.invokeMethod(parent, methodName, new Object[]{ child }, paramTypes); } } ---- I also think that it will be not a bad idea to add the following constructor to the SetNextRule. SetNextRule( String methodName, Class parameterClass) regards, Eugen Kuleshov -- To unsubscribe, e-mail: For additional commands, e-mail: