📄 varray.java
字号:
}
if(type!=Variant.V_BOL)
{
}
else
array.put(new Integer(ldimnum).toString(),new Boolean(flag));
ldimnum=0;
lpopdim=0;
pushdim=0;
}
/**
* set a Variant element into array.
*
*/
public void set(VObject obj) throws HpException
{
set((Variant)obj);
}
public void set(Variant var) throws HpException
{
if(type==Variant.V_CTL)
throw new HpException(28,"Out of stack space");
array.put(new Integer(ldimnum).toString(),var);
ldimnum=0;
lpopdim=0;
pushdim=0;
}
public void set(VArray ary) throws HpException
{
//if(classType!=null && !(var instanceof HECore.stddata.VObject))
//throw new HpException( 91," Object variable or With block variable not set");
array.put(new Integer(ldimnum).toString(),ary);
ldimnum=0;
lpopdim=0;
pushdim=0;
}
public void set(Object obj) throws HpException
{
if(!obj.getClass().getName().equalsIgnoreCase(classType))
throw new HpException(13,"Type mismatch");
if(array.get(new Integer(ldimnum).toString())!=null)
throw new HpException(28,"Out of stack space");
array.put(new Integer(ldimnum).toString(),obj);
ldimnum=0;
lpopdim=0;
pushdim=0;
}
/*public Object set()
{
try{
Class cls=Class.forName(classType);
Object obj =cls.newInstance();
array.put(new Integer(rdimnum).toString(),obj);
rdimnum=0;
rpopdim=0;
pushdim=0;
return obj;
}catch(Exception e){System.out.println(e); return null;}
}*/
/**
* if this VArray type is V_INT invoke this Method return array element . <br>
* return type is short.
*/
public short getint() throws HpException
{
short i=0;
if(type!=Variant.V_INT && type!=Variant.V_OBJ)
throw new HpException(13,"Type mismatch");
else
if(classType!=null && array.get(new Integer(ldimnum).toString())==null)
throw new HpException(91,"Object variable or With block variable not set");
else
if(array.get(new Integer(ldimnum).toString())==null)
i=0;
else
if(classType!=null && array.get(new Integer(ldimnum).toString()) instanceof HECore.stddata.VObject)
{
Variant var =((VObject)array.get(new Integer(ldimnum).toString())).getDefaultProperty();
i=(short)var.dblValue();
}
else
i=(short)((Double)array.get(new Integer(rdimnum).toString())).doubleValue();
rdimnum=0;
rpopdim=0;
pushdim=0;
return i;
}
/**
* if this VArray type is V_LONG invoke this Method return array element . <br>
* return type is int.
*/
public int getlng() throws HpException
{
int i=0;
if(type!=Variant.V_LONG && type!=Variant.V_OBJ)
throw new HpException(13,"Type mismatch");
else
if(classType!=null && array.get(new Integer(ldimnum).toString())==null)
throw new HpException(91,"Object variable or With block variable not set");
else
if(classType!=null && array.get(new Integer(ldimnum).toString()) instanceof HECore.stddata.VObject)
{
Variant var =((VObject)array.get(new Integer(ldimnum).toString())).getDefaultProperty();
i=(int)var.dblValue();
}
else
if(array.get(new Integer(ldimnum).toString())==null)
i= 0;
else
i=((Double)array.get(new Integer(rdimnum).toString())).intValue();
rdimnum=0;
rpopdim=0;
pushdim=0;
return i;
}
/**
* if this VArray type is V_SINGLE invoke this Method return array element . <br>
* return type is float.
*/
public float getsgl() throws HpException
{
float i=0f;
if(type!=Variant.V_SINGLE && type!=Variant.V_OBJ)
throw new HpException(13,"Type mismatch");
else
if(classType!=null && array.get(new Integer(ldimnum).toString())==null)
throw new HpException(91,"Object variable or With block variable not set");
else
if(classType!=null && array.get(new Integer(ldimnum).toString()) instanceof HECore.stddata.VObject)
{
Variant var =((VObject)array.get(new Integer(ldimnum).toString())).getDefaultProperty();
i=(float)var.dblValue();
}
else
if(array.get(new Integer(rdimnum).toString())==null)
i= 0f;
else
i=((Double)array.get(new Integer(rdimnum).toString())).floatValue();
rdimnum=0;
rpopdim=0;
pushdim=0;
return i;
}
/**
* if this VArray type is V_DBL invoke this Method return array element . <br>
* return type is Double.
*/
public double getdbl() throws HpException
{
double i=0;
if(type!=Variant.V_DBL && type!=Variant.V_OBJ)
throw new HpException(13,"Type mismatch");
else
if(classType!=null && array.get(new Integer(ldimnum).toString())==null)
throw new HpException(91,"Object variable or With block variable not set");
else
if(classType!=null && array.get(new Integer(ldimnum).toString()) instanceof HECore.stddata.VObject)
{
Variant var =((VObject)array.get(new Integer(ldimnum).toString())).getDefaultProperty();
i=var.dblValue();
}
else
if(array.get(new Integer(rdimnum).toString())==null)
i=0.0;
else
i=((Double)array.get(new Integer(rdimnum).toString())).doubleValue();
rdimnum=0;
rpopdim=0;
pushdim=0;
return i;
}
/**
* if this VArray type is V_STR invoke this Method return array element . <br>
* return type is String.
*/
public String getstr() throws HpException
{
String str="";
if(type!=Variant.V_STR && type!=Variant.V_OBJ)
throw new HpException(13,"Type mismatch");
else
if(classType!=null && array.get(new Integer(ldimnum).toString())==null)
throw new HpException(91,"Object variable or With block variable not set");
else
if(classType!=null && array.get(new Integer(ldimnum).toString()) instanceof HECore.stddata.VObject)
{
Variant var =((VObject)array.get(new Integer(ldimnum).toString())).getDefaultProperty();
str=var.strValue();
}
else
if(array.get(new Integer(rdimnum).toString())==null)
str= null;
else
str=(String)array.get(new Integer(rdimnum).toString());
rdimnum=0;
rpopdim=0;
pushdim=0;
return str;
}
/**
* if this VArray type is V_BOOL invoke this Method return array element . <br>
* return type is boolean.
*/
public boolean getbool() throws HpException
{
boolean flag=false;
if(type!=Variant.V_BOL && type!=Variant.V_OBJ)
throw new HpException(13,"Type mismatch");
else
if(classType!=null && array.get(new Integer(ldimnum).toString())==null)
throw new HpException(91,"Object variable or With block variable not set");
else
if(classType!=null && array.get(new Integer(ldimnum).toString()) instanceof HECore.stddata.VObject)
{
Variant var =((VObject)array.get(new Integer(ldimnum).toString())).getDefaultProperty();
flag=var.boolValue();
}
else
if(array.get(new Integer(rdimnum).toString())==null)
flag= false;
else
flag=((Boolean)array.get(new Integer(rdimnum).toString())).booleanValue();
rdimnum=0;
rpopdim=0;
pushdim=0;
return flag;
}
/**
* if this VArray type is V_VAR invoke this Method return array element . <br>
* return type is Variant. if array element is VObject return this VObject's defalutProperty.
*/
public Variant getvar() throws HpException
{
Variant var=null;
short type = getType();
if(array.get(new Integer(rdimnum).toString())==null)
{
if(type==Variant.V_DATE)
{
throw new HpException(91,"Object variable or with block variable not set");
//return null;
}
else
if(type==Variant.V_CURR)
return new VCurr(0);
else
return null;
}
if(array.get(new Integer(rdimnum).toString()) instanceof java.lang.Short )
var=new VInt(((Short)array.get(new Integer(rdimnum).toString())).shortValue());
else
if(array.get(new Integer(rdimnum).toString()) instanceof java.lang.Integer )
var=new VLong(((Integer)array.get(new Integer(rdimnum).toString())).intValue());
else
if(array.get(new Integer(rdimnum).toString()) instanceof java.lang.Float )
var=new VSingle(((Float)array.get(new Integer(rdimnum).toString())).floatValue());
else
if(array.get(new Integer(rdimnum).toString()) instanceof java.lang.Double )
var=new VDouble(((Double)array.get(new Integer(rdimnum).toString())).doubleValue());
else
if(array.get(new Integer(rdimnum).toString()) instanceof java.lang.Boolean )
var=new VBoolean(((Boolean)array.get(new Integer(rdimnum).toString())).booleanValue());
else
if(array.get(new Integer(rdimnum).toString()) instanceof java.lang.String )
var=new VString((String)array.get(new Integer(rdimnum).toString()));
else
if(array.get(new Integer(rdimnum).toString()) instanceof HECore.stddata.VObject)
var =((VObject)array.get(new Integer(rdimnum).toString())).getDefaultProperty();
else
var=(Variant)array.get(new Integer(rdimnum).toString());
rdimnum=0;
rpopdim=0;
pushdim=0;
return var;
}
/**
* if this VArray type is V_OBJ invoke this Method return array element . <br>
* return type is VObject.
*/
public VArray getary() throws HpException
{
VArray obj=null;
if(array.get(new Integer(rdimnum).toString())==null)
{
throw new HpException(91,"Object variable or with block variable not set");
}
obj=(VArray)array.get(new Integer(rdimnum).toString());
rdimnum=0;
rpopdim=0;
pushdim=0;
return obj;
}
public VObject getvobj() throws HpException
{
VObject obj=null;
if(classtype==null)
throw new HpException(13,"Type Mismatch");
if(array.get(new Integer(rdimnum).toString())==null)
{
obj =new VObject();
array.put(new Integer(rdimnum).toString(),obj);
}
if(!(array.get(new Integer(rdimnum).toString()) instanceof HECore.stddata.VObject))
obj=new VObject(array.get(new Integer(rdimnum).toString()));
else
obj=(VObject)array.get(new Integer(rdimnum).toString());
rdimnum=0;
rpopdim=0;
pushdim=0;
return obj;
}
/**
* return array element . <br>
* return type is Object . <br>
*/
public Object getobj() throws HpException
{
Object obj=array.get(new Integer(rdimnum).toString());
try{
if(obj==null )
{
if(type==V_UDT)
{
obj= Class.forName(classType).newInstance();
array.put(new Integer(rdimnum).toString(),obj);
}
else
throw new HpException(91,"Object variable or with block variable not set");
}
else
{
if(obj instanceof HECore.stddata.VObject)
obj=((VObject)obj).objValue();
}
rdimnum=0;
rpopdim=0;
pushdim=0;
return obj;
}catch(Exception e){return null;}
}
/**
* get UDT Object. <br>
* return Type is Object. <br>
*/
public Object getudt()
{
Object var=null;
var=(Object)array.get(new Integer(rdimnum).toString());
rdimnum=0;
rpopdim=0;
pushdim=0;
if(var==null)
return udtobj;
else
return var;
}
/**
* get array Heighter .
* return java.uitl.Vector
*/
public Vector getHighdims()
{
return decHsuffix;
}
/**
* get array Lower .
* return java.uitl.Vector.
*/
public Vector getLowdims()
{
return decLsuffix;
}
/**
* get array dimension .
* return int value.
*/
public int getDims()
{
return dim;
}
/**
* get array Type .
* return int value.
*/
public short getType()
{
return (short)type;
}
/**
* return array length.
*
*/
public int getLength()
{
int length=1;
for(int i=0;i<dim;i++)
length=length*((Integer)num.elementAt(i)).intValue();
return length;
}
// Tangzhen.
public int getArrayLength() {
return param_num;
}
public Hashtable getArrayHash() {
return array;
}
/**
* Convert Array to Varinat varible
*/
public Variant toVariant() {
return new Variant(this);
}
/**
* Returns index of element control.
*/
public Object elementAt(int index) throws HpException
{
popr(index);
Object obj=array.get(new Integer(rdimnum).toString());
if(obj==null)
{
try{
Class cls=Class.forName(classType);
obj =cls.newInstance();
array.put(new Integer(rdimnum).toString(),obj);
}catch(Exception e){System.out.println(e); return null;}
}
else
{
if(obj instanceof HECore.stddata.VObject)
obj=((VObject)obj).objValue();
}
rdimnum=0;
rpopdim=0;
pushdim=0;
return obj;
}
/**
* Returns Wrapper of control
*/
public VObject controlAt(int index) throws HpException
{
popr(index);
VObject obj1=null;
Object obj=array.get(new Integer(rdimnum).toString());
if(obj==null)
{
try{
Class cls=Class.forName(classType);
obj =cls.newInstance();
obj1=new VObject(obj);
array.put(new Integer(rdimnum).toString(),obj1);
}catch(Exception e){System.out.println(e); return null;}
}
else
{
obj1=(VObject)obj;
}
rdimnum=0;
rpopdim=0;
pushdim=0;
return obj1;
}
public Object loadobj(int index) throws HpException
{
int ctlindex=0;
Enumeration key;
popr(index);
key=array.keys();
if(key.hasMoreElements())
ctlindex=((Integer)key.nextElement()).intValue();
Object obj=array.get(new Integer(rdimnum).toString());
if(obj==null)
{
while(key.hasMoreElements())
{
int i=((Integer)key.nextElement()).intValue();
if(i>ctlindex)
continue;
else
ctlindex=i;
}
obj=array.get(new Integer(ctlindex).toString());
/*try{
obj=obj.clone();
}catch(Exception e){System.out.println(e);}*/
array.put(new Integer(rdimnum).toString(),obj);
}
else
throw new HpException(360,"Object alread Loaded");
rdimnum=0;
rpopdim=0;
pushdim=0;
return obj;
}
public Object unloadobj(int index) throws HpException
{
popr(index);
Object obj=array.get(new Integer(rdimnum).toString());
if(obj==null)
throw new HpException(340,"Control array element '10' doesn't exist");
rdimnum=0;
rpopdim=0;
pushdim=0;
return obj;
}
public Object Item(int index) throws HpException
{/*just for ctrlarr().*/
popr(index);
Object obj=array.get(new Integer(rdimnum).toString());
return obj;
}
public boolean is_numric()
{
if(type==Variant.V_INT || type==Variant.V_BOL || type==Variant.V_SINGLE || type==Variant.V_LONG || type==Variant.V_DBL)
return true;
else
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -