📄 vobject.java
字号:
package HECore.stddata;
import HPCore.Exception.*;
import java.util.*;
import java.beans.*;
import java.awt.*;
import HAB.HcBean.HalcyonAppletBeanInterface;
import java.lang.reflect.*;
public class VObject extends Variant{
private Object obj=null;
private Vector beanparam= new Vector();
private String classtype=null;
private BeanInfo bi = null;
private PropertyDescriptor properties[];
private MethodDescriptor methods[];
private EventSetDescriptor events[];
private int JavaWidth=0;
private int JavaHeight=0;
private int JavaLeft=0;
private int JavaTop=0;
private String name=null;
private Container con = null;
private static boolean isnoplugin=false;
//private Wrapper wobj=null;
public VObject()
{
classtype="object";
}
public VObject(Object obj) //throws HpException
{
try
{
if (obj==null)
{
classtype="object";
}//throw new HpException(117,"Object is null");
else
{
classtype=obj.getClass().getName();
this.obj=obj;
boolean exception =false;
if(!isnoplugin)
{
try{
if (bi == null)
bi = Introspector.getBeanInfo(obj.getClass());
properties = bi.getPropertyDescriptors();
methods = bi.getMethodDescriptors();
events = bi.getEventSetDescriptors();
BeanDescriptor bd = bi.getBeanDescriptor();
}catch(Throwable e){exception=true;}
}
else
{
if (bi == null)
bi=((HalcyonAppletBeanInterface)obj).getBeanInfo();
properties = bi.getPropertyDescriptors();
methods = bi.getMethodDescriptors();
events = bi.getEventSetDescriptors();
}
}
}catch(Throwable e){System.out.println(e);}
}
public VObject(String classtype) //throws HpException
{
try{
this.classtype=classtype;
Class cls=Class.forName(classtype);
obj =cls.newInstance();
if (obj==null)
return ;//throw new HpException(117,"Object is null");
}catch(Throwable e){System.out.println(e);}
}
public VObject(String classtype,boolean is_new) throws HpException
{
this.classtype=classtype;
boolean exception=false;
if(is_new)
{
try{
Class cls=Class.forName(classtype);
obj =cls.newInstance();
if (obj==null)
throw new HpException(117,"Object is null");
if(!isnoplugin)
{
try {
if (bi == null)
bi = Introspector.getBeanInfo(obj.getClass());
properties = bi.getPropertyDescriptors();
methods = bi.getMethodDescriptors();
events = bi.getEventSetDescriptors();
BeanDescriptor bd = bi.getBeanDescriptor();
}catch(Throwable e){exception=true;}
}
else
{
if (bi == null)
bi=((HalcyonAppletBeanInterface)obj).getBeanInfo();
properties = bi.getPropertyDescriptors();
methods = bi.getMethodDescriptors();
events = bi.getEventSetDescriptors();
}
}catch(Throwable e){System.out.println(e);}
}
else
obj=null;
//wobj=new Wrapper(obj);
}
public String getClassType() {
return classtype;
}
public void set(Object obj) throws HpException {
if(!obj.getClass().getName().equalsIgnoreCase(classtype) && !classtype.equalsIgnoreCase("object") )
throw new HpException(13,"Type mismatch");
this.obj= obj;
boolean exception=false;
if (obj==null)
throw new HpException(117,"Object is null");
if(!isnoplugin)
{
try {
if(bi == null)
bi = Introspector.getBeanInfo(obj.getClass());
properties = bi.getPropertyDescriptors();
methods = bi.getMethodDescriptors();
events = bi.getEventSetDescriptors();
BeanDescriptor bd = bi.getBeanDescriptor();
}catch(Throwable e){exception=true;System.out.println(e);}
}
else
{
try{
if (bi == null)
bi=((HalcyonAppletBeanInterface)obj).getBeanInfo();
properties = bi.getPropertyDescriptors();
methods = bi.getMethodDescriptors();
events = bi.getEventSetDescriptors();
}catch(Throwable e){System.out.println(e);}
}
}
public void set(VObject ob) throws HpException
{
Object obj =ob.objValue();
boolean exception=false;
if (obj==null)
throw new HpException(117,"Object is null");
else
this.obj=obj;
if(!obj.getClass().getName().equalsIgnoreCase(classtype) && !classtype.equalsIgnoreCase("object") )
throw new HpException(13,"Type mismatch");
if(!isnoplugin)
{
try {
if(bi == null)
bi = Introspector.getBeanInfo(obj.getClass());
properties = bi.getPropertyDescriptors();
methods = bi.getMethodDescriptors();
events = bi.getEventSetDescriptors();
BeanDescriptor bd = bi.getBeanDescriptor();
}catch(Throwable e){exception=true;}
}
else
{
try{
if (bi == null)
bi=((HalcyonAppletBeanInterface)obj).getBeanInfo();
properties = bi.getPropertyDescriptors();
methods = bi.getMethodDescriptors();
events = bi.getEventSetDescriptors();
}catch(Throwable e){System.out.println(e);}
}
}
/**
* return this VObject's obj
* obj is a Object.
*/
public Object objValue() throws HpException
{
if(obj==null)
throw new HpException(91,"Object variable or with block variable not set ");
return obj;
}
/**
* return Current VObject type.
*/
public short getType() {
return Variant.V_OBJ;
}
/**
* Justment this VObject is null.
*/
public boolean isNothing()
{
if(obj==null)
return true;
else
return false;
}
public String toString()
{
return obj.toString();
}
/**
*
* set Beans's Default Property.
* Param :<br>
* i is property's value .
*/
public void setDefaultProperty(short i) throws HpException {
push_parm(i);
setDefaultProper(1);
}
/**
* set Beans's Default Property. <br>
* Param :<br>
* i is property's value .
*/
public void setDefaultProperty(int i) throws HpException
{
push_parm(i);
setDefaultProper(1);
}
/**
*
* set Beans's Default Property. <br>
* Param :<br>
* i is property's value .
*/
public void setDefaultProperty(boolean i) throws HpException {
push_parm(i);
setDefaultProper(1);
}
/**
* set Beans's Default Property. <br>
* Param :<br>
* i is property's float value .
*/
public void setDefaultProperty(float i) throws HpException {
push_parm(i);
setDefaultProper(1);
}
/**
*
* set Beans's Default Property. <br>
* Param :<br>
* i is property's double value .
*/
public void setDefaultProperty(double i) throws HpException {
push_parm(i);
setDefaultProper(1);
}
/**
*
* set Beans's Default Property. <br>
* Param :<br>
* i is property's String value .
*/
public void setDefaultProperty(String i) throws HpException {
push_parm(i);
setDefaultProper(1);
}
public void setDefaultProperty(Object obj) throws HpException {
push_parm(obj);
setDefaultProper(1);
}
/**
* set Beans's Default Property. <br>
* Param :<br>
* i is property's Variant value .<br>
*/
public void setDefaultProperty(Variant i) throws HpException
{
push_parm(i);
setDefaultProper(1);
}
/**
* set Beans's Property. <br>
* Param :<br>
* property is this Beans's Property Name. <br>
* i is Beans Property's short value . <br>
*/
public void setProperty(String property, short s) 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 Short(s);
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 int value . <br>
*/
public void setProperty(String property,int in) 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 Integer(in);
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 boolean value .<br>
*/
public void setProperty(String property,boolean bool) 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 Boolean(bool);
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 float value . <br>
*/
public void setProperty(String property,float f) 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");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -