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

📄 typecodeimpl.java

📁 JAVA的一些源码 JAVA2 STANDARD EDITION DEVELOPMENT KIT 5.0
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	case TCKind._tk_short:	case TCKind._tk_ushort:	    dst.write_short(src.read_short());	    break;	case TCKind._tk_long:	case TCKind._tk_ulong:	    dst.write_long(src.read_long());	    break;	case TCKind._tk_float:	    dst.write_float(src.read_float());	    break;	case TCKind._tk_double:	    dst.write_double(src.read_double());	    break;	case TCKind._tk_longlong:	case TCKind._tk_ulonglong:	    dst.write_longlong(src.read_longlong());	    break;	case TCKind._tk_longdouble:	    throw wrapper.tkLongDoubleNotSupported() ;	case TCKind._tk_boolean:	    dst.write_boolean(src.read_boolean());	    break;	  	case TCKind._tk_char:	    dst.write_char(src.read_char());	    break;	case TCKind._tk_wchar:	    dst.write_wchar(src.read_wchar());	    break;	  	case TCKind._tk_octet:	    dst.write_octet(src.read_octet());	    break;	case TCKind._tk_string:	    {		String s;		s = src.read_string();		// make sure length bound in typecode is not violated		if ((_length != 0) && (s.length() > _length))		    throw wrapper.badStringBounds( new Integer(s.length()),			new Integer(_length) ) ;		dst.write_string(s);	    }	    break;	case TCKind._tk_wstring:	    {		String s;		s = src.read_wstring();		// make sure length bound in typecode is not violated		if ((_length != 0) && (s.length() > _length))		    throw wrapper.badStringBounds( new Integer(s.length()),			new Integer(_length) ) ;		dst.write_wstring(s);	    }	    break;	case TCKind._tk_fixed:	    {		dst.write_ushort(src.read_ushort());		dst.write_short(src.read_short());	    }	    break;	case TCKind._tk_any: 	    {		//Any tmp = new AnyImpl(_orb);		Any tmp =  ((CDRInputStream)src).orb().create_any();		TypeCodeImpl t = new TypeCodeImpl((ORB)dst.orb());		t.read_value((org.omg.CORBA_2_3.portable.InputStream)src);		t.write_value((org.omg.CORBA_2_3.portable.OutputStream)dst);		tmp.read_value(src, t);		tmp.write_value(dst);		break;	    }		case TCKind._tk_TypeCode: 	    {		dst.write_TypeCode(src.read_TypeCode());		break;	    }		case TCKind._tk_Principal: 	    {		dst.write_Principal(src.read_Principal());		break;	    }	case TCKind._tk_objref:	    {		dst.write_Object(src.read_Object());		break;	    }	case TCKind._tk_except:	    // Copy repositoryId	    dst.write_string(src.read_string());	    // Fall into ...	// _REVISIT_ what about the inherited members of this values concrete base type?	case TCKind._tk_value:	case TCKind._tk_struct:	    {		// copy each element, using the corresponding member type		for (int i=0; i < _memberTypes.length; i++) {		    _memberTypes[i].copy(src, dst);		}		break;	    }	case TCKind._tk_union:    /* _REVISIT_ More generic code?	    {		Any discriminator = new AnyImpl(_orb);		discriminator.read_value(src, _discriminator);		discriminator.write_value(dst);		int labelIndex = currentUnionMemberIndex(discriminator);		if (labelIndex == -1) {		    // check if label has not been found		    if (_defaultIndex == -1)			// throw exception if default was not expected			throw new MARSHAL();		    else 			// must be of the default branch type			_memberTypes[_defaultIndex].copy(src, dst);		} else {		    _memberTypes[labelIndex].copy(src, dst);		}	    }    */	    {		Any tagValue = new AnyImpl( (ORB)src.orb());		switch  (realType(_discriminator).kind().value()) {		case TCKind._tk_short:		    {			short value = src.read_short();			tagValue.insert_short(value);			dst.write_short(value);			break;		    }		case TCKind._tk_long:		    {			int value = src.read_long();			tagValue.insert_long(value);			dst.write_long(value);			break;		    }		case TCKind._tk_ushort:		    {			short value = src.read_short();			tagValue.insert_ushort(value);			dst.write_short(value);			break;		    }		case TCKind._tk_ulong:		    {			int value = src.read_long();			tagValue.insert_ulong(value);			dst.write_long(value);			break;		    }		case TCKind._tk_float:		    {			float value = src.read_float();			tagValue.insert_float(value);			dst.write_float(value);			break;		    }		case TCKind._tk_double:		    {			double value = src.read_double();			tagValue.insert_double(value);			dst.write_double(value);			break;		    }		case TCKind._tk_boolean:		    {			boolean value = src.read_boolean();			tagValue.insert_boolean(value);			dst.write_boolean(value);			break;		    }		case TCKind._tk_char:		    {			char value = src.read_char();			tagValue.insert_char(value);			dst.write_char(value);			break;		    }		case TCKind._tk_enum:		    {			int value = src.read_long();			tagValue.type(_discriminator);			tagValue.insert_long(value);			dst.write_long(value);			break;		    }		case TCKind._tk_longlong:		    {			long value = src.read_longlong();			tagValue.insert_longlong(value);			dst.write_longlong(value);			break;		    }		case TCKind._tk_ulonglong:		    {			long value = src.read_longlong();			tagValue.insert_ulonglong(value);			dst.write_longlong(value);			break;		    }		    // _REVISIT_ figure out long double mapping		    // case TCKind.tk_longdouble:		    // {		    // double value = src.read_double();		    //  tagValue.insert_longdouble(value);		    //  dst.putDouble(value);		    //  break;		    //}		case TCKind._tk_wchar:		    {			char value = src.read_wchar();			tagValue.insert_wchar(value);			dst.write_wchar(value);			break;		    }		default:		    throw wrapper.illegalUnionDiscriminatorType() ;		}		// using the value of the tag, find out the type of the value		// following. 		int labelIndex;		for (labelIndex = 0; labelIndex < _unionLabels.length; labelIndex++) {		    // use equality over anys		    if (tagValue.equal(_unionLabels[labelIndex])) {			_memberTypes[labelIndex].copy(src, dst);			break;		    }		}		if (labelIndex == _unionLabels.length) {		    // check if label has not been found		    if (_defaultIndex == -1)			// throw exception if default was not expected			throw wrapper.unexpectedUnionDefault() ;		    else 			// must be of the default branch type			_memberTypes[_defaultIndex].copy(src, dst);		}		break;	    }	case TCKind._tk_enum:	    dst.write_long(src.read_long());	    break;	  	case TCKind._tk_sequence:	    // get the length of the sequence	    int seqLength = src.read_long();	    // check for sequence bound violated	    if ((_length != 0) && (seqLength > _length))		throw wrapper.badSequenceBounds( new Integer(seqLength),		    new Integer(_length) ) ;	    // write the length of the sequence	    dst.write_long(seqLength);	    // copy each element of the seq using content type	    lazy_content_type(); // make sure it's resolved	    for (int i=0; i < seqLength; i++)		_contentType.copy(src, dst);	    break;	case TCKind._tk_array:	    // copy each element of the array using content type	    for (int i=0; i < _length; i++)		_contentType.copy(src, dst);	    break;	case TCKind._tk_alias:	case TCKind._tk_value_box:	    // follow the alias	    _contentType.copy(src, dst);	    break;	case tk_indirect:	    // need to follow offset, get unmarshal typecode from that	    // offset, and use that to do the copy	    // Don't need to read type code before using it to do the copy.	    // It should be fully usable.	    indirectType().copy(src, dst);	    break;	default:	    throw wrapper.invalidTypecodeKindMarshal() ;	}    }    static protected short digits(java.math.BigDecimal value) {        if (value == null)            return 0;        short length = (short)value.unscaledValue().toString().length();        if (value.signum() == -1)            length--;        return length;    }    static protected short scale(java.math.BigDecimal value) {        if (value == null)            return 0;        return (short)value.scale();    }    // Utility methods    // Only for union type. Returns the index of the union member    // corresponding to the discriminator. If not found returns the    // default index or -1 if there is no default index.    int currentUnionMemberIndex(Any discriminatorValue) throws BadKind {        if (_kind != TCKind._tk_union)            throw new BadKind();        try {            for (int i=0; i<member_count(); i++) {                if (member_label(i).equal(discriminatorValue)) {                    return i;                }            }            if (_defaultIndex != -1) {                return _defaultIndex;            }        } catch (BadKind bad) {        } catch (org.omg.CORBA.TypeCodePackage.Bounds bounds) {        }        return -1;    }    public String description() {        return "TypeCodeImpl with kind " + _kind + " and id " + _id;    }    public String toString() {        ByteArrayOutputStream byteOut = new ByteArrayOutputStream(1024);        PrintStream printOut = new PrintStream(byteOut, true);        printStream(printOut);        return super.toString() + " =\n" + byteOut.toString();    }    public void printStream(PrintStream s) {        printStream(s, 0);    }    private void printStream(PrintStream s, int level) {        if (_kind == tk_indirect) {            s.print("indirect " + _id);            return;        }        switch (_kind) {            case TCKind._tk_null:            case TCKind._tk_void:            case TCKind._tk_short:            case TCKind._tk_long:            case TCKind._tk_ushort:            case TCKind._tk_ulong:            case TCKind._tk_float:            case TCKind._tk_double:            case TCKind._tk_boolean:            case TCKind._tk_char:            case TCKind._tk_octet:            case TCKind._tk_any:            case TCKind._tk_TypeCode:            case TCKind._tk_Principal:            case TCKind._tk_objref:            case TCKind._tk_longlong:            case TCKind._tk_ulonglong:            case TCKind._tk_longdouble:            case TCKind._tk_wchar:            case TCKind._tk_native:                s.print(kindNames[_kind] + " " + _name);	        break;            case TCKind._tk_struct:            case TCKind._tk_except:            case TCKind._tk_value:                s.println(kindNames[_kind] + " " + _name + " = {");                for(int i=0; i<_memberCount; i++) {                    // memberName might differ from the name of the member.                    s.print(indent(level + 1));                    if (_memberTypes[i] != null)                        _memberTypes[i].printStream(s, level + 1);                    else                        s.print("<unknown type>");                    s.println(" " + _memberNames[i] + ";");                }                s.print(indent(level) + "}");	        break;            case TCKind._tk_union:                s.print("union " + _name + "...");	        break;            case TCKind._tk_enum:                s.print("enum " + _name + "...");	        break;            case TCKind._tk_string:                if (_length == 0)                    s.print("unbounded string " + _name);                else                    s.print("bounded string(" + _length + ") " + _name);	        break;            case TCKind._tk_sequence:            case TCKind._tk_array:                s.println(kindNames[_kind] + "[" + _length + "] " + _name + " = {");                s.print(indent(level + 1));                if (lazy_content_type() != null) {                    lazy_content_type().printStream(s, level + 1);                }                s.println(indent(level) + "}");	        break;            case TCKind._tk_alias:                s.print("alias " + _name + " = " + 		    (_contentType != null ? _contentType._name : "<unresolved>"));	        break;            case TCKind._tk_wstring:                s.print("wstring[" + _length + "] " + _name);	        break;            case TCKind._tk_fixed:                s.print("fixed(" + _digits + ", " + _scale + ") " + _name);	        break;            case TCKind._tk_value_box:                s.print("valueBox " + _name + "...");	        break;            case TCKind._tk_abstract_interface:                s.print("abstractInterface " + _name + "...");	        break;            default:                s.print("<unknown type>");	        break;        }    }    private String indent(int level) {        String indent = "";        for(int i=0; i<level; i++) {            indent += "  ";        }        return indent;    }    protected void setCaching(boolean enableCaching) {        cachingEnabled = enableCaching;        if (enableCaching == false)            outBuffer = null;    }}

⌨️ 快捷键说明

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