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

📄 convert.java

📁 一个简单的visio程序。
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            UdtDatetime  udt=new UdtDatetime();
            int[] standdt = udt.DtFormat(s);
            if( standdt==null)
                throw new HpException(13,"Type mismatch");
            dbl = udt.StrToDbl(standdt);
        }
        return new HDate(dbl);
    }
							/**
							*Convert double to date
							*/
							public static HDate dbl2date(double val){
							    return new HDate(val);
								}

							/**
         *  Convert boolean to date
        **/
  public static HDate bool2date(boolean val){
        double date =0.0;
        if(val)
          date = -1;
        else
          date = 0.0;
        return new HDate(date);
        }

       /**
       *Convert integer to long
       **/

       public static int int2lng(short val)
       {
           return val;
        }

        public static double int2dbl(short val)
        {
             return val;
        }

        public static double lng2dbl(int val)
								{
								    return val;

								}


								public static double sgl2dbl(float val)
								{
								    return val;
								}

								public static float int2sgl(short val)
        {
             return val;
        }
        /**
         *  Convert int to date
        **/
        public static HDate int2date(short val){
           return new HDate((double)val);
        }
        /**
         *  Convert long to date
        **/
        public static HDate lng2date(int val){
           return new HDate((double)val);
        }
        /**
         *  Convert single to date
        **/
        public static HDate sgl2date(float val){
           return new HDate((double)val);
        }
        /**
         *  Convert currency to date
        **/
        public static HDate curr2date(HCurr val){
            return new HDate(val.dblValue());
        }

						
        

      /**
        *Convert date to boolean
        */
        public static boolean date2bool(HDate date){
           if(date.dblValue() !=0.0)
              return true;
           else
              return false;
        }

      /**
        * Convert date to integer
        */
        public static short date2int(HDate date){
            return date.intValue();
        }

      /**
        *  Convert date to long
        */
        public static int date2lng(HDate date){
     return date.lngValue();
        }


      /**
        * Convert date to string
        */
        public static String date2str(HDate date)throws HpException{
        return date.strValue();
        }

       /**
        * Convert date to single
        */
        public static float date2sgl(HDate date){
           return date.sglValue();
        }

        /**
        * Convert date to single
        */
        public static double date2dbl(HDate date){
								
								   return  date.dblValue();
								}
								/**
        *Convert date to Currency
        */
        public static HCurr date2curr(HDate date){
          double curr=dbl2currval(date.dblValue());
										return new HCurr(curr);
        }
        /**
        *Convert byte to boolean
        */
        public static boolean byte2bool(short s){
            if(s !=0)
               return true;
            return false;
        }
        /**
        *Convert int to boolean
        */
        public static boolean int2bool(short s){
            if(s !=0)
               return true;
            return false;
        }
        /**
        *Convert long to boolean
        */
        public static boolean lng2bool(int i){
            if(i !=0)
               return true;
            return false;
        }
        /**
        *Convert single to boolean
        */
        public static boolean sgl2bool(float f){
            if(f !=0.0)
               return true;
            return false;
        }
        
								/**
								*Convert single to integer
								**/
        public static short sgl2int(float f){
								     return (new Float(f)).shortValue();
								}
								/**
        *Convert double to boolean
        */
        public static boolean dbl2bool(double db){
            if(db !=0.0)
               return true;
            return false;
        }

     	/*********
	     * convert to fixed length string
		*********/

    public static fixedString  byte2fixedstr(short i,int len)
   {
         return new fixedString(new Short(i).toString(),len);
   }
   /**
      *  Returns  a fixed length string  representation of a short
     **/

   public static fixedString  int2fixedstr(short i,int len)
   {
        return new fixedString(new Short(i).toString(),len);
   }
  /**
      *  Returns a fixed length string representation of a int
     **/

   public static fixedString  lng2fixedstr(int i,int len)
   {
      return new fixedString(new Integer(i).toString(),len);
   }
   /**
    *  Returns a fixed string representation of a float
   **/


   public static fixedString  sgl2fixedstr(float i,int len)
   {
       return new fixedString(new Float(i).toString(),len);
   }
   /**
      *  Returns a fixed length string  representation of a double
     **/

   public static fixedString  dbl2fixedstr(double i,int len)
   {
       return new fixedString(new Double(i).toString(),len);
   }

   public static fixedString date2fixedstr(HDate date,int len)throws HpException{
        return new fixedString((new HDate(date.dblValue())).strValue(),len);
		}
   public static fixedString curr2fixedstr(HCurr curr,int len){
           return new fixedString((new HCurr(curr.dblValue())).toString(),len);
           }

   public static int tointValue(Object ob) throws HpException
  {
    if(ob instanceof java.lang.Integer)
        return ((Integer)ob).intValue();
    else
     if(ob instanceof java.lang.Float)
       return ((Float)ob).intValue();
   else
     if(ob instanceof java.lang.Double)
       return ((Double)ob).intValue();
   else
     if(ob instanceof java.lang.String)
       return (int)(new VString((String)ob).dblValue());
   else
    if(ob instanceof java.lang.Boolean)
   {
     if(((Boolean)ob).booleanValue())
       return -1;
     else
        return 0;
   }
  else
    if(ob instanceof HECore.stddata.VObject)
        return tointValue(((VObject)ob).getDefaultProperty());
   else
     if(ob instanceof HECore.stddata.Variant)
       return (int)((Variant)ob).dblValue();
   else
    return 0;
  }

  public static double todoubleValue(Object ob) throws HpException 
  {
    if(ob instanceof java.lang.Integer)
        return (double)((Integer)ob).intValue();
    else
     if(ob instanceof java.lang.Float)
       return ((Float)ob).doubleValue();
    else
     if(ob instanceof java.lang.Double)
       return ((Double)ob).doubleValue();
    else
     if(ob instanceof java.lang.String)
       return (new VString((String)ob).dblValue());
    else
     if(ob instanceof java.lang.Boolean)
    {
     if(((Boolean)ob).booleanValue())
       return -1.0;
     else
        return 0.0;
    }
    else
     if(ob instanceof HECore.stddata.VObject)
        return todoubleValue(((VObject)ob).getDefaultProperty());
    else
     if(ob instanceof HECore.stddata.Variant)
       return ((Variant)ob).dblValue();
    else
     return 0.0;
  }


  public static boolean toboolValue(Object ob) throws HpException
  {
    if(ob instanceof java.lang.Integer)
    {
       if(((Integer)ob).intValue()!=0)
        return true;
       else
        return false;
    }
   else
   if(ob instanceof java.lang.Float)
   {
      if(((Float)ob).intValue()!=0)
        return true;
      else
        return false;
   }
   else
    if(ob instanceof java.lang.Double)
   {
      if(((Double)ob).intValue()!=0)
         return true;
      else
        return false;

   }
   else
    if(ob instanceof java.lang.String)
   {
      if((int)(new VString((String)ob).dblValue())!=0)
         return true;
      else
        return false;
   }
   else
    if(ob instanceof java.lang.Boolean)
   {
      return ((Boolean)ob).booleanValue();
   }
  else
   if(ob instanceof HECore.stddata.VObject)
        return toboolValue(((VObject)ob).getDefaultProperty());
   else
    if(ob instanceof HECore.stddata.Variant)
   {
     if((int)((Variant)ob).dblValue()!=0)
        return true;
     else
       return false;
   }
 else
     return false;

  }
  
  public static String fix2str(fixedString fix) {
    return fix.strValue();
  
   }
  
  public static short fix2int(fixedString fix){
       return fix.intValue();
					}

  public static int fix2lng(fixedString fix)
     {
        return fix.lngValue();
     }

  public static double fix2dbl(fixedString fix)
     {
        return fix.dblValue();
     }

  public static float fix2sgl(fixedString fix)
     {
        return fix.sglValue();
     }
  
		public static Variant fix2var(fixedString fix)
     {
        return Variant.newVariant(fix);
     } 

  public static HDate fix2date(fixedString fix)
		   {
        return new HDate(fix.dblValue());
     }  
							
  public static HCurr fix2curr(fixedString fix)
	{
       return new HCurr(fix.dblValue());
     }  
  
  
  
  public static HByte str2byte(String s) {
    return new HByte((new Short(s)).shortValue());
  } 
  public static HByte bool2byte(boolean b) {
     if(b)
	  return new HByte((short)255);
     return new HByte((short)0);
    
  } 
  public static HByte var2byte(Variant var) {
	  try{
	  return new HByte(var.byteValue());
	  }catch(Exception e){System.out.println(e);return null;}
     }
  
  public static HByte fix2byte(fixedString fs) {
     
	  return new HByte(fs.byteValue());
     } 
	  
  
  public static String byte2str(HByte hb) {
    return hb.strValue();
  
   }


  public static HByte int2byte(short i) {
    return new HByte((short)i);
  } 
   

   public static short byte2int(HByte hb){
       return hb.intValue();
					}

  public static int byte2lng(HByte hb)
     {
        return hb.lngValue();
     }
  
		
		public static HByte lng2byte(int i){
     return new HByte((short)i);
  }
  
  public static double byte2dbl(HByte hb)
     {
        return hb.dblValue();
     }

  public static HByte dbl2byte(double d){
     return new HByte((short)d);
  }

  public static float byte2sgl(HByte hb)
     {
        return hb.sglValue();
     }
  public static HByte sgl2byte(float f){
     return new HByte((short)f);
  }
		

  public static HDate byte2date(HByte hb)
		   {
        return new HDate(hb.dblValue());
     }  

  public static HByte date2byte(HDate hd)
	{
        return new HByte(hd.byteValue());
     }  
							
  public static HCurr byte2curr(HByte hb)
	{
       return new HCurr(hb.dblValue());
     }   
  
  public static HByte curr2byte(HCurr hc)
	{
       return new HByte(hc.byteValue());
     }  
  public static Variant byte2var(HByte hb){

     return new Variant();

  }
  
		public static boolean byte2bool(HByte hb){

     if(hb.byteValue()==0)
	   return false;
     
	 return true; 

  }

  


   

 }

⌨️ 快捷键说明

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