public void writeTag(int tagClass, boolean primitive, int tag) throws AsnException {
		
		if (tag < 0)
			throw new AsnException("Tag must not be negative");

		if (tag <= 30) {
			
			int toEncode = (tagClass & 0x03) << 6;
			toEncode |= (primitive ? 0 : 1) << 5;
			toEncode |= tag & 0x1F;
			this.write(toEncode);
		} else {
			
			int toEncode = (tagClass & 0x03) << 6;
			toEncode |= (primitive ? 0 : 1) << 5;
			toEncode |= 0x1F;
			this.write(toEncode);

			int byteArr = 8;
			byte[] buf = new byte[byteArr];
			int pos = byteArr;
			while (true) {
				int dd;
				if (tag <= 0x7F) {
					dd = tag;
					if (pos != byteArr)
						dd = dd | 0x80;
					buf[--pos] = (byte) dd;
					break;
				} else {
					dd = (tag & 0x7F);
					tag >>= 7;
					if (pos != byteArr)
						dd = dd | 0x80;
					buf[--pos] = (byte) dd;
				}
			}
			this.write(buf, pos, byteArr - pos);
		}
	}
public void writeTag ( int tagClass , boolean primitive , int tag ) throws AsnException { if ( tag < 0 ) throw new AsnException ( "Tag must not be negative" ) ; if ( tag <= 30 ) { int toEncode = ( tagClass & 0x03 ) << 6 ; toEncode |= ( primitive ? 0 : 1 ) << 5 ; toEncode |= tag & 0x1F ; this . write ( toEncode ) ; } else { int toEncode = ( tagClass & 0x03 ) << 6 ; toEncode |= ( primitive ? 0 : 1 ) << 5 ; toEncode |= 0x1F ; this . write ( toEncode ) ; int byteArr = 8 ; byte [ ] buf = new byte [ byteArr ] ; int pos = byteArr ; while ( true ) { int dd ; if ( tag <= 0x7F ) { dd = tag ; if ( pos != byteArr ) dd = dd | 0x80 ; buf [ -- pos ] = ( byte ) dd ; break ; } else { dd = ( tag & 0x7F ) ; tag >>= 7 ; if ( pos != byteArr ) dd = dd | 0x80 ; buf [ -- pos ] = ( byte ) dd ; } } this . write ( buf , pos , byteArr - pos ) ; } }
Writes a tag field into the atream

@param tagClass
@param primitive
@param tag
@throws AsnException