/*=============================================================================
* Copyright Texas Instruments 2003-2004. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $ProjectHeader: OSCRIPT 0.155 Fri, 20 Dec 2002 18:34:22 -0800 rclark $
*/
package oscript.data;
import oscript.exceptions.*;
/**
* An XML-RPC object.
*
* @author Rob Clark (rob@ti.com)
*/
public class XmlRpcObject extends OObject
{
/**
* The type object for an instance of XmlRpcObject.
*/
public final static Value TYPE = BuiltinType.makeBuiltinType("oscript.data.XmlRpcObject");
public final static String PARENT_TYPE_NAME = "oscript.data.OObject";
public final static String TYPE_NAME = "XmlRpcObject";
public final static String[] MEMBER_NAMES = new String[] {
"getType",
"castToJavaObject",
"castToString",
"bopInstanceOf",
"bopEquals",
"bopNotEquals",
"getMember",
};
/**
* The client object used to access the server
*/
private org.apache.xmlrpc.XmlRpcClient client;
/**
* The name of the object.
*/
private String objectName;
public static void init()
{
oscript.OscriptInterpreter.getGlobalScope().
createMember("XmlRpcObject",0).opAssign(TYPE);
}
/*=======================================================================*/
/**
* Class Constructor.
*
* @param client the client object
* @param objectName the name of the object
*/
XmlRpcObject( org.apache.xmlrpc.XmlRpcClient client, String objectName )
{
super();
this.client = client;
this.objectName = objectName;
}
/*=======================================================================*/
/**
* For benefit of <code>BuiltinType</code>... always throws an exception because
* script code should not be allowed to directly create an instance...
*
* @param args arguments to this constructor
* @throws PackagedScriptObjectException(Exception) if wrong number of args
*/
public XmlRpcObject( oscript.util.MemberTable args )
{
throw PackagedScriptObjectException.makeExceptionWrapper( new OIllegalArgumentException("wrong number of args!") );
}
/*=======================================================================*/
/**
* Get the type of this object. The returned type doesn't have to take
* into account the possibility of a script type extending a built-in
* type, since that is handled by {@link #getType}.
*
* @return the object's type
*/
protected Value getTypeImpl()
{
return TYPE;
}
/*=======================================================================*/
/**
* Get a member of this object.
*
* @param id the id of the symbol that maps to the member
* @param exception whether an exception should be thrown if the
* member object is not resolved
* @return a reference to the member
* @throws PackagedScriptObjectException(NoSuchMemberException)
*/
public Value getMember( int id, boolean exception )
throws PackagedScriptObjectException
{
Value member = super.getMember( id, false );
if( member != null )
return member;
return new XmlRpcMethod( client, objectName, Symbol.getSymbol(id).castToString() );
}
}
/*
* Local Variables:
* tab-width: 2
* indent-tabs-mode: nil
* mode: java
* c-indentation-style: java
* c-basic-offset: 2
* eval: (c-set-offset 'substatement-open '0)
* eval: (c-set-offset 'case-label '+)
* eval: (c-set-offset 'inclass '+)
* eval: (c-set-offset 'inline-open '0)
* End:
*/
|