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

📄 ddmreader.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
			dssIsContinued = true;		}		else 		{			dssIsContinued = false;		}		if (dssLength < 6)			agent.throwSyntaxrm(CodePoint.SYNERRCD_DSS_LESS_THAN_6,							   DRDAProtocolException.NO_CODPNT_ARG);		// If the GDS id is not valid, throw exception		if ((buffer[pos++] & 0xff) != DssConstants.DSS_ID)			agent.throwSyntaxrm(CodePoint.SYNERRCD_CBYTE_NOT_D0,							   DRDAProtocolException.NO_CODPNT_ARG);		int gdsFormatter = buffer[pos++] & 0xff;				// Determine if the current DSS is chained with the		// next DSS, with the same or different request ID.		if ((gdsFormatter & DssConstants.DSSCHAIN) == DssConstants.DSSCHAIN) 		{	// on indicates structure chained to next structure			if ((gdsFormatter & DssConstants.DSSCHAIN_SAME_ID) 					== DssConstants.DSSCHAIN_SAME_ID) 			{				dssIsChainedWithSameID = true;				dssIsChainedWithDiffID = false;			}			else 			{				dssIsChainedWithSameID = false;				dssIsChainedWithDiffID = true;			}		}		else 		{			dssIsChainedWithSameID = false;			dssIsChainedWithDiffID = false;		}		dssCorrelationID =			((buffer[pos++] & 0xff) << 8) +			((buffer[pos++] & 0xff) << 0);		if (SanityManager.DEBUG)								trace("dssLength = " + dssLength + " correlationID = " + dssCorrelationID);		dssLength -= 6;	}	/**	 * Read the DDM Length and CodePoint	 *	 * @return - returns codepoint	 *	 * @exception DRDProtocolException	 */	protected int readLengthAndCodePoint() throws DRDAProtocolException	{		ensureBLayerDataInBuffer (4, NO_ADJUST_LENGTHS);		ddmScalarLen =			((buffer[pos++] & 0xff) << 8) +			((buffer[pos++] & 0xff) << 0);		int codePoint =			((buffer[pos++] & 0xff) << 8) +			((buffer[pos++] & 0xff) << 0);		if (SanityManager.DEBUG)			trace("length = "+ ddmScalarLen + " codepoint = " + java.lang.Integer.toHexString(codePoint));		// SYNERRCD 0x0D - Object code point index not supported.		// the object codepoint index will not be checked here since		// the parse methods will catch any incorrect/unexpected codepoint values		// and report them as unsupported objects or parameters.		// Check if this DDM has extended length field		if ((ddmScalarLen & DssConstants.CONTINUATION_BIT) == DssConstants.CONTINUATION_BIT) 		{			int numberOfExtendedLenBytes = ((int)ddmScalarLen - 					DssConstants.CONTINUATION_BIT) - 4;			int adjustSize = 0;			ensureBLayerDataInBuffer (numberOfExtendedLenBytes, NO_ADJUST_LENGTHS);			switch (numberOfExtendedLenBytes) {			case 8:				 ddmScalarLen =					((buffer[pos++] & 0xff) << 56) +					((buffer[pos++] & 0xff) << 48) +					((buffer[pos++] & 0xff) << 40) +					((buffer[pos++] & 0xff) << 32) +					((buffer[pos++] & 0xff) << 24) +					((buffer[pos++] & 0xff) << 16) +					((buffer[pos++] & 0xff) << 8) +					((buffer[pos++] & 0xff) << 0);				adjustSize = 12;				break;			case 6:				ddmScalarLen =					((buffer[pos++] & 0xff) << 40) +					((buffer[pos++] & 0xff) << 32) +					((buffer[pos++] & 0xff) << 24) +					((buffer[pos++] & 0xff) << 16) +					((buffer[pos++] & 0xff) << 8) +					((buffer[pos++] & 0xff) << 0);				adjustSize = 10;				break;			case 4:				ddmScalarLen =					((buffer[pos++] & 0xff) << 24) +					((buffer[pos++] & 0xff) << 16) +					((buffer[pos++] & 0xff) << 8) +					((buffer[pos++] & 0xff) << 0);				adjustSize = 8;				break;			default:				agent.throwSyntaxrm(CodePoint.SYNERRCD_INCORRECT_EXTENDED_LEN,							   DRDAProtocolException.NO_CODPNT_ARG);		}			// adjust the lengths here.	this is a special case since the			// extended length bytes do not include their own length.			for (int i = 0; i <= topDdmCollectionStack; i++) {				ddmCollectionLenStack[i] -= adjustSize;			}			dssLength -= adjustSize;		}		else {			if (ddmScalarLen < 4)				agent.throwSyntaxrm(CodePoint.SYNERRCD_OBJ_LEN_LESS_THAN_4,								   DRDAProtocolException.NO_CODPNT_ARG);			adjustLengths (4);		}		return codePoint;	}	/**	 * Read the CodePoint	 *	 * @return - returns codepoint	 */	protected int readCodePoint()	{		return( ((buffer[pos++] & 0xff) << 8) +		  ((buffer[pos++] & 0xff) << 0));	}	/**	 * Push DDM Length on to collection stack	 */	protected void markCollection()	{		ddmCollectionLenStack[++topDdmCollectionStack] = ddmScalarLen;		ddmScalarLen = 0;	}	/**	 * 	Get the next CodePoint from a collection	 * 	@return	NO_CODEPOINT if collection stack is empty or remaining length is	 *		0; otherwise,  read length and code point	 *	 * @exception DRDProtocolException	 */	protected int getCodePoint() throws DRDAProtocolException	{		if (topDdmCollectionStack == EMPTY_STACK) 		{			return NO_CODEPOINT;		}		else 		{			// if the collecion is exhausted then return NO_CODEPOINT			if (ddmCollectionLenStack[topDdmCollectionStack] == 0) 			{				// done with this collection so remove it's length from the stack				ddmCollectionLenStack[topDdmCollectionStack--] = 0;				return NO_CODEPOINT;			}			else {				return readLengthAndCodePoint();			}		}	}	/**	 * Get the next CodePoint from a collection and check that it matches the specified	 * 	CodePoint	 * @param	codePointCheck	- codePoint to check against	 * @return	codePoint	 *	 * @exception DRDProtocolException	 */	protected int getCodePoint(int codePointCheck) throws DRDAProtocolException	{		int codePoint = getCodePoint();		if (codePoint != codePointCheck)			agent.missingCodePoint(codePoint);		return codePoint;	}	/**	 * The following routines read different types from the input stream	 * Data can be in network order or platform order depending on whether the	 * data is part of the protocol or data being received	 * The platform is determined by EXCSAT protocol	 */	/**	 * Read byte value	 * @return	value	 *	 * @exception DRDProtocolException	 */	protected byte readByte () throws DRDAProtocolException	{		ensureBLayerDataInBuffer (1, ADJUST_LENGTHS);		return buffer[pos++];	}	/**	 * Read byte value and mask out high order bytes before returning	 * @return value	 */	protected int readUnsignedByte () throws DRDAProtocolException	{		ensureBLayerDataInBuffer (1, ADJUST_LENGTHS);		return (int ) (buffer[pos++] & 0xff);	}	/**	 * Read network short value	 * @return	value	 *	 * @exception DRDProtocolException	 */	protected int readNetworkShort () throws DRDAProtocolException	{		ensureBLayerDataInBuffer (2, ADJUST_LENGTHS);		return ((buffer[pos++] & 0xff) << 8) +		  ((buffer[pos++] & 0xff) << 0);	}	/**	 * Read signed network short value	 * @return	value	 *	 * @exception DRDProtocolException	 */	protected int readSignedNetworkShort () throws DRDAProtocolException	{		ensureBLayerDataInBuffer (2, ADJUST_LENGTHS);		return (short)(((buffer[pos++] & 0xff) << 8) +		  ((buffer[pos++] & 0xff) << 0));	}	/**	 * Read platform short value	 * @return	value	 *	 * @exception DRDProtocolException	 */	protected short readShort (int byteOrder) throws DRDAProtocolException	{		ensureBLayerDataInBuffer (2, ADJUST_LENGTHS);		short s = SignedBinary.getShort (buffer, pos, byteOrder);		pos += 2;		return s;	}	/**	 * Read network int value	 * @return	value	 *	 * @exception DRDProtocolException	 */	protected int readNetworkInt () throws DRDAProtocolException	{		ensureBLayerDataInBuffer (4, ADJUST_LENGTHS);		return ((buffer[pos++] & 0xff) << 24) +		       ((buffer[pos++] & 0xff) << 16) +		       ((buffer[pos++] & 0xff) << 8) +		       ((buffer[pos++] & 0xff) << 0);	}	/**	 * Read platform int value	 * @return	value	 *	 * @exception DRDProtocolException	 */	protected int readInt (int byteOrder) throws DRDAProtocolException	{		ensureBLayerDataInBuffer (4, ADJUST_LENGTHS);		int i = SignedBinary.getInt (buffer, pos, byteOrder);		pos += 4;		return i;	}	/**	 * Read network long value	 * @return	value	 *	 * @exception DRDProtocolException	 */	protected long readNetworkLong () throws DRDAProtocolException	{		ensureBLayerDataInBuffer (8, ADJUST_LENGTHS);		return ((buffer[pos++] & 0xffL) << 56) +		       ((buffer[pos++] & 0xffL) << 48) +		       ((buffer[pos++] & 0xffL) << 40) +		       ((buffer[pos++] & 0xffL) << 32) +		       ((buffer[pos++] & 0xffL) << 24) +		       ((buffer[pos++] & 0xffL) << 16) +		       ((buffer[pos++] & 0xffL) << 8) +		       ((buffer[pos++] & 0xffL) << 0);	}		/**	 * Read network six byte value and put it in a long v	 * @return	value	 *	 * @exception DRDProtocolException	 */	protected long readNetworkSixByteLong() throws DRDAProtocolException	{		ensureBLayerDataInBuffer (6, ADJUST_LENGTHS);		return (				((buffer[pos++] & 0xffL) << 40) +		       ((buffer[pos++] & 0xffL) << 32) +		       ((buffer[pos++] & 0xffL) << 24) +		       ((buffer[pos++] & 0xffL) << 16) +		       ((buffer[pos++] & 0xffL) << 8) +		       ((buffer[pos++] & 0xffL) << 0));	}	/**	 * Read platform long value	 * @return	value	 *	 * @exception DRDProtocolException	 */	protected long readLong (int byteOrder) throws DRDAProtocolException	{		ensureBLayerDataInBuffer (8, ADJUST_LENGTHS);		long l = SignedBinary.getLong (buffer, pos, byteOrder);		pos += 8;		return l;	}	/**	 * Read platform float value	 * @return	value	 *	 * @exception DRDProtocolException	 */	protected float readFloat(int byteOrder) throws DRDAProtocolException	{		return Float.intBitsToFloat(readInt(byteOrder));	}	/**	 * Read platform double value	 * @return	value	 *	 * @exception DRDProtocolException	 */	protected double readDouble(int byteOrder) throws DRDAProtocolException	{		return Double.longBitsToDouble(readLong(byteOrder));	}	/**	 * Read a BigDecimal value	 * @param	precision of the BigDecimal	 * @param	scale of the BigDecimal	 * @return	value	 *	 * @exception DRDProtocolException	 */	protected BigDecimal readBigDecimal(int precision, int scale) throws DRDAProtocolException    {      // The byte-length of a packed decimal with precision p is always p/2 + 1      int length = precision / 2 + 1;	  ensureBLayerDataInBuffer (length, ADJUST_LENGTHS);      // check for sign.      int signum;      if ((buffer[pos+length-1] & 0x0F) == 0x0D)        signum = -1;      else        signum =  1;      if (precision <= 9) {        // can be handled by int without overflow.        int value = packedNybblesToInt(buffer, pos, 0, length*2-1);        // convert value to a byte array of magnitude.        byte[] magnitude = new byte[4];        magnitude[0] = (byte)(value >>> 24);        magnitude[1] = (byte)(value >>> 16);        magnitude[2] = (byte)(value >>> 8);        magnitude[3] = (byte)(value);		pos += length;        return new java.math.BigDecimal (new java.math.BigInteger(signum, magnitude), scale);      }      else if (precision <= 18) {        // can be handled by long without overflow.        long value = packedNybblesToLong(buffer, pos, 0, length*2-1);        // convert value to a byte array of magnitude.        byte[] magnitude = new byte[8];        magnitude[0] = (byte)(value >>> 56);        magnitude[1] = (byte)(value >>> 48);        magnitude[2] = (byte)(value >>> 40);        magnitude[3] = (byte)(value >>> 32);        magnitude[4] = (byte)(value >>> 24);        magnitude[5] = (byte)(value >>> 16);        magnitude[6] = (byte)(value >>>  8);        magnitude[7] = (byte)(value);		pos += length;        return new java.math.BigDecimal (new java.math.BigInteger(signum, magnitude), scale);      }      else if (precision <= 27) {        // get the value of last 9 digits (5 bytes).        int lo = packedNybblesToInt(buffer, pos, (length-5)*2, 9);        // get the value of another 9 digits (5 bytes).        int me = packedNybblesToInt(buffer, pos, (length-10)*2+1, 9);        // get the value of the rest digits.        int hi = packedNybblesToInt(buffer, pos, 0, (length-10)*2+1);        // compute the int array of magnitude.        int[] value = computeMagnitude(new int[] {hi, me, lo});        // convert value to a byte array of magnitude.        byte[] magnitude = new byte[12];        magnitude[0]  = (byte)(value[0] >>> 24);        magnitude[1]  = (byte)(value[0] >>> 16);        magnitude[2]  = (byte)(value[0] >>> 8);        magnitude[3]  = (byte)(value[0]);        magnitude[4]  = (byte)(value[1] >>> 24);        magnitude[5]  = (byte)(value[1] >>> 16);        magnitude[6]  = (byte)(value[1] >>> 8);        magnitude[7]  = (byte)(value[1]);

⌨️ 快捷键说明

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