typecode.java

来自「OTP是开放电信平台的简称」· Java 代码 · 共 874 行 · 第 1/2 页

JAVA
874
字号
/* ``The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved via the world wide web at http://www.erlang.org/. *  * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. *  * The Initial Developer of the Original Code is Ericsson Utvecklings AB. * Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings * AB. All Rights Reserved.'' *  *     $Id$ *//** * The TypeCode class for Java IDL * */package com.ericsson.otp.ic;/**  The TypeCode class is the implementation of the OMG-IDL TypeCode type.  **/public class TypeCode {  private TCKind _kind;  private java.lang.String _id,_name;  private int _length,_member_count,_default_index;  private TypeCode _member_type,_discriminator_type,_content_type;  private Any _member_label;  private boolean extracted;  private TypeCode _members[];  private java.lang.String _member_names[];  private Any _member_labels[];    /*   * Constructors   */  public TypeCode() {    extracted = false;    _members = null;    _member_names = null;    _member_labels = null;    _kind = null;    _id = null;    _name = null;    _length = -1;    _member_count = -1;    _default_index = -1;    _member_type = null;    _content_type = null;    _discriminator_type = null;    _member_label = null;  }  public TypeCode(TCKind __kind) {    _kind = __kind;  }  /*   * Operation "TypeCode::equal"    */  /**    Comparisson method for TypeCode.    @return true if the input TypeCode value equals the value of the current object, false otherwize    **/  public boolean equal(TypeCode tc) {    try {            TCKind tck = tc.kind();            switch (tck.value()) {	      case TCKind._tk_short:      case TCKind._tk_long:      case TCKind._tk_longlong:      case TCKind._tk_ushort:      case TCKind._tk_ulong:      case TCKind._tk_ulonglong:      case TCKind._tk_float:      case TCKind._tk_double:      case TCKind._tk_boolean:      case TCKind._tk_char:      case TCKind._tk_wchar:      case TCKind._tk_octet:      case TCKind._tk_string:      case TCKind._tk_wstring:      case TCKind._tk_any:      case TCKind._tk_void:      case TCKind._tk_atom:		return (tck.value() == _kind.value());	      case TCKind._tk_struct:		if((tc.id().compareTo(_id) == 0) &&	   (tc.name().compareTo(_name) == 0) &&	   (tc.member_count() == _member_count)){	  	  for (int i = 0; i < _member_count; i++)	    if (!tc.member_type(i).equal(_members[i]))	      return false;	  return true;	}	else	  return false;            case TCKind._tk_union:		if((tc.id().compareTo(_id) == 0) &&	   (tc.name().compareTo(_name) == 0) &&	   (tc.member_count() == _member_count) &&	   (tc.discriminator_type().equal(_discriminator_type))){	  	  for (int i = 0; i < _member_count; i++)	    if ((!tc.member_type(i).equal(_members[i])) &&		(tc.member_name(i).compareTo(_member_names[i]) != 0))	      return false;	  	  return true;	}	else	  return false;       case TCKind._tk_sequence:      case TCKind._tk_array:		if((tck.value() == _kind.value()) &&	   (tc.content_type().equal(_content_type)))	  return true;	else	  return false;      case TCKind._tk_enum:	if((tck.value() == _kind.value()) &&	   (tc.member_count() == _member_count)) {	  	  for (int i = 0; i < _member_count; i++)	    if (tc.member_name(i).compareTo(_member_names[i]) != 0)	      return false;	  	  return true;	}	else	  return false;		// Not used in real      case TCKind._tk_null:      case TCKind._tk_TypeCode:      case TCKind._tk_Principal:      case TCKind._tk_objref:      case TCKind._tk_alias:      case TCKind._tk_except:      case TCKind._tk_longdouble:      case TCKind._tk_fixed:	return (tck.value() == _kind.value());	      default :	return false;	      }    } catch (Exception e) {      return false;    }        }      /*   * Operation "TypeCode::kind"    */    /**    Accessor method for the TCKind value of TypeCode.    @return TCKind, the TCKind value of the TypeCode object.    **/  public TCKind kind() {    return _kind;  }  /**    Insertion method for the TCKind value of TypeCode.    Sets the TCKind value of the object.    **/  public void kind(TCKind __kind) {    _kind = __kind;  }  /**    Insertion method for the TCKind value of TypeCode.    Sets the TCKind value of the object.    **/  public static TCKind kind(java.lang.String atom)     throws java.lang.Exception {        if (atom.equals("tk_null"))      return TCKind.tk_null;         else      if (atom.equals("tk_void"))	return TCKind.tk_void;         else      if (atom.equals("tk_short"))	return TCKind.tk_short;         else      if (atom.equals("tk_long"))	return TCKind.tk_long;         else      if (atom.equals("tk_ushort"))	return TCKind.tk_ushort;         else      if (atom.equals("tk_ulong"))	return TCKind.tk_ulong;         else       if (atom.equals("tk_float"))	return TCKind.tk_float;         else      if (atom.equals("tk_double"))	return TCKind.tk_double;         else      if (atom.equals("tk_boolean"))	return TCKind.tk_boolean;         else      if (atom.equals("tk_char"))	return TCKind.tk_char;         else      if (atom.equals("tk_octet"))	return TCKind.tk_octet;         else      if (atom.equals("tk_any"))	return TCKind.tk_any;         else      if (atom.equals("tk_TypeCode"))	return TCKind.tk_TypeCode;         else      if (atom.equals("tk_Principal"))	return TCKind.tk_Principal;         else      if (atom.equals("tk_objref"))	return TCKind.tk_objref;         else      if (atom.equals("tk_struct"))	return TCKind.tk_struct;         else      if (atom.equals("tk_union"))	return TCKind.tk_union;         else      if (atom.equals("tk_enum"))	return TCKind.tk_enum;         else      if (atom.equals("tk_string"))	return TCKind.tk_string;         else      if (atom.equals("tk_sequence"))	return TCKind.tk_sequence;         else      if (atom.equals("tk_array"))	return TCKind.tk_array;         else      if (atom.equals("tk_alias"))	return TCKind.tk_alias;         else      if (atom.equals("tk_except"))	return TCKind.tk_except;         else      if (atom.equals("tk_longlong"))	return TCKind.tk_longlong;         else      if (atom.equals("tk_ulonglong"))	return TCKind.tk_ulonglong;       else      if (atom.equals("tk_longdouble"))	return TCKind.tk_longdouble;         else      if (atom.equals("tk_wchar"))	return TCKind.tk_wchar;    else      if (atom.equals("tk_wstring"))	return TCKind.tk_wstring;         else      if (atom.equals("tk_fixed"))	return TCKind.tk_fixed;    else      if (atom.equals("tk_atom"))	return TCKind.tk_atom;        else      throw new java.lang.Exception("BAD KIND");    }        /*   * Operation "TypeCode::id"    */  /**    Accessor method for the id value of TypeCode.    @return String, the id value of TypeCode object    **/  public java.lang.String id()    throws java.lang.Exception{            if (_id == null) 	throw new java.lang.Exception("BAD KIND");      return _id;  }  /**    Insertion method for the id value of TypeCode.    Sets the id value of the object.    **/  public void id(java.lang.String __id) {            _id = __id;  }      /*   * Operation "TypeCode::name"    */  /**    Accessor method for the name value of TypeCode.    @return String, the name value of TypeCode object    **/  public java.lang.String name()    throws java.lang.Exception{            if (_name == null) 	throw new java.lang.Exception("BAD KIND");            return _name;  }    /**    Insertion method for the name value of TypeCode.    Sets the name value of the object.    **/  public void name(java.lang.String __name) {      _name = __name;  }    /*   * Operation "TypeCode::member_count"    */    /**    Accessor method for the member number value of TypeCode.    @return int, the number of members of TypeCode object    **/  public int member_count()    throws java.lang.Exception{            if (_member_count == -1) 	throw new java.lang.Exception("BAD KIND");            return _member_count;  }  /**    Insertion method for the member number value of TypeCode.    Sets the number of members value of the object.    **/  public void member_count(int __member_count) {    switch(_kind.value()) {    case TCKind._tk_struct:      _members = new TypeCode[__member_count];      _member_names = new java.lang.String[__member_count];      _member_count = __member_count;      break;    case TCKind._tk_union:      _members = new TypeCode[__member_count];      _member_names = new java.lang.String[__member_count];      _member_labels = new Any[__member_count];      _member_count = __member_count;      break;    case TCKind._tk_enum:      _member_names = new java.lang.String[__member_count];      _member_count = __member_count;      break;    default :      // Do nothing    }  }    /*   * Operation "TypeCode::member_name"    */    /**    Member name accessor method for TypeCode.    @return String, the name value of the member of the TypeCode object    on the selected index    **/  public java.lang.String member_name(int __index)    throws java.lang.Exception{            return _member_names[__index];  }    /**    Insertion method for the indexed member name of TypeCode.    Sets the name of a member value of the object at the selected index..    **/  public void member_name(int __index, java.lang.String __member_name) {    _member_names[__index] = __member_name;  }    /*   * Operation "TypeCode::member_type"    */    /**    Member type accessor method for TypeCode.    @return TypeCOde, the type of the member of the TypeCode object    on the selected index    **/  public TypeCode member_type(int __index)

⌨️ 快捷键说明

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