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

📄 safearray.java

📁 java与windows的com桥,可以用来操作所有的com程序如word或者excel等
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

	/**
	 * @param dim
	 *            the dimension we are checking in a multidimensional array
	 * @return The upper bounds of the array?
	 */
	public native int getUBound(int dim);

	/**
	 * variant access
	 * 
	 * @param sa_idx
	 * @return Variant held in location in the array?
	 */
	public native Variant getVariant(int sa_idx);

	/**
	 * get Variant value from N-dimensional array
	 * 
	 * @param indices -
	 *            length must equal Dimension of SafeArray
	 * @return the value at the specified location
	 */
	public native Variant getVariant(int indices[]);

	/**
	 * variant access
	 * 
	 * @param sa_idx1
	 * @param sa_idx2
	 * @return Variant held in a location in the array?
	 */
	public native Variant getVariant(int sa_idx1, int sa_idx2);

	/**
	 * variant access
	 * 
	 * @param sa_idx
	 * @param nelems
	 * @param ja
	 * @param ja_start
	 */
	public native void getVariants(int sa_idx, int nelems, Variant ja[],
			int ja_start);

	/**
	 * @return the Variant type
	 */
	public native int getvt();

	protected native void init(int vt, int lbounds[], int celems[]);

	/**
	 * Does anyone want to document this?
	 * 
	 * @param sa
	 */
	public native void reinit(SafeArray sa);

	/**
	 * Does anyone want to document this?
	 * 
	 * @param vt
	 *            the variant type?
	 */
	public native void reinterpretType(int vt);

	/**
	 * {@inheritDoc}
	 */
	public void safeRelease() {
		super.safeRelease();
		if (m_pV != 0) {
			destroy();
			m_pV = 0;
		} else {
			// looks like a double release
			if (isDebugEnabled()) {
				debug(this.getClass().getName() + ":" + this.hashCode()
						+ " double release");
			}
		}
	}

	/**
	 * boolean access
	 * 
	 * @param sa_idx
	 * @param c
	 */
	public native void setBoolean(int sa_idx, boolean c);

	/**
	 * set boolean value in N-dimensional array
	 * 
	 * @param indices -
	 *            length must equal Dimension of SafeArray
	 * @param c
	 */
	public native void setBoolean(int indices[], boolean c);

	/**
	 * boolean access
	 * 
	 * @param sa_idx1
	 * @param sa_idx2
	 * @param c
	 */
	public native void setBoolean(int sa_idx1, int sa_idx2, boolean c);

	/**
	 * boolean access
	 * 
	 * @param sa_idx
	 * @param nelems
	 * @param ja
	 * @param ja_start
	 */
	public native void setBooleans(int sa_idx, int nelems, boolean ja[],
			int ja_start);

	/**
	 * byte access
	 * 
	 * @param sa_idx
	 * @param c
	 */
	public native void setByte(int sa_idx, byte c);

	/**
	 * set byte value in N-dimensional array
	 * 
	 * @param indices -
	 *            length must equal Dimension of SafeArray
	 * @param c
	 */
	public native void setByte(int indices[], byte c);

	/**
	 * byte access
	 * 
	 * @param sa_idx1
	 * @param sa_idx2
	 * @param c
	 */
	public native void setByte(int sa_idx1, int sa_idx2, byte c);

	/**
	 * fills array with passed in bytes
	 * 
	 * @param sa_idx
	 * @param nelems
	 * @param ja
	 * @param ja_start
	 */
	public native void setBytes(int sa_idx, int nelems, byte ja[], int ja_start);

	/**
	 * char access
	 * 
	 * @param sa_idx
	 * @param c
	 */
	public native void setChar(int sa_idx, char c);

	/**
	 * set char value in N-dimensional array
	 * 
	 * @param indices -
	 *            length must equal Dimension of SafeArray
	 * @param c
	 */
	public native void setChar(int indices[], char c);

	/**
	 * char access
	 * 
	 * @param sa_idx1
	 * @param sa_idx2
	 * @param c
	 */
	public native void setChar(int sa_idx1, int sa_idx2, char c);

	/**
	 * char access
	 * 
	 * @param sa_idx
	 * @param nelems
	 * @param ja
	 * @param ja_start
	 */
	public native void setChars(int sa_idx, int nelems, char ja[], int ja_start);

	/**
	 * double access
	 * 
	 * @param sa_idx
	 * @param c
	 */
	public native void setDouble(int sa_idx, double c);

	/**
	 * set double value in N-dimensional array
	 * 
	 * @param indices -
	 *            length must equal Dimension of SafeArray
	 * @param c
	 */
	public native void setDouble(int indices[], double c);

	/**
	 * double access
	 * 
	 * @param sa_idx1
	 * @param sa_idx2
	 * @param c
	 */
	public native void setDouble(int sa_idx1, int sa_idx2, double c);

	/**
	 * double access
	 * 
	 * @param sa_idx
	 * @param nelems
	 * @param ja
	 * @param ja_start
	 */
	public native void setDoubles(int sa_idx, int nelems, double ja[],
			int ja_start);

	/**
	 * float access
	 * 
	 * @param sa_idx
	 * @param c
	 */
	public native void setFloat(int sa_idx, float c);

	/**
	 * set float value in N-dimensional array
	 * 
	 * @param indices -
	 *            length must equal Dimension of SafeArray
	 * @param c
	 */
	public native void setFloat(int indices[], float c);

	/**
	 * float access
	 * 
	 * @param sa_idx1
	 * @param sa_idx2
	 * @param c
	 */
	public native void setFloat(int sa_idx1, int sa_idx2, float c);

	/**
	 * float access
	 * 
	 * @param sa_idx
	 * @param nelems
	 * @param ja
	 * @param ja_start
	 */
	public native void setFloats(int sa_idx, int nelems, float ja[],
			int ja_start);

	/**
	 * sets the int value of an element in a single dimensional array
	 * 
	 * @param sa_idx
	 *            index into the array
	 * @param c
	 *            the value to be set
	 */
	public native void setInt(int sa_idx, int c);

	/**
	 * set int value in N-dimensional array
	 * 
	 * @param indices -
	 *            length must equal Dimension of SafeArray
	 * @param c
	 */
	public native void setInt(int indices[], int c);

	/**
	 * sets the int value of a 2 dimensional array
	 * 
	 * @param sa_idx1
	 *            index on the first dimension
	 * @param sa_idx2
	 *            index on the second dimension
	 * @param c
	 *            the value to be set
	 */
	public native void setInt(int sa_idx1, int sa_idx2, int c);

	/**
	 * sets a group of ints into a single dimensional array
	 * 
	 * @param sa_idx
	 *            the index of the start of the array to put into
	 * @param nelems
	 *            number of elements to be copied
	 * @param ja
	 *            the new int values to be put into the array
	 * @param ja_start
	 *            the start index in the array that we are copying into
	 *            SafeArray
	 */
	public native void setInts(int sa_idx, int nelems, int ja[], int ja_start);

	/**
	 * sets the long value of an element in a single dimensional array
	 * 
	 * @param sa_idx
	 *            index into the array
	 * @param c
	 *            the value to be set
	 */
	public native void setLong(int sa_idx, long c);

	/**
	 * set long value in N-dimensional array
	 * 
	 * @param indices -
	 *            length must equal Dimension of SafeArray
	 * @param c
	 */
	public native void setLong(int indices[], long c);

	/**
	 * sets the long value of a 2 dimensional array
	 * 
	 * @param sa_idx1
	 *            index on the first dimension
	 * @param sa_idx2
	 *            index on the second dimension
	 * @param c
	 *            the value to be set
	 */
	public native void setLong(int sa_idx1, int sa_idx2, long c);

	/**
	 * sets a group of longs into a single dimensional array
	 * 
	 * @param sa_idx
	 *            the index of the start of the array to put into
	 * @param nelems
	 *            number of elements to be copied
	 * @param ja
	 *            the new long values to be put into the array
	 * @param ja_start
	 *            the start index in the array that we are copying into
	 *            SafeArray
	 */
	public native void setLongs(int sa_idx, int nelems, long ja[], int ja_start);

	/**
	 * short access
	 * 
	 * @param sa_idx1
	 * @param sa_idx2
	 * @param c
	 */
	public native void setShort(int sa_idx1, int sa_idx2, short c);

	/**
	 * short access
	 * 
	 * @param sa_idx
	 * @param c
	 */
	public native void setShort(int sa_idx, short c);

	/**
	 * set short value in N-dimensional array
	 * 
	 * @param indices -
	 *            length must equal Dimension of SafeArray
	 * @param c
	 */
	public native void setShort(int indices[], short c);

	/**
	 * short access
	 * 
	 * @param sa_idx
	 * @param nelems
	 * @param ja
	 * @param ja_start
	 */
	public native void setShorts(int sa_idx, int nelems, short ja[],
			int ja_start);

	/**
	 * puts a string into an element in a two dimensional array.
	 * 
	 * @param sa_idx1
	 * @param sa_idx2
	 * @param c
	 */
	public native void setString(int sa_idx1, int sa_idx2, String c);

	/*
	 * ================================================================ The
	 * beginning of N-dimensional array support
	 * ================================================================
	 */

	/**
	 * puts a string into an element in a single dimensional safe array
	 * 
	 * @param sa_idx
	 * @param c
	 */
	public native void setString(int sa_idx, String c);

	/**
	 * set Stringvalue in N-dimensional array
	 * 
	 * @param indices -
	 *            length must equal Dimension of SafeArray
	 * @param c
	 */
	public native void setString(int indices[], String c);

	/**
	 * string access
	 * 
	 * @param sa_idx
	 * @param nelems
	 * @param ja
	 * @param ja_start
	 */
	public native void setStrings(int sa_idx, int nelems, String ja[],
			int ja_start);

	/**
	 * variant access
	 * 
	 * @param sa_idx1
	 * @param sa_idx2
	 * @param c
	 */
	public native void setVariant(int sa_idx1, int sa_idx2, Variant c);

	/**
	 * variant access
	 * 
	 * @param sa_idx
	 * @param c
	 */
	public native void setVariant(int sa_idx, Variant c);

	/**
	 * set Variant value in N-dimensional array
	 * 
	 * @param indices -
	 *            length must equal Dimension of SafeArray
	 * @param v
	 */
	public native void setVariant(int indices[], Variant v);

	/**
	 * variant access
	 * 
	 * @param sa_idx
	 * @param nelems
	 * @param ja
	 * @param ja_start
	 */
	public native void setVariants(int sa_idx, int nelems, Variant ja[],
			int ja_start);

	/**
	 * Retrieves the data from the array cast to a Java data type
	 * 
	 * @return boolean[] array of booleans contained in this collection
	 */
	public native boolean[] toBooleanArray();

	/**
	 * Retrieves the data from the array cast to a Java data type
	 * 
	 * @return byte[] byte array contained in this collection
	 */
	public native byte[] toByteArray();

	/**
	 * Retrieves the data from the array cast to a Java data type
	 * 
	 * @return char[] character array contained in this collection
	 */
	public native char[] toCharArray();

	/**
	 * Retrieves the data from the array cast to a Java data type
	 * 
	 * @return double[] double array contained in this collection
	 */
	public native double[] toDoubleArray();

	/**
	 * Retrieves the data from the array cast to a Java data type
	 * 
	 * @return float[] array of float contained in this collection
	 */
	public native float[] toFloatArray();

	/**
	 * Retrieves the data from the array cast to a Java data type
	 * 
	 * @return int[] int array contained in this collection
	 */
	public native int[] toIntArray();

	/**
	 * Retrieves the data from the array cast to a Java data type
	 * 
	 * @return long[] long array contained in this collection
	 */
	public native long[] toLongArray();

	/**
	 * Retrieves the data from the array cast to a Java data type
	 * 
	 * @return short[] short array contained in this collection
	 */
	public native short[] toShortArray();

	/**
	 * Standard toString() Warning, this creates new Variant objects!
	 * 
	 * @return String contents of variant
	 */
	public String toString() {
		String s = "";
		int ndim = getNumDim();
		if (ndim == 1) {
			int ldim = getLBound();
			int udim = getUBound();
			for (int i = ldim; i <= udim; i++) {
				Variant v = getVariant(i);

				if (((v.getvt() & Variant.VariantTypeMask) | Variant.VariantArray) == v
						.getvt()) {
					return s + "[" + v.toSafeArray().toString() + "]";
				} else {
					s += " " + v.toString();
				}
			}
		} else if (ndim == 2) {
			int ldim1 = getLBound(1);
			int udim1 = getUBound(1);

			int ldim2 = getLBound(2);
			int udim2 = getUBound(2);

			for (int i = ldim1; i <= udim1; i++) {
				for (int j = ldim2; j <= udim2; j++) {
					Variant v = getVariant(i, j);
					s += " " + v.toString();
				}
				s += "\n";
			}
		}
		return s;
	}

	/**
	 * Retrieves the data from the array cast to a Java data type
	 * 
	 * @return String[] String array contained in this collection
	 */
	public native String[] toStringArray();

	/**
	 * Retrieves the data from the array cast to a Java data type
	 * 
	 * @return Variant[] array of variants contained in this collection
	 */
	public native Variant[] toVariantArray();

}

⌨️ 快捷键说明

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