//This file is automatically generated. DO NOT EDIT!
package com.robotraconteur.testing.TestService2;
import java.util.*;
import com.robotraconteur.*;
public class com__robotraconteur__testing__TestService2Factory extends ServiceFactory
{
    public String defString()
{
    String out="service com.robotraconteur.testing.TestService2\n\noption version 0.8\n\nexception testexception3\n\nstruct ostruct2\nfield double[] a1\nend struct\n\n\nobject baseobj\nproperty double d1\nproperty double[] d2\n\nfunction double func3(double d1, double d2)\n\nevent ev1()\n\nobjref subobj o5\n\npipe double[] p1\n\ncallback void cb2(double d1, double d2)\n\nwire double[] w1\n\nmemory double[] m1\n\n\nend object\n\nobject subobj\n\nfunction double add_val(double v)\n\nend object\n\n";
    return out;    }
    public String getServiceName() {return "com.robotraconteur.testing.TestService2";}
    public ostruct2_stub ostruct2_stubentry;
    public com__robotraconteur__testing__TestService2Factory()
{
    ostruct2_stubentry=new ostruct2_stub(this);
    }
    public IStructureStub findStructureStub(String objecttype)
    {
    if (objecttype.equals("ostruct2"))    return ostruct2_stubentry;
    throw new DataTypeException("Cannot find appropriate structure stub");
    }
    public IPodStub findPodStub(String objecttype)
    {
    throw new DataTypeException("Cannot find appropriate structure stub");
    }
    public INamedArrayStub findNamedArrayStub(String objecttype)
    {
    throw new DataTypeException("Cannot find appropriate structure stub");
    }
    public ServiceStub createStub(WrappedServiceStub innerstub) {
    String objecttype=innerstub.getRR_objecttype().getServiceDefinition().getName() + "." + innerstub.getRR_objecttype().getName();
    if (RobotRaconteurNode.splitQualifiedName(objecttype)[0].equals( "com.robotraconteur.testing.TestService2")) {
    String objshort=removePath(objecttype);
    if(objshort.equals( "baseobj"))
    return new baseobj_stub(innerstub);
    if(objshort.equals( "subobj"))
    return new subobj_stub(innerstub);
    } else {
    String ext_service_type=(RobotRaconteurNode.splitQualifiedName(objecttype)[0]);
    return RobotRaconteurNode.s().getServiceType(ext_service_type).createStub(innerstub);
    }
    throw new ServiceException("Could not create stub");
    }
    public ServiceSkel createSkel(Object obj) {
    String objtype=ServiceSkelUtil.findParentInterface(obj.getClass()).getName().toString();
    if ((RobotRaconteurNode.splitQualifiedName(objtype.toString())[0]).equals( "com.robotraconteur.testing.TestService2")) {
    String sobjtype=removePath(objtype);
    if(sobjtype.equals( "baseobj"))
    return new baseobj_skel((baseobj)obj);
    if(sobjtype.equals( "subobj"))
    return new subobj_skel((subobj)obj);
    } else {
    String ext_service_type=(RobotRaconteurNode.splitQualifiedName(objtype.toString())[0]);
    return RobotRaconteurNode.s().getServiceType(ext_service_type).createSkel(obj);
    }
    throw new ServiceException("Could not create skel");
    }
    public RobotRaconteurException downCastException(RobotRaconteurException rr_exp){
    if (rr_exp==null) return rr_exp;
    String rr_type=rr_exp.error;
    if (!rr_type.contains(".")) return rr_exp;
    String[] rr_stype = RobotRaconteurNode.splitQualifiedName(rr_type);
    if (!rr_stype[0].equals("com.robotraconteur.testing.TestService2")) return RobotRaconteurNode.s().downCastException(rr_exp);
    if (rr_stype[1].equals("testexception3")) return new testexception3(rr_exp.getMessage(),rr_exp.errorSubName,rr_exp.errorParam);
    return rr_exp;
    }
}
