// The contents of this file are subject to the Mozilla Public License Version 1.1 // (the "License"); you may not use this file except in compliance with the License. // You may obtain a copy of the License at . // // Software distributed under the License is distributed on an "AS IS" basis, WITHOUT // WARRANTY OF ANY KIND, either express or implied. See the License for the specific // language governing rights and limitations under the License. // // The Original Code is the Venice Web Communities System. // // The Initial Developer of the Original Code is Eric J. Bowersox , // for Silverwrist Design Studios. Portions created by Eric J. Bowersox are // Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. // // Contributor(s): // Implements the XML-RPC Validation Suite functions as documented by UserLand Software, // see http://www.xmlrpc.com/validator1Docs importPackage(java.util); importPackage(Packages.com.silverwrist.venice.ui.rpc); xreq = bsf.lookupBean("xmlrpc"); if ("validator1.arrayOfStructsTest"==xreq.method) { // arrayOfStructsTest coming right up! if (xreq.paramCount!=1) vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter count mismatch")); else if ("array"!=xreq.getParamType(0)) vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch")); else { // The parameter is an array of structs containing at least three elements, named // "moe", "larry", and "curly", all of which are integers. We need to add up all // the "curly" elements and return the sum. parm = vlib.castList(xreq.getParam(0)); accum = 0; it = parm.iterator(); while (it.hasNext()) { // build the return value str = vlib.castMap(it.next()); accum += vlib.toInteger(str.get("curly")); } // end while vlib.output(vlib.createInteger(accum)); } // end else vlib.done(); } // end if if ("validator1.countTheEntities"==xreq.method) { // countTheEntities test coming right up! if (xreq.paramCount!=1) vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter count mismatch")); else if ("string"!=xreq.getParamType(0)) vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch")); else { // We get a string in which we're supposed to count the number of left angle brackets, // right angle brackets, ampersands, quotes, and apostrophes. We return that information // in a formatted structure. str = xreq.getParamString(0) + ""; nleft = 0; nright = 0; namper = 0; napos = 0; nquot = 0; for (i=0; i