hpfuncmisc.java

来自「一个简单的visio程序。」· Java 代码 · 共 2,139 行 · 第 1/4 页

JAVA
2,139
字号
			case Variant.V_STR:
			case Variant.V_FIX_STR:
			result = 8;
			break;

			//case Variant.V_FORM:
			//result = 9;
			//break;

			case Variant.V_OBJ:
			result = VARTYPE((VObject)variant);
			break;

			case Variant.V_ERR:
			result = 10;
			break;

			case Variant.V_BOL:
			result = 11;
			break;

			case Variant.V_BYTE:
			result = 17;
			break;

			case Variant.V_ARR:
			result = VARTYPE(variant.getArray());
			break;

			default:
				throw new HpException(13, "Type mismatch");
		}
		return result;
	}

   /**
	* @Function: IsEmpty(expression)
	* Returns a Boolean value indicating whether a variable has been
	* initialized.
	*/
	public static boolean ISEMPTY(short variant) throws HpException {
		return false;
	}

	public static boolean ISEMPTY(int variant) throws HpException {
		return false;
	}

	public static boolean ISEMPTY(HByte variant) throws HpException {
		return false;
	}

	public static boolean ISEMPTY(double variant) throws HpException {
		return false;
	}

	public static boolean ISEMPTY(float variant) throws HpException {
		return false;
	}

	public static boolean ISEMPTY(boolean variant) throws HpException {
		return false;
	}

	public static boolean ISEMPTY(String variant) throws HpException {
		return false;
	}

	public static boolean ISEMPTY(VObject variant) throws HpException {
		return false;
	}

	public static boolean ISEMPTY(HDate variant) throws HpException {
		return false;
	}

	public static boolean ISEMPTY(HCurr variant) throws HpException {
		return false;
	}

	public static boolean ISEMPTY(VNull variant) throws HpException {
		return false;
	}

	public static boolean ISEMPTY(fixedString variant) throws HpException {
		return false;
	}

	public static boolean ISEMPTY(Variant variant) throws HpException {
		if (variant.getType() == Variant.V_EMPTY)
			return true;
		return false;
	}

   /**
	* @Function: IsNull(variant)
	* Returns a Boolean value that indicates whether an expression
	* contains no valid data (Null).
	*/
	public static boolean ISNULL(int variant) throws HpException {
		return false;
	}

	public static boolean ISNULL(short variant) throws HpException {
		return false;
	}

	public static boolean ISNULL(HByte variant) throws HpException {
		return false;
	}

	public static boolean ISNULL(double variant) throws HpException {
		return false;
	}

	public static boolean ISNULL(float variant) throws HpException {
		return false;
	}

	public static boolean ISNULL(boolean variant) throws HpException {
		return false;
	}

	public static boolean ISNULL(String variant) throws HpException {
		return false;
	}

	public static boolean ISNULL(VObject variant) throws HpException {
		return false;
	}

	public static boolean ISNULL(HDate variant) throws HpException {
		return false;
	}

	public static boolean ISNULL(HCurr variant) throws HpException {
		return false;
	}

	public static boolean ISNULL(VArray variant) throws HpException {
		return false;
	}

	public static boolean ISNULL(fixedString variant) throws HpException {
		return false;
	}

	public static boolean ISNULL(VNull variant) throws HpException {
		return true;
	}

	public static boolean ISNULL(Variant variant) throws HpException {
		if (variant.getType() == Variant.V_NULL)
			return true;
		return false;
	}

   /**
	* @Function: IsNumeric(variant)
	* Returns a Boolean value indicating whether an expression can
	* be evaluated as a number.
	*/
	public static boolean ISNUMERIC(int variant) throws HpException {
		return true;
	}

	public static boolean ISNUMERIC(short variant) throws HpException {
		return true;
	}

	public static boolean ISNUMERIC(boolean variant) throws HpException {
		return true;
	}

	public static boolean ISNUMERIC(HByte variant) throws HpException {
		return true;
	}

	public static boolean ISNUMERIC(double variant) throws HpException {
		return true;
	}

	public static boolean ISNUMERIC(float variant) throws HpException {
		return true;
	}

	public static boolean ISNUMERIC(String variant) throws HpException {
		return isNumOfStr(variant);
	}

	public static boolean ISNUMERIC(VObject variant) throws HpException {
		Object obj = variant.objValue(); //Wrapper  obj = variant.getObject();
		if (obj == null)
			return false;
		else
		{
			String s = variant.getClassType();
			if (s.indexOf("nothing") == -1)
				return true;
			else
				return false;
		}
	}

	public static boolean ISNUMERIC(HDate variant) throws HpException {
		return false;
	}

	public static boolean ISNUMERIC(HCurr variant) throws HpException {
		return true;
	}

	public static boolean ISNUMERIC(VNull variant) throws HpException {
		return false;
	}

	public static boolean ISNUMERIC(fixedString variant) throws HpException {
		return isNumOfStr(variant.strValue());
	}

	public static boolean ISNUMERIC(Variant variant) throws HpException
	{
		switch (variant.getType()) {
			case Variant.V_OBJ:
				return ISNUMERIC((VObject)variant);
			case Variant.V_INT:
			case Variant.V_CURR:
			case Variant.V_LONG:
			case Variant.V_DBL:
			case Variant.V_SINGLE:
			case Variant.V_BYTE:
			case Variant.V_BOL:
			case Variant.V_EMPTY:
				return true;
			case Variant.V_NULL:
			case Variant.V_DATE:
				return false;
			case Variant.V_FIX_STR:
				//int i = variant.getFixedLength();
				//String str = Variant.fixed_string(i,variant.strValue() );
				String str = new String(((VString)variant).fixedString());
				return isNumOfStr(str);

			case Variant.V_STR:
				return isNumOfStr(variant.strValue());

			default:
				return false;
		}
		//return false;
	}

   /**
	* Judge a String whether a Number.
	*/
	public static boolean isNumOfStr(String str) throws HpException {
		if (getshort(str) == 0)
			return false;
		return true;
	}

	private static short getshort(String s) throws HpException
	{
		short    result = 0;

		if (s == null || s == "")
			return 0;

		s = s.trim();

		Double  isdb;
		double  db;
		try {
			isdb = new Double(s);
			db = isdb.doubleValue();
			if( s.lastIndexOf("d") != -1 || s.lastIndexOf("D") != -1 ||
				s.lastIndexOf("f") != -1 || s.lastIndexOf("F") != -1)
				result = 0;
			else
				result = -1;
		} catch( Exception err) {
			if (s.length() < 2)
				return 0;

			if( s.charAt(0)=='$' )
				s = s.substring(1);
			else if( s.charAt(s.length()-1)=='$' )
				s = s.substring(0, s.length()-1 );

			if( s.length()>2 && s.charAt(0)=='(' && s.charAt(s.length()-1)==')' )
				s = s.substring(1, s.length()-1 );

			if( s.length()>1 && (s.charAt(s.length()-1)=='-' || s.charAt(s.length()-1)=='+') )
				s = s.substring(0, s.length()-1 );

			try {
				isdb = new Double(s);
				db = isdb.doubleValue();
				result = -1;
			} catch( Exception err1) {
				if( s.length()==2 )
				{
        			if( s.charAt(0)=='&')
            			s = s.substring(1);
        			try {
        				db = (double)Long.parseLong(s, 8);
        				result = -1;
        			} catch( Exception err2 ){;}
				}
				else if( (s.charAt(0)=='-' || s.charAt(0)=='+') &&
        				s.charAt(1)=='$'    )
				{
        			if( s.charAt(0)=='-' )
        				s = '-' + s.substring(2);
        			else
        				s = s.substring(2);

        			try{
            			isdb = new Double(s);
            			db = isdb.doubleValue();
            			result = -1;
        			}catch( Exception err3){;}
				}
				else if( (s.charAt( s.length()-1 )=='-' || s.charAt( s.length()-1 )=='+') &&
        			  s.charAt(s.length()-2 )=='$' )
				{
        			if( s.charAt(s.length()-1)=='-' )
        				s = '-' + s.substring(0,s.length()-2 );
        			else
        				s = s.substring(0,s.length()-2 );

        			try {
            			isdb = new Double(s);
            			db = isdb.doubleValue();
            			result = -1;
					} catch(Exception err4) {;}
				}
				else if( s.charAt(0)=='&' && (s.charAt(1)=='h' || s.charAt(1)=='H' ) )
				{
        			try {
            			s = s.substring(2);
            			db = (double)Long.parseLong(s, 16);
            			result = -1;
					} catch(Exception err5) { ;}
				}
				else if( s.charAt(0)=='&' && (s.charAt(1)=='o' || s.charAt(1)=='O' ) )
				{
        			try {
            			s = s.substring(2);
            			db = (double)Long.parseLong(s, 8);
            			result = -1;
					} catch (Exception err6) { ;}
				}
				else
				{
        			int le = s.length(), found = 0;
        			boolean  dot = false, comma = false, char_e = false;
        			while (le != 0)
        			{
    					if( s.charAt(found)=='.' && (dot==true || char_e==true))   break;
    					if( s.charAt(found)==',' && (found==0 || char_e==true ))   break;
    					if( s.charAt(found)=='e' && (char_e==true || found==0))   break;


    					if ( s.charAt(found)=='.')
    					{
    						dot = true;
    					}
    					else if( s.charAt(found)==',')
    					{
    						comma = true;
    					}
    					else if( s.charAt(found)=='e' )
    					{
    						char_e = true;
    					}
    					else if(s.charAt(found)<'0' || s.charAt(found)>'9' )
    						break;

						found++;
	    				le--;
        			}
        			if( found==s.length() )
        				result = -1;
        			else
       					result = 0;
				}
			}
		}
		return  result;
	}

   /**
	* @Function: IsError(expression)
	* Returns a Boolean value indicating whether an expression is an error value.
	*/
	public static boolean ISERROR(short variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(int variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(HByte variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(double variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(float variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(boolean variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(String variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(fixedString variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(VObject variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(VNull variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(HDate variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(HCurr variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(VArray variant) throws HpException {
		return false;
	}

	public static boolean ISERROR(Variant variant) throws HpException {
		if (variant.getType() == Variant.V_ERR)
			return true;
		return false;
	}

   /**
	* @Function: IsMissing(argname)
	* Returns a Boolean value indicating whether an optional argument
	* has been passed to a procedure.
	*/
	public static boolean ISMISSING(short variant) throws HpException {
		return false;
	}

	public static boolean ISMISSING(int variant) throws HpException {
		return false;
	}

	public static boolean ISMISSING(HByte variant) throws HpException {
		return false;
	}

	public static boolean ISMISSING(double variant) throws HpException {
		return false;
	}

	public static boolean ISMISSING(float variant) throws HpException {
		return false;
	}

	public static boolean ISMISSING(boolean variant) throws HpException {
		return false;
	}

	public static boolean ISMISSING(String variant) throws HpException {
		return false;
	}

	public static boolean ISMISSING(fixedString variant) throws HpException {
		return false;
	}

	public static boolean ISMISSING(VObject variant) throws HpException {
		return false;
	}

	public static boolean ISMISSING(VNull variant) throws HpException {
		return false;
	}

	public static boolean ISMISSING(HDate variant) throws HpException {
		return false;
	}

	public static boolean ISMISSING(HCurr variant) throws HpException {
		return false;
	}

	public static boolean ISMISSING(VArray variant) throws HpException {
		return false;
	}

	// Hope fixed.
	public static boolean ISMISSING(Variant variant) throws HpException	{
		if ( variant == null )
			return true;
		return false;
	}

   /**
	* @Function: isArray(varname)
	* Returns a Boolean value indicating whether a variable is an array.
	*/
	public static boolean ISARRAY(short variant) throws HpException {
		return false;
	}

	public static boolean ISARRAY(int variant) throws HpException {
		return false;
	}

	public static boolean ISARRAY(HByte variant) throws HpException {
		return false;
	}

	public static boolean ISARRAY(double variant) throws HpException {

⌨️ 快捷键说明

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