⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vobject.java

📁 一个简单的visio程序。
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	try {
	if(md != null) {
      Class param[] = md.getParameterTypes();
      Object objarg[] = new Object[1];
      objarg[0] = new Float(f);
      md.invoke(obj,objarg);
     }
	 beanparam.removeAllElements();
    }catch(Throwable e){ throw new HpException(1,e.getMessage()); }    
  }

 /**
  * set  Beans's  Property. <br>
  * Param :<br>
  * property is this Beans's Property Name.<br>  
  * i is Beans Property's double value . <br>
  */
 public void setProperty(String property,double dbl) throws HpException
  {
  if(bi==null)
		throw new HpException(424,"Object Require");
	Method md = searchMethod(property,false);

    if(property.equalsIgnoreCase("name") && name!=null)
             throw new HpException(0," Function call on left-hand side of assignment must return Variant or Object"); 
	try {
	if(md != null) {
      Class param[] = md.getParameterTypes();
      Object objarg[] = new Object[1];
      objarg[0] = new Double(dbl);
      md.invoke(obj,objarg);
     }
	 beanparam.removeAllElements();
    }catch(Throwable e){ throw new HpException(1,e.getMessage()); }    
  }

 /**
  * set  Beans's  Property. <br>
  * Param :<br>
  * property is this Beans's Property Name.<br> 
  * i is Beans Property's String value . <br>
  */
 public void setProperty(String property,String str) throws HpException
  {
  if(bi==null)
		throw new HpException(424,"Object Require");
	Method md = searchMethod(property,false);

    if(property.equalsIgnoreCase("name") && name!=null)
             throw new HpException(0," Function call on left-hand side of assignment must return Variant or Object"); 
	try {
	if(md != null) {
      Class param[] = md.getParameterTypes();
      Object objarg[] = new Object[1];
      objarg[0] = new String(str);
      md.invoke(obj,objarg);
     }
	 beanparam.removeAllElements();
    }catch(Throwable e){ throw new HpException(1,e.getMessage()); }    
  }

  public void setProperty(String property,Object obj) throws HpException
  {
    if(bi==null)
		throw new HpException(424,"Object Require");
	Method md = searchMethod(property,false);

    if(property.equalsIgnoreCase("name") && name!=null)
             throw new HpException(0," Function call on left-hand side of assignment must return Variant or Object"); 
	try {
	if(md != null) {
      Class param[] = md.getParameterTypes();
      Object objarg[] = new Object[1];
      objarg[0] = obj;
      md.invoke(obj,objarg);
     }
	 beanparam.removeAllElements();
    }catch(Throwable e){ throw new HpException(1,e.getMessage()); }    
  }

 /**
  * set  Beans's  Property. <br>
  * Param :<br>
  * property is this Beans's Property Name.<br> 
  * i is Beans Property's Variant value . <br>
  */
 public void setProperty(String property,Variant var) throws HpException 
 { 
  if(bi==null)
		throw new HpException(424,"Object Require");
	Method md = searchMethod(property,false);

    if(property.equalsIgnoreCase("name") && name!=null)
             throw new HpException(0," Function call on left-hand side of assignment must return Variant or Object"); 
	try {
	if(md != null) {
      Class param[] = md.getParameterTypes();
      Object objarg[] = new Object[1];
      objarg[0] = var.objValue();
      md.invoke(obj,objarg);
     }
	 beanparam.removeAllElements();
    }catch(Throwable e){ throw new HpException(1,e.getMessage()); }    
  }
 
 
 public void setDefaultProper(int param_num) throws HpException
  {
      int defaultIndex=0;
	  if(bi==null)
		 throw new HpException(424,"Object Require");
      try{
          if(bi!=null)
          {
            defaultIndex=bi.getDefaultPropertyIndex();
            if(defaultIndex!=-1)
            {
       
               Method md =properties[defaultIndex].getWriteMethod();
               if(properties[defaultIndex].getName().equalsIgnoreCase("name") && name!=null)
                 throw new HpException(0," Function call on left-hand side of assignment must return Variant or Object"); 
               Class param[] =md.getParameterTypes();
               dealParam(param);
               Object objarg[] =new Object[beanparam.size()];
               for(int i=0;i<beanparam.size();i++)
                objarg[i]=beanparam.elementAt(i);
               md.invoke(obj,objarg);
          
            }
          }
	}catch(Throwable e){System.out.println(e);}  
    
   beanparam.removeAllElements();
  }

 
 
 public void setProper(String property,int param_num ) throws HpException
  {
    boolean found=false;
	if(bi==null)
		throw new HpException(424,"Object Require");
    int index=0;
    try{
         for(int i = 0;i < properties.length;i++)
         {
           if(properties[i].getName().equalsIgnoreCase(property)) { 
            found = true;
            index = i;
            break;
           }

         }
        if(found)
        {
          Method md = properties[index].getWriteMethod();
          if(property.equalsIgnoreCase("name") && name!=null)
                 throw new HpException(0," Function call on left-hand side of assignment must return Variant or Object"); 
          Class param[] = md.getParameterTypes();
          //dealParam(param);
          Object objarg[] = new Object[beanparam.size()];
          for(int i = 0;i < beanparam.size();i ++)
           objarg[i] = beanparam.elementAt(i);
           md.invoke(obj,objarg);
        }
        beanparam.removeAllElements();
      }catch(Throwable e){System.out.println(e);}  
    
  }
  
  /**
   * 
   * get Bean's Default Property. <br>
   * return type is Variant.<br>
   *
   */
 
  
  public Variant getDefaultProperty() throws HpException
  {
    int defaultIndex=0;
        if(bi!=null)
        {
          defaultIndex=bi.getDefaultPropertyIndex();
          if(defaultIndex!=-1) {
           Method md =properties[defaultIndex].getReadMethod();
           Object objarg[]={};
           Class returnType=md.getReturnType();
           return dealReturnType(returnType,md,objarg);
           }
         else
          throw new HpException(450,"Wrong number of arguments or invalid property assignment");;
       }
    else
        return null;
  }
 
   /** 
    *  set a = recordset.Fields(0);
	*/
 
 private Method searchMethod(String property,boolean flag) {
        for(int i=0;i<properties.length;i++)
         {
           if(properties[i].getName().equalsIgnoreCase(property))
           { 
		   if(flag) // get
		     return properties[i].getReadMethod();
           else
		     return properties[i].getWriteMethod();
           }
         }

		if(!flag) return null;

		for(int i=0;i<methods.length;i++)
           {
		    Method mm = methods[i].getMethod();
            if(mm.getName().equalsIgnoreCase(property))
          	 return mm;
           }
	   return null;
  }

 public Variant getProperty(String property,int num) throws HpException {
    try {
		if(bi==null)
     	 throw new HpException(424,"Object Require");  
		Method md = searchMethod(property,true);
		if(md != null)  
			{
            Class param[] =md.getParameterTypes(); 
		    Class returnType= md.getReturnType();
            dealParam(param);
            Object objarg[] =new Object[beanparam.size()];
            for(int i=0;i<beanparam.size();i++)
				objarg[i]=beanparam.elementAt(i);
            Variant v = dealReturnType(returnType,md,objarg);
            beanparam.removeAllElements();
		    return v;
			}      
		else
		  throw new HpException(1,"Property " + property + " not Found");

     }catch(Throwable e){ throw new HpException(2, e.getMessage());}
 }
   
  /**
   * 
   * get Bean's  Property. <br>
   * Param :<br> 
   * property is Bean's Property Name.<br> 
   * return type is Variant.
   *
   */
 
  public Variant  getProperty(String property) throws HpException
  {
    boolean found=false;
    int index = 0;
    if(bi==null)
     	 throw new HpException(424,"Object Require");  
	Method md = searchMethod(property,true);
    try{
	    if(md != null) {
          Object objarg[]={};
          Class returnType=md.getReturnType();
          return dealReturnType(returnType,md,objarg);
        }
       else
        return null;
       }catch(Throwable e){System.out.println(e);return null;}
   }

  /**
   *  
   * invoke Bean's Method. <br> 
   * Param :<br>  
   * methodname is Bean's Method name ,param_num is the Method's param num.
   */

  public void invokeMethod(String methodname ,int param_num) throws HpException
  {
    if(methodname.equalsIgnoreCase("move"))
      {
      switch (param_num)
       {
         case 1: 
             setLeft(convert.tointValue(beanparam.elementAt(0)));
             break;     
        case 2:
             setLeft(convert.tointValue(beanparam.elementAt(0)));
             setTop(convert.tointValue(beanparam.elementAt(1)));
             break;     
        case 3:
             setLeft(convert.tointValue(beanparam.elementAt(0)));
             setTop(convert.tointValue(beanparam.elementAt(1)));
             setWidth(convert.tointValue(beanparam.elementAt(2)));
             break;     
        case 4:
             setLeft(convert.tointValue(beanparam.elementAt(0)));
             setTop(convert.tointValue(beanparam.elementAt(1)));
             setWidth(convert.tointValue(beanparam.elementAt(2)));
             setHeight(convert.tointValue(beanparam.elementAt(3)));
             break;     
       }
    }

   else
   {
      boolean found=false;
      int index=0;
      try{
          
 
          for(int i=0;i<methods.length;i++)
           {
             if(methods[i].getMethod().getName().equalsIgnoreCase(methodname))
             { 
               found=true;
               index=i;
               break;
             }
           }
          if(found)
          {
           Method md =methods[index].getMethod();
           Class param[] =md.getParameterTypes(); 
           dealParam(param);
           Object objarg[] =new Object[beanparam.size()];
           for(int i=0;i<beanparam.size();i++)
            objarg[i]=beanparam.elementAt(i);
           md.invoke(obj,objarg);
           beanparam.removeAllElements();
          }
         else
          beanparam.removeAllElements();//return null;
        }catch(Throwable e){ throw new HpException(0,e.getMessage());}  
    }
  }

  /**
   * 
   * push Variant value to Vector. <br> 
   * return this VObject 
   */
  public VObject push_parm(Variant var) {
    beanparam.addElement(var);
    return this;
   }
  
  /**
   * push short vlaue to Vector. <br> 
   * return this VObject 
   */

  public VObject push_parm(short i) {
    beanparam.addElement(new Integer((int)i));
    return this;
    }
  
  /**
   * 
   * push int vlaue to Vector. <br> 
   * return this VObject 
   */
  public VObject push_parm(int i) {
    beanparam.addElement(new Integer(i));
    return this;
   }
  
  
  /**
   * 
   * push boolean value to Vector. <br> 
   * return this VObject 
   */

  public VObject push_parm(boolean flag) {
    beanparam.addElement(new Boolean(flag));
    return this;
  }
  
  /**
   * 
   * push float vlaue to Vector. <br> 
   * return this VObject 
   */
  public VObject push_parm(float f) {
   beanparam.addElement(new Float(f));
   return this;
  }
  
  
  /**
   * push double value to Vector. <br>  
   * return this VObject 
   */
  public VObject push_parm(double dbl) {
      beanparam.addElement(new Double(dbl));
      return this;
  }
  
  
  /**
   * 
   * push String value to Vector. <br>  
   * return this VObject 
   */
  public VObject push_parm(String str) {
      beanparam.addElement(new String(str));
      return this;
     }
  
 public VObject push_parm(Object obj) {
      beanparam.addElement(obj);
      return this;
     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -