diff options
Diffstat (limited to 'lib/ic/java_src/com/ericsson')
30 files changed, 5474 insertions, 0 deletions
diff --git a/lib/ic/java_src/com/ericsson/otp/ic/Any.java b/lib/ic/java_src/com/ericsson/otp/ic/Any.java new file mode 100644 index 0000000000..7337241908 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/Any.java @@ -0,0 +1,1023 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + + +/** + +The Any class is the java mapping of the any OMG-IDL type. + + +**/ + + +public class Any { + + // Typecode value holder + protected TypeCode tcV; + + // Primitive value holder + protected java.lang.String stringV; + protected byte byteV; + protected boolean booleanV; + protected char charV; + protected short shortV; + protected int intV; + protected long longV; + protected float floatV; + protected double doubleV; + + // Streams used for user defined types + protected com.ericsson.otp.erlang.OtpInputStream is; + protected com.ericsson.otp.erlang.OtpOutputStream os; + + + // Constructor + public Any() { + tcV = null; + } + + // Equal function + + /** + Any comparison method + @return true if the input Any is equal to the object, false otherwize + **/ + public boolean equal(com.ericsson.otp.ic.Any _any) { + + int _is1Len,_is2Len; + byte _compressed[]; + com.ericsson.otp.erlang.OtpInputStream _is1,_is2; + TypeCode _tc = _any.type(); + + if (!tcV.equal(_tc)) + return false; + + try { + + TCKind _tck = _tc.kind(); + + switch (_tck.value()) { + + case TCKind._tk_short: + return (_any.extract_short() == shortV); + + case TCKind._tk_ushort: + return (_any.extract_ushort() == shortV); + + case TCKind._tk_long: + return (_any.extract_long() == intV); + + case TCKind._tk_longlong: + return (_any.extract_longlong() == longV); + + case TCKind._tk_ulong: + return (_any.extract_ulong() == intV); + + case TCKind._tk_ulonglong: + return (_any.extract_ulonglong() == longV); + + case TCKind._tk_float: + return equal(_any.extract_float(),floatV); + + case TCKind._tk_double: + return equal(_any.extract_double(),doubleV); + + case TCKind._tk_boolean: + return (_any.extract_boolean() == booleanV); + + case TCKind._tk_char: + return (_any.extract_char() == charV); + + case TCKind._tk_wchar: + return (_any.extract_wchar() == charV); + + case TCKind._tk_octet: + return (_any.extract_octet() == byteV); + + case TCKind._tk_string: + return (_any.extract_string().compareTo(stringV) == 0); + + case TCKind._tk_wstring: + return (_any.extract_wstring().compareTo(stringV) == 0); + + case TCKind._tk_sequence: + + _is1 = new com.ericsson.otp.erlang.OtpInputStream(os.toByteArray()); + + _is2 = _any.extract_Streamable(); + + if (_is1.peek() != _is2.peek()) { + + // _is1's sequence is compressed to string + if(_is1.peek() == com.ericsson.otp.erlang.OtpExternal.stringTag) { + + _compressed = (_is1.read_string()).getBytes(); + _is1Len = _compressed.length; + + _is2.read_list_head(); + + for(int i = 0; i < _is1Len; i++) { + if ((long)(_compressed[i] & 0xff) != _is2.read_long()) + return false; + } + + _is2.read_nil(); + } + else { // _is2's sequence is compressed to string + + _compressed = (_is2.read_string()).getBytes(); + _is2Len = _compressed.length; + + _is1.read_list_head(); + + for(int i = 0; i < _is2Len; i++) + if ((long)(_compressed[i] & 0xff) != _is1.read_long()) + return false; + + _is1.read_nil(); + } + } + else { // None of them is compressed + + _is2Len = _is2.available(); + + if (_is1.available() != _is2Len) + return false; + + for(int i = 0; i < _is2Len; i++) { + if (_is1.read() != _is2.read()) + return false; + } + } + + return true; + + case TCKind._tk_struct: + case TCKind._tk_union: + case TCKind._tk_array: + case TCKind._tk_enum: + + _is1 = new com.ericsson.otp.erlang.OtpInputStream(os.toByteArray()); + + _is2 = _any.extract_Streamable(); + + _is2Len = _is2.available(); + + if (_is1.available() != _is2Len) + return false; + + for(int i = 0; i < _is2Len; i++) { + if (_is1.read() != _is2.read()) + return false; + } + + return true; + + // Not used in real + case TCKind._tk_any: + case TCKind._tk_void: + case TCKind._tk_atom: + 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 true; + + default : + return false; + + } + } catch (Exception e) { + //e.printStackTrace(); + return false; + } + + } + + + /* Equal function for floats ( relative diff ) */ + boolean equal(float x, float y) { + + if (x != 0) + return (java.lang.Math.abs((x-y)/x) < 1.0E-15); + + if (y != 0) + return (java.lang.Math.abs((y-x)/y) < 1.0E-15); + + return (x==y); + } + + /* Equal function for doubles ( relative diff ) */ + boolean equal(double x, double y) { + + if (x != 0) + return (java.lang.Math.abs((x-y)/x) < 1.0E-15); + + if (y != 0) + return (java.lang.Math.abs((y-x)/y) < 1.0E-15); + + return (x==y); + } + + + + /** + TypeCode accessor method + @return the Any's TypeCode + **/ + public TypeCode type() { + return tcV; + } + + + /** + TypeCode insertion method + **/ + public void type(TypeCode _tc) { + tcV = _tc; + } + + + /* Value accessors */ + + /** + Reads a value from the stream, according to the inserted TypeCode + **/ + public void read_value(com.ericsson.otp.erlang.OtpInputStream _is, + TypeCode _tc) + throws java.lang.Exception { + + tcV = _tc; + + switch(tcV.kind().value()) { + + case TCKind._tk_short : + shortV = _is.read_short(); + break; + case TCKind._tk_ushort : + shortV = _is.read_ushort(); + break; + case TCKind._tk_long : + intV = _is.read_int(); + break; + case TCKind._tk_ulong : + intV = _is.read_uint(); + break; + case TCKind._tk_longlong : + longV = _is.read_long(); + break; + case TCKind._tk_ulonglong : + longV = _is.read_ulong(); + break; + case TCKind._tk_float : + floatV = _is.read_float(); + break; + case TCKind._tk_double : + doubleV = _is.read_double(); + break; + case TCKind._tk_boolean : + booleanV = _is.read_boolean(); + break; + case TCKind._tk_char : + case TCKind._tk_wchar : + charV = _is.read_char(); + break; + case TCKind._tk_octet : + byteV = _is.read_byte(); + break; + case TCKind._tk_string : + case TCKind._tk_wstring : + stringV = _is.read_string(); + break; + case TCKind._tk_atom : + stringV = _is.read_atom(); + break; + case TCKind._tk_void : + _is.read_atom(); + break; + + /* + * Not supported types + */ + case TCKind._tk_any : + 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 : + throw new java.lang.Exception("Unsupported type"); + + default: // User defined type + + if (os == null) + os = new com.ericsson.otp.erlang.OtpOutputStream(); + else + os.reset(); + + try { + read_user_defined(_is, _tc); + is = new com.ericsson.otp.erlang.OtpInputStream(os.toByteArray()); + } catch (Exception e) { + throw new java.lang.Exception("BAD VALUE"); + } + } + + } + + void read_user_defined(com.ericsson.otp.erlang.OtpInputStream _is, TypeCode _tc) + throws java.lang.Exception { + + TypeCode memberTC = null; + int len = -1; + int __tag; + + switch(_tc.kind().value()) { + + case TCKind._tk_short : + os.write_short(_is.read_short()); + break; + case TCKind._tk_ushort : + os.write_ushort(_is.read_ushort()); + break; + case TCKind._tk_long : + os.write_int(_is.read_int()); + break; + case TCKind._tk_longlong : + os.write_long(_is.read_long()); + break; + case TCKind._tk_ulong : + os.write_uint(_is.read_uint()); + break; + case TCKind._tk_ulonglong : + os.write_ulong(_is.read_ulong()); + break; + case TCKind._tk_float : + os.write_float(_is.read_float()); + break; + case TCKind._tk_double : + os.write_double(_is.read_double()); + break; + case TCKind._tk_boolean : + os.write_boolean(_is.read_boolean()); + break; + case TCKind._tk_char : + case TCKind._tk_wchar : + os.write_char(_is.read_char()); + break; + case TCKind._tk_octet : + os.write_byte(_is.read_byte()); + break; + case TCKind._tk_string : + case TCKind._tk_wstring : + os.write_string(_is.read_string()); + break; + + case TCKind._tk_struct: + len = _is.read_tuple_head(); + os.write_tuple_head(len); + os.write_atom(_is.read_atom()); + // Member list + len -=1; + for(int i=0; i<len; i++) + read_user_defined(_is,_tc.member_type(i)); + break; + + case TCKind._tk_union: + os.write_tuple_head(_is.read_tuple_head()); + os.write_atom(_is.read_atom()); + + int __mlen = _tc.member_count(); + __tag = _is.peek(); + boolean __found = false; + + switch (__tag) { + case (com.ericsson.otp.erlang.OtpExternal.atomTag): + java.lang.String __elabel = _is.read_atom(); // Enumerant or Boolean + os.write_atom(__elabel); + + for (int i=0; i<__mlen; i++) { + java.lang.String __mlabel; + if (_tc.member_label(i).type().kind().value() == TCKind._tk_string) + __mlabel = _tc.member_label(i).extract_string(); + else // Default + __mlabel = _tc.member_label(i).extract_atom(); + + if (__elabel.compareTo(__mlabel)==0) { + read_user_defined(_is,_tc.member_type(i)); + i = __mlen; + __found = true; + } + } + break; + + default: // Integer type + long __ilabel = _is.read_long(); + os.write_long(__ilabel); + + for (int i=0; i<__mlen; i++) { + boolean __itype = true; + long __mlabel = 0; + + switch (_tc.member_label(i).type().kind().value()) { + + case TCKind._tk_short : + __mlabel = _tc.member_label(i).extract_short(); + break; + case TCKind._tk_ushort : + __mlabel = _tc.member_label(i).extract_ushort(); + break; + case TCKind._tk_long : + __mlabel = _tc.member_label(i).extract_long(); + break; + case TCKind._tk_longlong : + __mlabel = _tc.member_label(i).extract_longlong(); + break; + case TCKind._tk_ulong : + __mlabel = _tc.member_label(i).extract_ulong(); + break; + case TCKind._tk_ulonglong : + __mlabel = _tc.member_label(i).extract_ulonglong(); + break; + case TCKind._tk_char : + __mlabel = _tc.member_label(i).extract_char(); + break; + case TCKind._tk_wchar : + __mlabel = _tc.member_label(i).extract_wchar(); + break; + + default : // Default label + __itype = false; + + } + + if (__itype) { + if (__ilabel == __mlabel) { + read_user_defined(_is,_tc.member_type(i)); + i = __mlen; + __found = true; + } + } + } + } + + // Use the default label instead + if (!__found) + read_user_defined(_is,_tc.member_type(_tc.default_index())); + + break; + + case TCKind._tk_sequence: + __tag = _is.peek(); + + switch(__tag) { + case com.ericsson.otp.erlang.OtpExternal.stringTag: + os.write_string(_is.read_string()); + break; + default: + len = _is.read_list_head(); + os.write_list_head(len); + + for (int i=0; i<len; i++) + read_user_defined(_is,_tc.content_type()); + + _is.read_nil(); + os.write_nil(); + } + break; + + case TCKind._tk_array: + len = _is.read_tuple_head(); + os.write_tuple_head(len); + for (int i=0; i<len; i++) + read_user_defined(_is,_tc.content_type()); + break; + + case TCKind._tk_enum: + os.write_atom(_is.read_atom()); + break; + + case TCKind._tk_void : + os.write_atom(_is.read_atom()); + break; + + case TCKind._tk_any : + AnyHelper.marshal(os,AnyHelper.unmarshal(_is)); + break; + + /* + * Not supported types + */ + default : + throw new java.lang.Exception(""); + + } + + } + + + /** + Writes the Any's value to the ouput stream + **/ + public void write_value(com.ericsson.otp.erlang.OtpOutputStream _os) + throws java.lang.Exception { + + switch(tcV.kind().value()) { + + case TCKind._tk_short : + _os.write_short(shortV); + break; + case TCKind._tk_ushort : + _os.write_ushort(shortV); + break; + case TCKind._tk_long : + _os.write_int(intV); + break; + case TCKind._tk_ulong : + _os.write_uint(intV); + break; + case TCKind._tk_longlong : + _os.write_long(longV); + break; + case TCKind._tk_ulonglong : + _os.write_ulong(longV); + break; + case TCKind._tk_float : + _os.write_float(floatV); + break; + case TCKind._tk_double : + _os.write_double(doubleV); + break; + case TCKind._tk_boolean : + _os.write_boolean(booleanV); + break; + case TCKind._tk_char : + case TCKind._tk_wchar : + _os.write_char(charV); + break; + case TCKind._tk_octet : + _os.write_byte(byteV); + break; + case TCKind._tk_string : + case TCKind._tk_wstring : + _os.write_string(stringV); + break; + case TCKind._tk_atom : + _os.write_atom(stringV); + break; + case TCKind._tk_void : + _os.write_atom("ok"); + break; + + /* + * Not supported types + */ + case TCKind._tk_any : + 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 : + throw new java.lang.Exception("BAD KIND"); + + default: + _os.write(os.toByteArray()); + } + } + + + /* + * Insert and extract each primitive type + */ + + /* short */ + + /** + Short value extractor method + @return short, the value of Any + **/ + public short extract_short() + throws java.lang.Exception { + if (tcV.kind() == TCKind.tk_short) + return shortV; + + throw new java.lang.Exception(""); + } + + /** + Short value insertion method + **/ + public void insert_short(short s) { + shortV = s; + tcV = new TypeCode(TCKind.tk_short); + }; + + + /* long */ + /** + Long value extractor method + @return int, the value of Any + **/ + public int extract_long() + throws java.lang.Exception { + if (tcV.kind() == TCKind.tk_long) + return intV; + + throw new java.lang.Exception(""); + } + + /** + Long value insertion method + **/ + public void insert_long(int i){ + intV = i; + tcV = new TypeCode(TCKind.tk_long); + } + + + + /* long long */ + /** + Long Long value extractor method + @return long, the value of Any + **/ + public long extract_longlong() + throws java.lang.Exception { + if (tcV.kind() == TCKind.tk_longlong) + return longV; + + throw new java.lang.Exception(""); + } + + /** + Long Long value insertion method + **/ + public void insert_longlong(long l){ + longV = l; + tcV = new TypeCode(TCKind.tk_longlong); + } + + + /* ushort */ + /** + Unsigned Short value extractor method + @return short, the value of Any + **/ + public short extract_ushort() + throws java.lang.Exception { + if (tcV.kind() == TCKind.tk_ushort) + return shortV; + + throw new java.lang.Exception(""); + } + + /** + Unsigned Short value insertion method + **/ + public void insert_ushort(short s){ + shortV = s; + tcV = new TypeCode(TCKind.tk_ushort); + } + + + /* ulong */ + + /** + Unsigned Long value extractor method + @return int, the value of Any + **/ + public int extract_ulong() + throws java.lang.Exception{ + if (tcV.kind() == TCKind.tk_ulong) + return intV; + + throw new java.lang.Exception(""); + } + + /** + Unsigned Long value insertion method + **/ + public void insert_ulong(int i){ + intV = i; + tcV = new TypeCode(TCKind.tk_ulong); + } + + + + + /* unsigned long long */ + /** + Unsigned Long Long value extractor method + @return long, the value of Any + **/ + public long extract_ulonglong() + throws java.lang.Exception { + if (tcV.kind() == TCKind.tk_ulonglong) + return longV; + + throw new java.lang.Exception(""); + } + + /** + Unsigned Long Long value insertion method + **/ + public void insert_ulonglong(long l){ + longV = l; + tcV = new TypeCode(TCKind.tk_ulonglong); + } + + + /* float */ + /** + Float value extractor method + @return float, the value of Any + **/ + public float extract_float() + throws java.lang.Exception{ + if (tcV.kind() == TCKind.tk_float) + return floatV; + + throw new java.lang.Exception(""); + } + + /** + Float value insertion method + **/ + public void insert_float(float f){ + floatV = f; + tcV = new TypeCode(TCKind.tk_float); + } + + + /* double */ + /** + Double value extractor method + @return double, the value of Any + **/ + public double extract_double() + throws java.lang.Exception{ + if (tcV.kind() == TCKind.tk_double) + return doubleV; + + throw new java.lang.Exception(""); + } + + /** + Double value insertion method + **/ + public void insert_double(double d){ + doubleV = d; + tcV = new TypeCode(TCKind.tk_double); + } + + + /* boolean */ + /** + Boolean value extractor method + @return boolean, the value of Any + **/ + public boolean extract_boolean() + throws java.lang.Exception{ + if (tcV.kind() == TCKind.tk_boolean) + return booleanV; + + throw new java.lang.Exception(""); + } + + /** + Boolean value insertion method + **/ + public void insert_boolean(boolean b){ + booleanV = b; + tcV = new TypeCode(TCKind.tk_boolean); + } + + + + /* char */ + /** + Char value extractor method + @return char, the value of Any + **/ + public char extract_char() + throws java.lang.Exception{ + if (tcV.kind() == TCKind.tk_char) + return charV; + + throw new java.lang.Exception(""); + } + + /** + Char value insertion method + **/ + public void insert_char(char c) { + charV = c; + tcV = new TypeCode(TCKind.tk_char); + } + + + /* wchar */ + /** + Wchar value extractor method + @return char, the value of Any + **/ + public char extract_wchar() + throws java.lang.Exception{ + if (tcV.kind() == TCKind.tk_wchar) + return charV; + + throw new java.lang.Exception(""); + } + + /** + Wchar value insertion method + **/ + public void insert_wchar(char c) { + charV = c; + tcV = new TypeCode(TCKind.tk_wchar); + } + + + + /* octet */ + /** + Octet value extractor method + @return byte, the value of Any + **/ + public byte extract_octet() + throws java.lang.Exception{ + if (tcV.kind() == TCKind.tk_octet) + return byteV; + + throw new java.lang.Exception(""); + } + + /** + Octet value insertion method + **/ + public void insert_octet(byte b){ + byteV = b; + tcV = new TypeCode(TCKind.tk_octet); + } + + + /* string */ + /** + String value extractor method + @return String, the value of Any + **/ + public java.lang.String extract_string() + throws java.lang.Exception{ + if (tcV.kind() == TCKind.tk_string) + return stringV; + + throw new java.lang.Exception(""); + } + + /** + String value insertion method + **/ + public void insert_string(java.lang.String s) { + stringV = s; + tcV = new TypeCode(TCKind.tk_string); + } + + + + /* wstring */ + /** + Wstring value extractor method + @return String, the value of Any + **/ + public java.lang.String extract_wstring() + throws java.lang.Exception{ + if (tcV.kind() == TCKind.tk_wstring) + return stringV; + + throw new java.lang.Exception(""); + } + + /** + Wstring value insertion method + **/ + public void insert_wstring(java.lang.String s) { + stringV = s; + tcV = new TypeCode(TCKind.tk_wstring); + } + + + + /* atom */ + /** + Atom value extractor method + @return atom, the value of Any + **/ + public java.lang.String extract_atom() + throws java.lang.Exception{ + if (tcV.kind() == TCKind.tk_atom) + return stringV; + + throw new java.lang.Exception(""); + } + + /** + Atom value insertion method + **/ + public void insert_atom(java.lang.String s) { + stringV = s; + tcV = new TypeCode(TCKind.tk_atom); + } + + + /** + Object Stream insertion method + **/ + public void insert_Streamable(com.ericsson.otp.erlang.OtpOutputStream _os) { + os = _os; + } + + /** + Object Stream extractor method + @return OtpInputStream, the stream value of Any + **/ + public com.ericsson.otp.erlang.OtpInputStream extract_Streamable() { + + if (is == null) { + if (os == null) + return null; + else { + is = new com.ericsson.otp.erlang.OtpInputStream(os.toByteArray()); + } + } + + is.reset(); + return is; + } + +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/ic/java_src/com/ericsson/otp/ic/AnyHelper.java b/lib/ic/java_src/com/ericsson/otp/ic/AnyHelper.java new file mode 100644 index 0000000000..d80d299db8 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/AnyHelper.java @@ -0,0 +1,78 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + +Helper class for Any, according to OMG-IDL java mapping. +<p>Instead for write,read methods, the methods marshal respective +unmarshal are used to denote the implementation difference. + +**/ + + +public class AnyHelper { + + // Constructors + private AnyHelper() {} + + // Methods + /** + Marshal method for the Any class, encodes the Any object to the output stream. + **/ + public static void marshal(com.ericsson.otp.erlang.OtpOutputStream _out, Any _any) + throws java.lang.Exception { + + TypeCode _tc = _any.type(); + + _out.write_tuple_head(3); + _out.write_atom("any"); + + TypeCode.marshal(_out, _tc); + _any.write_value(_out); + + } + + /** + Unmarshal method for the Any class, decodes an Any object from the stream. + @return Any, read from the input stream + **/ + public static Any unmarshal(com.ericsson.otp.erlang.OtpInputStream _in) + throws java.lang.Exception { + + Any _value; + TypeCode _tc; + + _in.read_tuple_head(); + + if ((_in.read_atom()).compareTo("any") != 0) + throw new java.lang.Exception(""); + + _tc = TypeCode.unmarshal(_in); + _value = new Any(); + _value.read_value(_in,_tc); + + return _value; + } + +} + + + diff --git a/lib/ic/java_src/com/ericsson/otp/ic/AnyHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/AnyHolder.java new file mode 100644 index 0000000000..fa28bd0e5d --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/AnyHolder.java @@ -0,0 +1,60 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + +Holder class for Any, according to OMG-IDL java mapping. +<p>Instead for _write,_read methods, the methods _marshal respective +_unmarshal are used to denote the implementation difference. + +**/ + +final public class AnyHolder { + + // Instance variables + public Any value; + + // Constructors + public AnyHolder() {} + + public AnyHolder(Any initial) { + value = initial; + } + + // Methods + /** + Marshal method for the Any class, encodes the Any object to the output stream. + **/ + public void _marshal(com.ericsson.otp.erlang.OtpOutputStream out) + throws java.lang.Exception { + AnyHelper.marshal(out, value); + } + + /** + Unmarshal method for the Any class, decodes an Any object from the stream and + assigns it to the Holder value. + **/ + public void _unmarshal(com.ericsson.otp.erlang.OtpInputStream in) + throws java.lang.Exception { + value = AnyHelper.unmarshal(in); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/BooleanHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/BooleanHolder.java new file mode 100644 index 0000000000..5e91ae81af --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/BooleanHolder.java @@ -0,0 +1,62 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * A Holder class for IDL's out/inout argument passing modes for boolean + * + */ +package com.ericsson.otp.ic; + +/** + +Holder class for Boolean, according to OMG-IDL java mapping. + +**/ + + +final public class BooleanHolder implements Holder { + public boolean value; + + public BooleanHolder() {} + + public BooleanHolder(boolean initial) { + value = initial; + } + + /* Extra methods not in standard. */ + /** + Comparisson method for Booleans. + @return true if the input object equals the current object, false otherwize + **/ + public boolean equals( Object obj ) { + if( obj instanceof Boolean ) + return ( value == ((Boolean)obj).booleanValue()); + else + return false; + } + + /** + Comparisson method for Booleans. + @return true if the input boolean value equals the value of the current object, false otherwize + **/ + public boolean equals( boolean b ) { + return ( value == b ); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/ByteHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/ByteHolder.java new file mode 100644 index 0000000000..cd70573ab4 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/ByteHolder.java @@ -0,0 +1,61 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * A Holder class for IDL's out/inout argument passing modes for byte + * + */ +package com.ericsson.otp.ic; + +/** + +Holder class for Byte, according to OMG-IDL java mapping. + +**/ + +final public class ByteHolder implements Holder { + public byte value; + + public ByteHolder() {} + + public ByteHolder(byte initial) { + value = initial; + } + + /* Extra methods not in standard. */ + /** + Comparisson method for Bytes. + @return true if the input object equals the current object, false otherwize + **/ + public boolean equals( Object obj ) { + if( obj instanceof Byte ) + return ( value == ((Byte)obj).byteValue()); + else + return false; + } + + /** + Comparisson method for Byte. + @return true if the input boolean value equals the value of the current object, false otherwize + **/ + public boolean equals( byte b ) { + return ( value == b); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/CharHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/CharHolder.java new file mode 100644 index 0000000000..6005269a38 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/CharHolder.java @@ -0,0 +1,63 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * A Holder class for IDL's out/inout argument passing modes for char + * + */ +package com.ericsson.otp.ic; + + +/** + +Holder class for Char, according to OMG-IDL java mapping. + +**/ + + +final public class CharHolder implements Holder { + public char value; + + public CharHolder() {} + + public CharHolder(char initial) { + value = initial; + } + + /* Extra methods not in standard. */ + /** + Comparisson method for Chars. + @return true if the input object equals the current object, false otherwize + **/ + public boolean equals( Object obj ) { + if( obj instanceof Character ) + return ( value == ((Character)obj).charValue()); + else + return false; + } + + /** + Comparisson method for Chars. + @return true if the input char value equals the value of the current object, false otherwize + **/ + public boolean equals( char c ) { + return ( value == c); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/DoubleHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/DoubleHolder.java new file mode 100644 index 0000000000..d0da72cc2c --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/DoubleHolder.java @@ -0,0 +1,61 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * A Holder class for IDL's out/inout argument passing modes for double + * + */ +package com.ericsson.otp.ic; + +/** + +Holder class for Double, according to OMG-IDL java mapping. + +**/ + +final public class DoubleHolder implements Holder { + public double value; + + public DoubleHolder() {} + + public DoubleHolder(double initial) { + value = initial; + } + + /* Extra methods not in standard. */ + /** + Comparisson method for Doubles. + @return true if the input object equals the current object, false otherwize + **/ + public boolean equals( Object obj ) { + if( obj instanceof Double ) + return ( value == ((Double)obj).doubleValue()); + else + return false; + } + + /** + Comparisson method for Doubles. + @return true if the input double value equals the value of the current object, false otherwize + **/ + public boolean equals( double d ) { + return ( value == d); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/Environment.java b/lib/ic/java_src/com/ericsson/otp/ic/Environment.java new file mode 100644 index 0000000000..f0c66f0726 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/Environment.java @@ -0,0 +1,475 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * The Environment class for Java IDL + * + */ +package com.ericsson.otp.ic; + +/** + + The Environment class handles communication + setup and stub state. The methods of this class + are specially designed for the generated stubs. + This class must be used when designing asynchronous + message passing. + + **/ + + +public class Environment { + + // Private variables + private com.ericsson.otp.erlang.OtpSelf self; + private com.ericsson.otp.erlang.OtpPeer peer; + private java.lang.Object server; + private java.lang.String cookie; + private com.ericsson.otp.erlang.OtpConnection connection; + private com.ericsson.otp.erlang.OtpErlangRef send_ref; /* Client side send reference */ + private com.ericsson.otp.erlang.OtpErlangRef receive_ref; /* Client side received reference */ + private com.ericsson.otp.erlang.OtpErlangPid clientP; + private com.ericsson.otp.erlang.OtpErlangPid serverP; + private com.ericsson.otp.erlang.OtpOutputStream os; /* Output stream */ + private com.ericsson.otp.erlang.OtpInputStream is; /* Input stream */ + private boolean stopped; + + // Private variables used by server only + private int tag; + private java.lang.String operation; + private java.lang.String type; + private com.ericsson.otp.erlang.OtpErlangRef ref; /* Server side client reference */ + private com.ericsson.otp.erlang.OtpErlangPid caller; /* Server side client pid */ + + // Tags to distiguish client / server environments + private boolean clientT; + private boolean serverT; + + + /** + Client stub side constructor. + **/ + public Environment(com.ericsson.otp.erlang.OtpSelf _Self, + com.ericsson.otp.erlang.OtpPeer _Peer, + java.lang.Object _Server) throws java.lang.Exception { + + init(); + clientT = true; + self = _Self; + peer = _Peer; + server = _Server; + os = new com.ericsson.otp.erlang.OtpOutputStream(); + } + + + /** + Client stub side constructor. + **/ + public Environment(java.lang.String _SelfNode, + java.lang.String _PeerNode, + java.lang.String _Cookie, + java.lang.Object _Server) throws java.lang.Exception { + + init(); + clientT = true; + self = new com.ericsson.otp.erlang.OtpSelf(_SelfNode, _Cookie); + peer = new com.ericsson.otp.erlang.OtpPeer(_PeerNode); + cookie = _Cookie; + server = _Server; + os = new com.ericsson.otp.erlang.OtpOutputStream(); + } + + + /** + Client stub side constructor. + **/ + public Environment(com.ericsson.otp.erlang.OtpConnection _connection, + java.lang.Object _Server) throws java.lang.Exception { + + init(); + clientT = true; + self = _connection.self(); + peer = _connection.peer(); + connection = _connection; + server = _Server; + os = new com.ericsson.otp.erlang.OtpOutputStream(); + } + + + /** + Server skeleton side constructor. + **/ + public Environment() throws java.lang.Exception { + + init(); + serverT = true; + stopped = false; + os = new com.ericsson.otp.erlang.OtpOutputStream(); + + } + + + /* Communication toolbox */ + + /** + Client stub side connector. + **/ + public void connect() throws java.lang.Exception { + + if (connection == null) + connection = self.connect(peer); + + clientP = new com.ericsson.otp.erlang.OtpErlangPid(self); /* This is not perfect */ + send_ref = new com.ericsson.otp.erlang.OtpErlangRef(self); + + } + + /** + Reconnects a client by closing existing connection + and connecting. + **/ + public void reconnect() throws java.lang.Exception { + + if (connection.isConnected()) + connection.close(); + + connection = self.connect(peer); + + } + + /** + Closes the established connection. + **/ + public void disconnect() { + + connection.close(); + + } + + + /** + Client side message sender. + **/ + public void send() throws java.lang.Exception { + + if (server instanceof java.lang.String) + connection.sendBuf((java.lang.String)server, os); + else + connection.sendBuf((com.ericsson.otp.erlang.OtpErlangPid)server, os); + + } + + + /** + Client message receiver. + **/ + public void receive() throws java.lang.Exception { + + is = connection.receiveBuf(); + + if (clientT) { // If client, decode message reference too + is.read_tuple_head(); + receive_ref = is.read_ref(); + } + } + + + /** + Universal message receiver. + **/ + public void receive(com.ericsson.otp.erlang.OtpConnection _connection) throws java.lang.Exception { + + is = _connection.receiveBuf(); + + if (clientT) { // If client, decode message reference too + is.read_tuple_head(); + receive_ref = is.read_ref(); + } + } + + + /* Accessors */ + + /** + Server RegName/OtpErlangPid accessor. + Used to access the server Reg/Pid, which + initiated the connection. + @return java.lang.Object, the server for the active OtpConnection. + **/ + public java.lang.Object server() { + + return server; + + } + + /** + Caller identity accessor. Used by a server stub to access the + caller identity of the received message. + @return OtpErlangPid, the caller identity. + **/ + public com.ericsson.otp.erlang.OtpErlangPid caller_pid() { + + return clientP; + + } + + + /** + Received message reference accessor. Used by a server stub to access the + reference of the received message. + @return OtpErlangRef, the reference of the received message. + **/ + public com.ericsson.otp.erlang.OtpErlangRef received_ref() { + + return receive_ref; + + } + + + /* Encoders */ + + /** + Client Pid Encoder. Used by a server stub to encode the + enclosed client process identity. + **/ + public void write_client_pid() { + + os.write_pid(clientP.node(),clientP.id(),clientP.serial(),clientP.creation()); + + } + + /** + Client Ref Encoder. Used by a server stub to encode the + enclosed client message reference. + **/ + public void write_client_ref() { + + os.write_ref(send_ref.node(),send_ref.id(),send_ref.creation()); + + } + + + + /* Field access functions */ + + /** + Output Stream accessor. + @return OtpOutputStream, the enclosed output stream. + **/ + public com.ericsson.otp.erlang.OtpOutputStream getOs() { + return os; + } + + /** + Input Stream accessor. + @return OtpInputStream, the enclosed input stream. + **/ + public com.ericsson.otp.erlang.OtpInputStream getIs() { + return is; + } + + /** + Server skeleton side client (caller) pid accessor. + @return OtpErlangPid, the caller process identity. + **/ + public com.ericsson.otp.erlang.OtpErlangPid getScaller() { + return caller; + } + + /** + Server skeleton side client call reference accessor. + @return OtpErlangRef, the latest call message reference. + **/ + public com.ericsson.otp.erlang.OtpErlangRef getSref() { + return ref; + } + + + + /* Field modifiers */ + + + + /* Decoders */ + + /** + Decodes the message head from existing stream. + Assignes message data to private variables of the Environment Object. + **/ + public void uHead() throws java.lang.Exception { + uHead(is); + } + + /** + Decodes the message head and writes over input stream. + Assignes message data to private variables of the Environment Object. + **/ + public void uHead(com.ericsson.otp.erlang.OtpInputStream _is) throws java.lang.Exception { + + is = _is; + is.read_tuple_head(); + type = is.read_atom(); + + if (type.equals("$gen_call")) { // Call type operation + is.read_tuple_head(); + caller = is.read_pid(); + ref = is.read_ref(); + tag = is.peek(); + + switch (tag) { + case com.ericsson.otp.erlang.OtpExternal.atomTag: + operation = is.read_atom(); + break; + default: + is.read_tuple_head(); + operation = is.read_atom(); + } + } else { // Cast type operation + tag = is.peek(); + switch (tag) { + case com.ericsson.otp.erlang.OtpExternal.atomTag: + operation = is.read_atom(); + break; + default: + is.read_tuple_head(); + operation = is.read_atom(); + } + } + } + + /** + Operation label accessor. + @return int, the label hash value. + **/ + public int uLabel(java.util.Dictionary _operations) { + + java.lang.Integer __label = + (java.lang.Integer) _operations.get(operation); + + if(__label == null) + return -1; + + return __label.intValue(); + } + + + + /* Controllers */ + + /** + Operation controller. + @return boolean, true if the operation variable found in Environment class + is supported in the input operation dictionary, false otherwize. + **/ + public boolean validOp(java.util.Dictionary _operations) { + + if((_operations.get(operation)) == null) + return false; + + return true; + } + + + /** + Server stop request controller. + @return boolean, true if there is a client request for the server + to be stopped, false otherwize. + **/ + public boolean isStopped() { + return stopped; + }; + + + + /* Destroy functions */ + + /* + Creates and sends a stop message. + Called by client stub to terminate the server. + */ + public void client_stop_server() + throws java.lang.Exception { + + // Message header assembly + os.reset(); + os.write_tuple_head(2); + os.write_atom("$gen_cast"); + + os.write_atom("stop"); + + send(); + + } + + /* + Sets the stop flag for the server. + Called by server skeleton when stop message is received. + */ + public void server_stop_server() { + + // Note at server is dead ! + stopped = true; + } + + + /* Private methods */ + + /** + Private variable initialization. + **/ + public void init() { + + clientT = false; + serverT = false; + stopped = false; + self = null; + peer = null; + server = null; + cookie = null; + connection = null; + clientP = null; + serverP = null; + send_ref = null; + receive_ref = null; + os = null; + is = null; + + tag = -1; + operation = null; + type = null; + + }; + +} + + + + + + + + + + + + + + + + diff --git a/lib/ic/java_src/com/ericsson/otp/ic/FloatHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/FloatHolder.java new file mode 100644 index 0000000000..4904fd5fc1 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/FloatHolder.java @@ -0,0 +1,62 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * A Holder class for IDL's out/inout argument passing modes for float + * + */ +package com.ericsson.otp.ic; + +/** + +Holder class for Float, according to OMG-IDL java mapping. + +**/ + + +final public class FloatHolder implements Holder { + public float value; + + public FloatHolder() {} + + public FloatHolder(float initial) { + value = initial; + } + + /* Extra methods not in standard. */ + /** + Comparisson method for Floats. + @return true if the input object equals the current object, false otherwize + **/ + public boolean equals( Object obj ) { + if( obj instanceof Float ) + return ( value == ((Float)obj).floatValue()); + else + return false; + } + + /** + Comparisson method for Floats. + @return true if the input float value equals the value of the current object, false otherwize + **/ + public boolean equals( float f ) { + return ( value == f); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/Holder.java b/lib/ic/java_src/com/ericsson/otp/ic/Holder.java new file mode 100644 index 0000000000..a00efcef68 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/Holder.java @@ -0,0 +1,33 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * Holder interface class. +*/ +package com.ericsson.otp.ic; +import java.io.Serializable; + +/** + Holder interface class. + **/ + +public interface Holder extends Serializable +{ + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/IntHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/IntHolder.java new file mode 100644 index 0000000000..1037af4f08 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/IntHolder.java @@ -0,0 +1,62 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * A Holder class for IDL's out/inout argument passing modes for long + * + */ +package com.ericsson.otp.ic; + +/** + +Holder class for Int, according to OMG-IDL java mapping. + +**/ + +final public class IntHolder implements Holder { + public int value; + + public IntHolder() {} + + public IntHolder(int initial) { + value = initial; + } + + /* Extra methods not in standard. */ + + /** + Comparisson method for Ints. + @return true if the input object equals the current object, false otherwize + **/ + public boolean equals( Object obj ) { + if( obj instanceof Integer ) + return ( value == ((Integer)obj).intValue()); + else + return false; + } + + /** + Comparisson method for Ints. + @return true if the input int value equals the value of the current object, false otherwize + **/ + public boolean equals( int i ) { + return ( value == i); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/LongHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/LongHolder.java new file mode 100644 index 0000000000..8fa4430018 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/LongHolder.java @@ -0,0 +1,60 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * A Holder class for IDL's out/inout argument passing modes for long + * + */ +package com.ericsson.otp.ic; + +/** + +Holder class for Long, used by the Term class. + +**/ + +final public class LongHolder implements Holder { + public long value; + + public LongHolder() {} + + public LongHolder(long initial) { + value = initial; + } + + /** + Comparisson method for Longs. + @return true if the input object equals the current object, false otherwize + **/ + public boolean equals( Object obj ) { + if( obj instanceof Long ) + return ( value == ((Long)obj).longValue()); + else + return false; + } + + /** + Comparisson method for Longs. + @return true if the input long value equals the value of the current object, false otherwize + **/ + public boolean equals( long l ) { + return ( value == l); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/Makefile b/lib/ic/java_src/com/ericsson/otp/ic/Makefile new file mode 100644 index 0000000000..f730749ccb --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/Makefile @@ -0,0 +1,118 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1999-2009. All Rights Reserved. +# +# 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 online 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. +# +# %CopyrightEnd% +# +# +include $(ERL_TOP)/make/target.mk + + +JAVA_DEST_ROOT = $(ERL_TOP)/lib/ic/priv/ +JAVA_SRC_ROOT = $(ERL_TOP)/lib/ic/java_src/ +JAVA_CLASS_SUBDIR = com/ericsson/otp/ic/ +JAVA_INCL_ROOT = $(ERL_TOP)/lib/jinterface/priv/ + +include $(ERL_TOP)/make/$(TARGET)/otp.mk + +# ---------------------------------------------------- +# Application version +# ---------------------------------------------------- +include $(ERL_TOP)/lib/ic/vsn.mk +VSN=$(IC_VSN) + +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/lib/ic-$(VSN) + +# +# JAVA macros +# +JAVA_CLASSES = \ + Holder \ + BooleanHolder \ + ByteHolder \ + CharHolder \ + DoubleHolder \ + FloatHolder \ + IntHolder \ + LongHolder \ + ShortHolder \ + StringHolder \ + Environment \ + Any \ + AnyHelper \ + AnyHolder \ + TypeCode \ + TCKind \ + Pid \ + PidHolder \ + PidHelper \ + Ref \ + RefHolder \ + RefHelper \ + Port \ + PortHolder \ + PortHelper \ + Term \ + TermHolder \ + TermHelper + +TARGET_FILES= $(JAVA_CLASSES:%=$(JAVA_DEST_ROOT)$(JAVA_CLASS_SUBDIR)%.class) +JAVA_FILES= $(JAVA_CLASSES:%=%.java) + +JARFILE= ic.jar + +# ---------------------------------------------------- +# Programs and Flags +# ---------------------------------------------------- +CLASSPATH = $(JAVA_SRC_ROOT):$(JAVA_INCL_ROOT) + +JAR= jar + +JAVADOCFLAGS=-d $(DOCDIR) +JAVAFLAGS=-d $(JAVA_DEST_ROOT) +JARFLAGS= -cvf + +JAVA_OPTIONS = + +# ---------------------------------------------------- +# Make Rules +# ---------------------------------------------------- + +debug opt: $(JAVA_DEST_ROOT)$(JARFILE) + +$(JAVA_DEST_ROOT)$(JARFILE): $(TARGET_FILES) + @(cd $(JAVA_DEST_ROOT) ; $(JAR) $(JARFLAGS) $(JARFILE) $(JAVA_CLASS_SUBDIR)) + +clean: + rm -f $(TARGET_FILES) *~ + +docs: + +# ---------------------------------------------------- +# Release Targets +# ---------------------------------------------------- +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: opt + $(INSTALL_DIR) $(RELSYSDIR)/java_src/com/ericsson/otp/ic + $(INSTALL_DATA) $(JAVA_FILES) $(RELSYSDIR)/java_src/com/ericsson/otp/ic + $(INSTALL_DIR) $(RELSYSDIR)/priv + $(INSTALL_DATA) $(JAVA_DEST_ROOT)$(JARFILE) $(RELSYSDIR)/priv + +release_docs_spec: + diff --git a/lib/ic/java_src/com/ericsson/otp/ic/Pid.java b/lib/ic/java_src/com/ericsson/otp/ic/Pid.java new file mode 100644 index 0000000000..8d0608bf58 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/Pid.java @@ -0,0 +1,55 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + + +/** + +Pid class mapps the built-in erlang type pid, a process identity. + +**/ + + +final public class Pid extends com.ericsson.otp.erlang.OtpErlangPid { + + public Pid(com.ericsson.otp.erlang.OtpSelf self) { + super(self); + } + + public Pid(com.ericsson.otp.erlang.OtpInputStream buf) + throws com.ericsson.otp.erlang.OtpErlangDecodeException { + super(buf); + } + + + public Pid(String node, int id, int serial, int creation) { + super(node,id,serial,creation); + } + + + /** + Comparisson method for Pid. + @return true if the input Pid value equals the value of the current object, false otherwize + **/ + public boolean equal(Pid _pid) { + return super.equals(_pid); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/PidHelper.java b/lib/ic/java_src/com/ericsson/otp/ic/PidHelper.java new file mode 100644 index 0000000000..a51ff2fe80 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/PidHelper.java @@ -0,0 +1,144 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + Helper class for Pid. + **/ + +public class PidHelper { + + // constructors + private PidHelper() {} + + // methods + /** + Marshal method for the Pid class, encodes the Pid object to the output stream. + **/ + public static void marshal(com.ericsson.otp.erlang.OtpOutputStream _out, Pid _value) + throws java.lang.Exception { + + _out.write_pid(_value.node(),_value.id(),_value.serial(),_value.creation()); + } + + /** + Unmarshal method for the Pid class, decodes a Pid object from the stream. + @return Pid, read from the input stream + **/ + public static Pid unmarshal(com.ericsson.otp.erlang.OtpInputStream _in) + throws java.lang.Exception { + + // Double job is done here, there should be + // a function returning a Pid instead of an + // OtpErlangPid + com.ericsson.otp.erlang.OtpErlangPid oep = _in.read_pid(); + + return new Pid(oep.node(),oep.id(),oep.serial(),oep.creation()); + } + + /** + Standard method that returns the interface repository identity. + @return String containing the interface repository identity of Pid + **/ + public static String id() { + return "IDL:com/ericsson/otp/ic/Pid:1.0"; + } + + /** + Standard method that returns the Pid class name. + @return String containing the class name of Pid + **/ + public static String name() { + return "Pid"; + } + + /** + Holds the TypeCode + **/ + private static com.ericsson.otp.ic.TypeCode _tc; + + /** + Standard TypeCode accessor method. + @return the TypeCode for Pid + **/ + synchronized public static com.ericsson.otp.ic.TypeCode type() { + + if (_tc != null) + return _tc; + + com.ericsson.otp.ic.TypeCode _tc0 = + new com.ericsson.otp.ic.TypeCode(); + _tc0.kind(com.ericsson.otp.ic.TCKind.tk_struct); + _tc0.id("IDL:com/ericsson/otp/ic/Pid:1.0"); + _tc0.name("Pid"); + _tc0.member_count(4); + _tc0.member_name(0,"node"); + com.ericsson.otp.ic.TypeCode _tc1 = + new com.ericsson.otp.ic.TypeCode(); + _tc1.kind(com.ericsson.otp.ic.TCKind.tk_string); + _tc1.length(256); + _tc0.member_type(0,_tc1); + _tc0.member_name(1,"num"); + com.ericsson.otp.ic.TypeCode _tc2 = + new com.ericsson.otp.ic.TypeCode(); + _tc2.kind(com.ericsson.otp.ic.TCKind.tk_ulong); + _tc0.member_type(1,_tc2); + _tc0.member_name(2,"serial"); + com.ericsson.otp.ic.TypeCode _tc3 = + new com.ericsson.otp.ic.TypeCode(); + _tc3.kind(com.ericsson.otp.ic.TCKind.tk_ulong); + _tc0.member_type(2,_tc3); + _tc0.member_name(3,"creation"); + com.ericsson.otp.ic.TypeCode _tc4 = + new com.ericsson.otp.ic.TypeCode(); + _tc4.kind(com.ericsson.otp.ic.TCKind.tk_ulong); + _tc0.member_type(3,_tc4); + + _tc = _tc0; + + return _tc0; + } + + + /** + Standard method for inserting a Pid to an Any. + **/ + public static void insert(com.ericsson.otp.ic.Any _any, Pid _this) + throws java.lang.Exception { + + com.ericsson.otp.erlang.OtpOutputStream _os = + new com.ericsson.otp.erlang.OtpOutputStream(); + + _any.type(type()); + marshal(_os, _this); + _any.insert_Streamable(_os); + } + + /** + Standard method for extracting a Pid from an Any. + @return Pid, the value found in an Any contained stream. + **/ + public static Pid extract(com.ericsson.otp.ic.Any _any) + throws java.lang.Exception { + + return unmarshal(_any.extract_Streamable()); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/PidHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/PidHolder.java new file mode 100644 index 0000000000..9e42385dec --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/PidHolder.java @@ -0,0 +1,54 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + Holder class for Pid. + **/ + +final public class PidHolder { + + /** + Pid instance variable. + **/ + public Pid value; + + // constructors + public PidHolder() {} + public PidHolder(Pid initial) { + value = initial; + } + + // methods + /** + Marshal method for the PidHolder class, encodes the Pid object value to the output stream. + **/ + public void _marshal(com.ericsson.otp.erlang.OtpOutputStream out) throws java.lang.Exception { + PidHelper.marshal(out, value); + } + + /** + Unmarshal method for the PidHolder class, decodes a Pid object from the output stream + and assigns it to the Holder value field. + **/ + public void _unmarshal(com.ericsson.otp.erlang.OtpInputStream in) throws java.lang.Exception { + value = PidHelper.unmarshal(in); + } +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/Port.java b/lib/ic/java_src/com/ericsson/otp/ic/Port.java new file mode 100644 index 0000000000..e830365d5c --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/Port.java @@ -0,0 +1,48 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + +Port class mapps the built-in erlang type port, a process port. + +**/ + +final public class Port extends com.ericsson.otp.erlang.OtpErlangPort { + + public Port(com.ericsson.otp.erlang.OtpInputStream buf) + throws com.ericsson.otp.erlang.OtpErlangDecodeException { + super(buf); + } + + public Port(String node, int id, int creation) { + super(node,id,creation); + } + + /** + Comparisson method for Port. + @return true if the input Port value equals the value of the current object, false otherwize + **/ + public boolean equal(Port _port) { + return super.equals(_port); + } + + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/PortHelper.java b/lib/ic/java_src/com/ericsson/otp/ic/PortHelper.java new file mode 100644 index 0000000000..26c79713e0 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/PortHelper.java @@ -0,0 +1,140 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + Helper class for Port. + **/ + +public class PortHelper { + + // constructors + private PortHelper() {} + + // methods + + /** + Marshal method for the Port class, encodes the Port object to the output stream. + **/ + public static void marshal(com.ericsson.otp.erlang.OtpOutputStream _out, Port _value) + throws java.lang.Exception { + + _out.write_port(_value.node(),_value.id(),_value.creation()); + } + + /** + Unmarshal method for the Port class, decodes a Port object from the stream. + @return Port, read from the input stream + **/ + public static Port unmarshal(com.ericsson.otp.erlang.OtpInputStream _in) + throws java.lang.Exception { + + // Double job is done here, there should be + // a function returning a Port instead of an + // OtpErlangPort + com.ericsson.otp.erlang.OtpErlangPort oep = _in.read_port(); + + return new Port(oep.node(),oep.id(),oep.creation()); + } + + /** + Standard method that returns the interface repository identity. + @return String containing the interface repository identity of Port + **/ + public static String id() { + return "IDL:com/ericsson/otp/ic/Port:1.0"; + } + + /** + Standard method that returns the Port class name. + @return String containing the class name of Port + **/ + public static String name() { + return "Port"; + } + + /** + Holds the TypeCode + **/ + private static com.ericsson.otp.ic.TypeCode _tc; + + /** + Standard TypeCode accessor method. + @return the TypeCode for Port + **/ + synchronized public static com.ericsson.otp.ic.TypeCode type() { + + if (_tc != null) + return _tc; + + com.ericsson.otp.ic.TypeCode _tc0 = + new com.ericsson.otp.ic.TypeCode(); + _tc0.kind(com.ericsson.otp.ic.TCKind.tk_struct); + _tc0.id("IDL:com/ericsson/otp/ic/Port:1.0"); + _tc0.name("Port"); + _tc0.member_count(3); + _tc0.member_name(0,"node"); + com.ericsson.otp.ic.TypeCode _tc1 = + new com.ericsson.otp.ic.TypeCode(); + _tc1.kind(com.ericsson.otp.ic.TCKind.tk_string); + _tc1.length(256); + _tc0.member_type(0,_tc1); + _tc0.member_name(1,"id"); + com.ericsson.otp.ic.TypeCode _tc2 = + new com.ericsson.otp.ic.TypeCode(); + _tc2.kind(com.ericsson.otp.ic.TCKind.tk_ulong); + _tc0.member_type(1,_tc2); + _tc0.member_name(2,"creation"); + com.ericsson.otp.ic.TypeCode _tc3 = + new com.ericsson.otp.ic.TypeCode(); + _tc3.kind(com.ericsson.otp.ic.TCKind.tk_ulong); + _tc0.member_type(2,_tc3); + + _tc = _tc0; + + return _tc0; + } + + + /** + Standard method for inserting a Port to an Any. + **/ + public static void insert(com.ericsson.otp.ic.Any _any, Port _this) + throws java.lang.Exception { + + com.ericsson.otp.erlang.OtpOutputStream _os = + new com.ericsson.otp.erlang.OtpOutputStream(); + + _any.type(type()); + marshal(_os, _this); + _any.insert_Streamable(_os); + } + + /** + Standard method for extracting a Port from an Any. + @return Port, the value found in an Any contained stream. + **/ + public static Port extract(com.ericsson.otp.ic.Any _any) + throws java.lang.Exception { + + return unmarshal(_any.extract_Streamable()); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/PortHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/PortHolder.java new file mode 100644 index 0000000000..80744f223f --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/PortHolder.java @@ -0,0 +1,56 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + Holder class for Port. + **/ + +final public class PortHolder { + + /** + Port instance variable. + **/ + public Port value; + + // constructors + public PortHolder() {} + public PortHolder(Port initial) { + value = initial; + } + + // methods + /** + Marshal method for the PortHolder class, encodes the Port object value to the output stream. + **/ + public void _marshal(com.ericsson.otp.erlang.OtpOutputStream out) + throws java.lang.Exception { + PortHelper.marshal(out, value); + } + + /** + Unmarshal method for the PortHolder class, decodes a Port object from the output stream + and assigns it to the Holder value field. + **/ + public void _unmarshal(com.ericsson.otp.erlang.OtpInputStream in) + throws java.lang.Exception { + value = PortHelper.unmarshal(in); + } +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/Ref.java b/lib/ic/java_src/com/ericsson/otp/ic/Ref.java new file mode 100644 index 0000000000..0a3876989e --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/Ref.java @@ -0,0 +1,60 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + +Ref class mapps the built-in erlang type Ref, a message reference. + +**/ + +final public class Ref extends com.ericsson.otp.erlang.OtpErlangRef { + + public Ref(com.ericsson.otp.erlang.OtpSelf self) { + super(self); + } + + + public Ref(com.ericsson.otp.erlang.OtpInputStream buf) + throws com.ericsson.otp.erlang.OtpErlangDecodeException { + super(buf); + } + + /** + Old style Ref costructor. Costructs an Ref that coresponds to the + old erlang Ref type. + **/ + public Ref(String node, int id, int creation) { + super(node,id,creation); + } + + public Ref(String node, int[] ids, int creation) { + super(node,ids,creation); + } + + /** + Comparisson method for Ref. + @return true if the input Ref value equals the value of the current object, false otherwize + **/ + public boolean equal(Ref _ref) { + return super.equals(_ref); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/RefHelper.java b/lib/ic/java_src/com/ericsson/otp/ic/RefHelper.java new file mode 100644 index 0000000000..a58dec7905 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/RefHelper.java @@ -0,0 +1,141 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + Helper class for Ref. + **/ + +public class RefHelper { + + // constructors + private RefHelper() {} + + // methods + /** + Marshal method for the Ref class, encodes the Ref object to the output stream. + **/ + public static void marshal(com.ericsson.otp.erlang.OtpOutputStream _out, Ref _value) + throws java.lang.Exception { + + _out.write_ref(_value.node(),_value.id(),_value.creation()); + } + + /** + Unmarshal method for the Ref class, decodes a Ref object from the stream. + @return Ref, read from the input stream + **/ + public static Ref unmarshal(com.ericsson.otp.erlang.OtpInputStream _in) + throws java.lang.Exception { + + // Double job is done here, there should be + // a function returning a Ref instead of an + // OtpErlangRef + com.ericsson.otp.erlang.OtpErlangRef oer = _in.read_ref(); + + if (oer.isNewRef()) + return new Ref(oer.node(),oer.ids(),oer.creation()); + else + return new Ref(oer.node(),oer.id(),oer.creation()); + } + + /** + Standard method that returns the interface repository identity. + @return String containing the interface repository identity of Ref + **/ + public static String id() { + return "IDL:com/ericsson/otp/ic/Ref:1.0"; + } + + /** + Standard method that returns the Ref class name. + @return String containing the class name of Ref + **/ + public static String name() { + return "Ref"; + } + + /** + Holds the TypeCode + **/ + private static com.ericsson.otp.ic.TypeCode _tc; + + /** + Standard TypeCode accessor method. + @return the TypeCode for Ref + **/ + synchronized public static com.ericsson.otp.ic.TypeCode type() { + + if (_tc != null) + return _tc; + + com.ericsson.otp.ic.TypeCode _tc0 = + new com.ericsson.otp.ic.TypeCode(); + _tc0.kind(com.ericsson.otp.ic.TCKind.tk_struct); + _tc0.id("IDL:com/ericsson/otp/ic/Ref:1.0"); + _tc0.name("Ref"); + _tc0.member_count(3); + _tc0.member_name(0,"node"); + com.ericsson.otp.ic.TypeCode _tc1 = + new com.ericsson.otp.ic.TypeCode(); + _tc1.kind(com.ericsson.otp.ic.TCKind.tk_string); + _tc1.length(256); + _tc0.member_type(0,_tc1); + _tc0.member_name(1,"id"); + com.ericsson.otp.ic.TypeCode _tc2 = + new com.ericsson.otp.ic.TypeCode(); + _tc2.kind(com.ericsson.otp.ic.TCKind.tk_ulong); + _tc0.member_type(1,_tc2); + _tc0.member_name(2,"creation"); + com.ericsson.otp.ic.TypeCode _tc3 = + new com.ericsson.otp.ic.TypeCode(); + _tc3.kind(com.ericsson.otp.ic.TCKind.tk_ulong); + _tc0.member_type(2,_tc3); + + _tc = _tc0; + + return _tc0; + } + + /** + Standard method for inserting a Ref to an Any. + **/ + public static void insert(com.ericsson.otp.ic.Any _any, Ref _this) + throws java.lang.Exception { + + com.ericsson.otp.erlang.OtpOutputStream _os = + new com.ericsson.otp.erlang.OtpOutputStream(); + + _any.type(type()); + marshal(_os, _this); + _any.insert_Streamable(_os); + } + + /** + Standard method for extracting a Ref from an Any. + @return Ref, the value found in an Any contained stream. + **/ + public static Ref extract(com.ericsson.otp.ic.Any _any) + throws java.lang.Exception { + + return unmarshal(_any.extract_Streamable()); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/RefHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/RefHolder.java new file mode 100644 index 0000000000..2dc3f4b42a --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/RefHolder.java @@ -0,0 +1,54 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + Holder class for Ref. + **/ + +final public class RefHolder { + + /** + Ref instance variable. + **/ + public Ref value; + + // constructors + public RefHolder() {} + public RefHolder(Ref initial) { + value = initial; + } + + // methods + /** + Marshal method for the RefHolder class, encodes the Ref object value to the output stream. + **/ + public void _marshal(com.ericsson.otp.erlang.OtpOutputStream out) throws java.lang.Exception { + RefHelper.marshal(out, value); + } + + /** + Unmarshal method for the RefHolder class, decodes a Ref object from the output stream + and assigns it to the Holder value field. + **/ + public void _unmarshal(com.ericsson.otp.erlang.OtpInputStream in) throws java.lang.Exception { + value = RefHelper.unmarshal(in); + } +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/ShortHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/ShortHolder.java new file mode 100644 index 0000000000..81fd7656b8 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/ShortHolder.java @@ -0,0 +1,61 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * A Holder class for IDL's out/inout argument passing modes for long + * + */ +package com.ericsson.otp.ic; + +/** + +Holder class for Short, according to OMG-IDL java mapping. + +**/ + +final public class ShortHolder implements Holder { + public short value; + + public ShortHolder() {} + + public ShortHolder(short initial) { + value = initial; + } + + /* Extra methods not in standard. */ + /** + Comparisson method for Shorts. + @return true if the input object equals the current object, false otherwize + **/ + public boolean equals( Object obj ) { + if( obj instanceof Short ) + return ( value == ((Short)obj).shortValue()); + else + return false; + } + + /** + Comparisson method for Shorts. + @return true if the input short value equals the value of the current object, false otherwize + **/ + public boolean equals( short s ) { + return ( value == s); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/StringHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/StringHolder.java new file mode 100644 index 0000000000..09b42dc270 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/StringHolder.java @@ -0,0 +1,62 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * A Holder class for IDL's out/inout argument passing modes for string + * + */ +package com.ericsson.otp.ic; + + +/** + +Holder class for String, according to OMG-IDL java mapping. + +**/ + +final public class StringHolder implements Holder { + public String value; + + public StringHolder() {} + + public StringHolder(String initial) { + value = initial; + } + + /* Extra methods not in standard. */ + /** + Comparisson method for Strings. + @return true if the input object equals the current object, false otherwize + **/ + public boolean equals( Object obj ) { + if( obj instanceof String ) + return ( value == obj); + else + return false; + } + + /** + Comparisson method for Strings. + @return true if the input String value equals the value of the current object, false otherwize + **/ + public boolean equals( String s ) { + return ( value == s); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/TCKind.java b/lib/ic/java_src/com/ericsson/otp/ic/TCKind.java new file mode 100644 index 0000000000..210f7f6216 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/TCKind.java @@ -0,0 +1,199 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * The TCKind class for Java IDL + * + */ +package com.ericsson.otp.ic; + +/** + The TCKind class is the implementation of the OMG-IDL enumerant type TCKind. + **/ + +final public class TCKind { + + // instance variables + public static final int _tk_null = 0, + _tk_void = 1, + _tk_short = 2, + _tk_long = 3, + _tk_ushort = 4, + _tk_ulong = 5, + _tk_float = 6, + _tk_double = 7, + _tk_boolean = 8, + _tk_char = 9, + _tk_octet = 10, + _tk_any = 11, + _tk_TypeCode = 12, + _tk_Principal = 13, + _tk_objref = 14, + _tk_struct = 15, + _tk_union = 16, + _tk_enum = 17, + _tk_string = 18, + _tk_sequence = 19, + _tk_array = 20, + _tk_alias = 21, + _tk_except = 22, + _tk_longlong = 23, + _tk_ulonglong = 24, + _tk_longdouble = 25, + _tk_wchar = 26, + _tk_wstring = 27, + _tk_fixed = 28, + _tk_atom = 20000, /* Used for union label default value only */ + _tk_pid = 20001, /* Used for special pid struct */ + _tk_port = 20002, /* Used for special port struct */ + _tk_ref = 20003, /* Used for special ref struct */ + _tk_term = 20004; /* Used for special term struct */ + + public static final TCKind tk_null = new TCKind(_tk_null); + public static final TCKind tk_void = new TCKind(_tk_void); + public static final TCKind tk_short = new TCKind(_tk_short); + public static final TCKind tk_long = new TCKind(_tk_long); + public static final TCKind tk_ushort = new TCKind(_tk_ushort); + public static final TCKind tk_ulong = new TCKind(_tk_ulong); + public static final TCKind tk_float = new TCKind(_tk_float); + public static final TCKind tk_double = new TCKind(_tk_double); + public static final TCKind tk_boolean = new TCKind(_tk_boolean); + public static final TCKind tk_char = new TCKind(_tk_char); + public static final TCKind tk_octet = new TCKind(_tk_octet); + public static final TCKind tk_any = new TCKind(_tk_any); + public static final TCKind tk_TypeCode = new TCKind(_tk_TypeCode); + public static final TCKind tk_Principal = new TCKind(_tk_Principal); + public static final TCKind tk_objref = new TCKind(_tk_objref); + public static final TCKind tk_struct = new TCKind(_tk_struct); + public static final TCKind tk_union = new TCKind(_tk_union); + public static final TCKind tk_enum = new TCKind(_tk_enum); + public static final TCKind tk_string = new TCKind(_tk_string); + public static final TCKind tk_sequence = new TCKind(_tk_sequence); + public static final TCKind tk_array = new TCKind(_tk_array); + public static final TCKind tk_alias = new TCKind(_tk_alias); + public static final TCKind tk_except = new TCKind(_tk_except); + public static final TCKind tk_longlong = new TCKind(_tk_longlong); + public static final TCKind tk_ulonglong = new TCKind(_tk_ulonglong); + public static final TCKind tk_longdouble = new TCKind(_tk_longdouble); + public static final TCKind tk_wchar = new TCKind(_tk_wchar); + public static final TCKind tk_wstring = new TCKind(_tk_wstring); + public static final TCKind tk_fixed = new TCKind(_tk_fixed); + protected static final TCKind tk_atom = new TCKind(_tk_atom); + protected static final TCKind tk_pid = new TCKind(_tk_pid); + protected static final TCKind tk_port = new TCKind(_tk_port); + protected static final TCKind tk_ref = new TCKind(_tk_ref); + protected static final TCKind tk_term = new TCKind(_tk_term); + private int _value; + + // constructors + private TCKind(int __value) { + _value = __value; + } + + // methods + + /** + Accessor method for the value of TCKind. + @return int, the value of TCKind object + **/ + public int value() { + return _value; + } + + /** + Translator method for TCKind. + Traslates the input integer value to a TCKind enumerant object. + @return TCKind, a TCKind object + **/ + public static final TCKind from_int(int __value) throws java.lang.Exception { + switch (__value) { + case _tk_null: + return tk_null; + case _tk_void: + return tk_void; + case _tk_short: + return tk_short; + case _tk_long: + return tk_long; + case _tk_ushort: + return tk_ushort; + case _tk_ulong: + return tk_ulong; + case _tk_float: + return tk_float; + case _tk_double: + return tk_double; + case _tk_boolean: + return tk_boolean; + case _tk_char: + return tk_char; + case _tk_octet: + return tk_octet; + case _tk_any: + return tk_any; + case _tk_TypeCode: + return tk_TypeCode; + case _tk_Principal: + return tk_Principal; + case _tk_objref: + return tk_objref; + case _tk_struct: + return tk_struct; + case _tk_union: + return tk_union; + case _tk_enum: + return tk_enum; + case _tk_string: + return tk_string; + case _tk_sequence: + return tk_sequence; + case _tk_array: + return tk_array; + case _tk_alias: + return tk_alias; + case _tk_except: + return tk_except; + case _tk_longlong: + return tk_longlong; + case _tk_ulonglong: + return tk_ulonglong; + case _tk_longdouble: + return tk_longdouble; + case _tk_wchar: + return tk_wchar; + case _tk_wstring: + return tk_wstring; + case _tk_fixed: + return tk_fixed; + case _tk_atom: + return tk_atom; + case _tk_pid: + return tk_pid; + case _tk_port: + return tk_port; + case _tk_ref: + return tk_ref; + case _tk_term: + return tk_term; + default: + throw new java.lang.Exception(""); + } + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/Term.java b/lib/ic/java_src/com/ericsson/otp/ic/Term.java new file mode 100644 index 0000000000..9219cb7038 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/Term.java @@ -0,0 +1,1109 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + +The Term class is intended to represent the erlang term generic type. +It extends the Any class and is basically used the same way as the Any class. +<p>The main difference between Term and Any is the use of guard methods +instead for TypeCode to determine the data included in the Term. +This actual when cannot determine a Term's value class returned at compile time. + +**/ + +final public class Term extends Any { + + // Primitive value holder + protected java.lang.String atomV; + protected long longV; + protected Pid PidV; + protected Ref RefV; + protected Port PortV; + protected com.ericsson.otp.erlang.OtpErlangObject ObjV; + protected int tag; + + /** + Tag accessor method + @return int, the tag of the Object that denotes the erlang external format tag + **/ + public int tag() { + return tag; + } + + /* Guards */ + + /** + Guard method + @return true if the Term is an OtpErlangAtom, false otherwize + **/ + public boolean isAtom() { + + if (ObjV == null) { + if (tag == com.ericsson.otp.erlang.OtpExternal.atomTag) + return true; + + return false; + } + + return (ObjV instanceof com.ericsson.otp.erlang.OtpErlangAtom) ; + } + + /** + Guard method + @return true if the Term is not an OtpErlangList nor an OtpErlangTuple, false otherwize + **/ + public boolean isConstant() { + if (isList()) + return false; + + if (isTuple()) + return false; + + return true; + } + + /** + Guard method + @return true if the Term is an OtpErlangFloat, false otherwize + **/ + public boolean isFloat() { + if (tag == com.ericsson.otp.erlang.OtpExternal.floatTag) + return true; + + return false; + } + + /** + Guard method + @return true if the Term is an OtpErlangInt, false otherwize + **/ + public boolean isInteger() { + switch(tag) { + case com.ericsson.otp.erlang.OtpExternal.smallIntTag: + case com.ericsson.otp.erlang.OtpExternal.intTag: + case com.ericsson.otp.erlang.OtpExternal.smallBigTag: + return true; + default: + return false; + } + } + + /** + Guard method + @return true if the Term is an OtpErlangList, false otherwize + **/ + public boolean isList() { + + if (ObjV == null) { + switch(tag) { + case com.ericsson.otp.erlang.OtpExternal.listTag: + case com.ericsson.otp.erlang.OtpExternal.stringTag: + case com.ericsson.otp.erlang.OtpExternal.nilTag: + return true; + default: + return false; + } + } + + if (ObjV instanceof com.ericsson.otp.erlang.OtpErlangList) + return true; + + if (ObjV instanceof com.ericsson.otp.erlang.OtpErlangString) + return true; + + return false; + } + + + /** + Guard method + @return true if the Term is an OtpErlangString, false otherwize + **/ + public boolean isString() { + + if (ObjV == null) { + switch(tag) { + case com.ericsson.otp.erlang.OtpExternal.stringTag: + case com.ericsson.otp.erlang.OtpExternal.nilTag: + return true; + default: + try { + stringV = extract_string(); + return true; + } catch (Exception e) { + return false; + } + } + } + + if (ObjV instanceof com.ericsson.otp.erlang.OtpErlangString) + return true; + + try { + stringV = extract_string(); + return true; + } catch (Exception e) { + return false; + } + } + + /** + Guard method + @return true if the Term is an OtpErlangInteger or an OtpErlangFloat, false otherwize + **/ + public boolean isNumber() { + switch(tag) { + case com.ericsson.otp.erlang.OtpExternal.smallIntTag: + case com.ericsson.otp.erlang.OtpExternal.intTag: + case com.ericsson.otp.erlang.OtpExternal.smallBigTag: + case com.ericsson.otp.erlang.OtpExternal.floatTag: + return true; + default : + return false; + } + } + + + /** + Guard method + @return true if the Term is an OtpErlangPid or Pid, false otherwize + **/ + public boolean isPid() { + + if (ObjV == null) { + if (tag == com.ericsson.otp.erlang.OtpExternal.pidTag) + return true; + + return false; + } + + return (ObjV instanceof com.ericsson.otp.erlang.OtpErlangPid) ; + } + + + /** + Guard method + @return true if the Term is an OtpErlangPort or Port, false otherwize + **/ + public boolean isPort() { + if (ObjV == null) { + if (tag == com.ericsson.otp.erlang.OtpExternal.portTag) + return true; + + return false; + } + + return (ObjV instanceof com.ericsson.otp.erlang.OtpErlangPort); + } + + + /** + Guard method + @return true if the Term is an OtpErlangRef, false otherwize + **/ + public boolean isReference() { + if (ObjV == null) { + switch(tag) { + case com.ericsson.otp.erlang.OtpExternal.refTag: + case com.ericsson.otp.erlang.OtpExternal.newRefTag: + return true; + default : + return false; + } + } + + return (ObjV instanceof com.ericsson.otp.erlang.OtpErlangRef) ; + } + + + /** + Guard method + @return true if the Term is an OtpErlangTuple, false otherwize + **/ + public boolean isTuple() { + if (ObjV == null) { + switch(tag) { + case com.ericsson.otp.erlang.OtpExternal.smallTupleTag: + case com.ericsson.otp.erlang.OtpExternal.largeTupleTag: + return true; + default : + return false; + } + } + + return (ObjV instanceof com.ericsson.otp.erlang.OtpErlangTuple); + } + + + /** + Guard method + @return true if the Term is an OtpErlangBinary, false otherwize + **/ + public boolean isBinary() { + if (ObjV == null) { + if (tag == com.ericsson.otp.erlang.OtpExternal.binTag) + return true; + + return false; + } + + return (ObjV instanceof com.ericsson.otp.erlang.OtpErlangBinary); + } + + + + + // Equal function + /** + Term comparison method + @return true if the input Term is equal to the object, false otherwize + **/ + public boolean equal(Term _any) { + + try { + + /* Pids */ + if ((PidV != null) && (_any.PidV != null)) + if (PidV.equal(_any.PidV)) + return true; + + /* Refs */ + if ((RefV != null) && (_any.RefV != null)) + if (RefV.equal(_any.RefV)) + return true; + + /* Ports */ + if ((PortV != null) && (_any.PortV != null)) + if (PortV.equals(_any.PortV)) + return true; + + /* strings */ + if ((stringV != null) && (_any.stringV != null)) + if (stringV.equals(_any.stringV)) + return true; + + /* atoms and booleans */ + if ((atomV != null) && (_any.atomV != null)) + if (atomV.equals(_any.atomV)) + return true; + + /* booleans */ + if (atomV != null) + if (_any.booleanV == Boolean.valueOf(atomV).booleanValue()) + return true; + + if (_any.atomV != null) + if (booleanV == Boolean.valueOf(_any.atomV).booleanValue()) + return true; + + /* integer types plus floating point types */ + double _ownNS = + longV+doubleV; + + double _othersNS = + _any.longV+_any.doubleV; + + if ((equal(_ownNS,_othersNS)) && + (!equal(_ownNS,0))) + return true; + + /* All together, 0 or false */ + if ((equal(_ownNS,_othersNS)) && + booleanV == _any.booleanV) + return true; + + + return false; + + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + Writes the value of Term to a stream + **/ + public void write_value(com.ericsson.otp.erlang.OtpOutputStream _os) + throws java.lang.Exception { + + if ((tcV == null) && (ObjV != null)) + _os.write_any(ObjV); // Type not generated by IC + + else { + + switch(tcV.kind().value()) { + + case TCKind._tk_octet : + case TCKind._tk_char : + case TCKind._tk_wchar : + case TCKind._tk_short : + case TCKind._tk_ushort : + case TCKind._tk_long : + case TCKind._tk_longlong : + case TCKind._tk_ulong : + case TCKind._tk_ulonglong : + _os.write_long(longV); + break; + + case TCKind._tk_float : + _os.write_double(doubleV); + break; + + case TCKind._tk_double : + _os.write_double(doubleV); + break; + + case TCKind._tk_boolean : + _os.write_boolean(booleanV); + break; + + case TCKind._tk_string : + case TCKind._tk_wstring : + _os.write_string(stringV); + break; + + case TCKind._tk_atom : + _os.write_atom(stringV); + break; + + case TCKind._tk_struct: + if (isPid()) + PidHelper.marshal(_os, PidV); + else { + if (isReference()) + RefHelper.marshal(_os, RefV); + else { + if (isPort()) + PortHelper.marshal(_os, PortV); + else + _os.write(os.toByteArray()); + } + } + break; + + case TCKind._tk_union: + case TCKind._tk_array: + case TCKind._tk_sequence: + case TCKind._tk_enum: + _os.write(os.toByteArray()); + break; + + case TCKind._tk_void : + _os.write_atom("ok"); + break; + + /* + * Not supported types + */ + default: + throw new java.lang.Exception("BAD KIND"); + } + } + } + + + + /* + * Insert and extract each primitive type + */ + + + /* short */ + + /** + Short value extractor method + @return short, the value of Term + **/ + public short extract_short() + throws java.lang.Exception { + + if (tcV == null) + return (short) longV; + + if (tcV.kind() == TCKind.tk_short) + return (short) longV; + + throw new java.lang.Exception(""); + } + + /** + Short value insertion method + **/ + public void insert_short(short s) { + longV = s; + tag = com.ericsson.otp.erlang.OtpExternal.intTag; + tcV = new TypeCode(TCKind.tk_short); + }; + + /** + Short value insertion method + **/ + public void insert_short(long l) { + longV = l; + tag = com.ericsson.otp.erlang.OtpExternal.intTag; + tcV = new TypeCode(TCKind.tk_short); + }; + + + /* long */ + + /** + Long value extractor method + @return int, the value of Term + **/ + public int extract_long() + throws java.lang.Exception { + + if (tcV == null) + return (int) longV; + + if (tcV.kind() == TCKind.tk_long) + return (int) longV; + + throw new java.lang.Exception(""); + } + + /** + Long value insertion method + **/ + public void insert_long(int i){ + longV = i; + tag = com.ericsson.otp.erlang.OtpExternal.intTag; + tcV = new TypeCode(TCKind.tk_long); + } + + /** + Long value insertion method + **/ + public void insert_long(long l){ + longV = l; + tag = com.ericsson.otp.erlang.OtpExternal.intTag; + tcV = new TypeCode(TCKind.tk_long); + } + + + /* longlong */ + + /** + Long Long value extractor method + @return long, the value of Term + **/ + public long extract_longlong() + throws java.lang.Exception { + + if (tcV == null) + return longV; + + if (tcV.kind() == TCKind.tk_longlong) + return longV; + + throw new java.lang.Exception(""); + } + + + /** + Long Long value insertion method + **/ + public void insert_longlong(long l){ + longV = l; + tag = com.ericsson.otp.erlang.OtpExternal.intTag; + tcV = new TypeCode(TCKind.tk_longlong); + } + + + /* ushort */ + + /** + Unsigned Short value extractor method + @return short, the value of Term + **/ + public short extract_ushort() + throws java.lang.Exception { + + if (tcV == null) + return (short) longV; + + if (tcV.kind() == TCKind.tk_ushort) + return (short) longV; + + throw new java.lang.Exception(""); + } + + /** + Unsigned Short value insertion method + **/ + public void insert_ushort(short s){ + longV = s; + tag = com.ericsson.otp.erlang.OtpExternal.intTag; + tcV = new TypeCode(TCKind.tk_ushort); + } + + /** + Unsigned Short value insertion method + **/ + public void insert_ushort(long l){ + longV = l; + tag = com.ericsson.otp.erlang.OtpExternal.intTag; + tcV = new TypeCode(TCKind.tk_ushort); + } + + + /* ulong */ + + /** + Unsigned Long value extractor method + @return int, the value of Term + **/ + public int extract_ulong() + throws java.lang.Exception{ + + if (tcV == null) + return (int) longV; + + if (tcV.kind() == TCKind.tk_ulong) + return (int) longV; + + throw new java.lang.Exception(""); + } + + /** + Unsigned Long value insertion method + **/ + public void insert_ulong(int i){ + longV = i; + tag = com.ericsson.otp.erlang.OtpExternal.intTag; + tcV = new TypeCode(TCKind.tk_ulong); + } + + + /** + Unsigned Long value insertion method + **/ + public void insert_ulong(long l){ + longV = l; + tag = com.ericsson.otp.erlang.OtpExternal.intTag; + tcV = new TypeCode(TCKind.tk_ulong); + } + + + + /* ulonglong */ + + /** + Unsigned Long Long value extractor method + @return long, the value of Term + **/ + public long extract_ulonglong() + throws java.lang.Exception { + + if (tcV == null) + return longV; + + if (tcV.kind() == TCKind.tk_ulonglong) + return longV; + + throw new java.lang.Exception(""); + } + + + /** + Unsigned Long Long value insertion method + **/ + public void insert_ulonglong(long l){ + longV = l; + tag = com.ericsson.otp.erlang.OtpExternal.intTag; + tcV = new TypeCode(TCKind.tk_ulonglong); + } + + + + /* float */ + /** + Float value extractor method + @return float, the value of Term + **/ + public float extract_float() + throws java.lang.Exception{ + + if (tcV == null) + return (float) doubleV; + + if (tcV.kind() == TCKind.tk_float) + return (float) doubleV; + + throw new java.lang.Exception(""); + } + + + /** + Float value insertion method + **/ + public void insert_float(float f){ + doubleV = f; + tag = com.ericsson.otp.erlang.OtpExternal.floatTag; + tcV = new TypeCode(TCKind.tk_float); + } + + /** + Float value insertion method + **/ + public void insert_float(double f){ + doubleV = f; + tag = com.ericsson.otp.erlang.OtpExternal.floatTag; + tcV = new TypeCode(TCKind.tk_float); + } + + + /* double */ + /** + Double value extractor method + @return double, the value of Term + **/ + public double extract_double() + throws java.lang.Exception{ + + if (tcV == null) + return doubleV; + + if (tcV.kind() == TCKind.tk_double) + return doubleV; + + throw new java.lang.Exception(""); + } + + /** + Double value insertion method + **/ + public void insert_double(double d){ + doubleV = d; + tag = com.ericsson.otp.erlang.OtpExternal.floatTag; + tcV = new TypeCode(TCKind.tk_double); + } + + + /* boolean */ + /** + Boolean value extractor method + @return boolean, the value of Term + **/ + public boolean extract_boolean() + throws java.lang.Exception{ + + if ((tcV == null) && (atomV != null)) + return Boolean.valueOf(atomV).booleanValue(); + + if (tcV.kind() == TCKind.tk_boolean) + return booleanV; + + throw new java.lang.Exception(""); + } + + /** + Boolean value insertion method + **/ + public void insert_boolean(boolean b){ + booleanV = b; + tag = com.ericsson.otp.erlang.OtpExternal.atomTag; + tcV = new TypeCode(TCKind.tk_boolean); + } + + + /* char */ + /** + Char value extractor method + @return char, the value of Term + **/ + public char extract_char() + throws java.lang.Exception{ + + if (tcV == null) + return (char) longV; + + if (tcV.kind() == TCKind.tk_char) + return (char) longV; + + throw new java.lang.Exception(""); + } + + /** + Char value insertion method + **/ + public void insert_char(char c) { + longV = c; + tag = com.ericsson.otp.erlang.OtpExternal.smallIntTag; + tcV = new TypeCode(TCKind.tk_char); + } + + /** + Char value insertion method + **/ + public void insert_char(long l) { + longV = l; + tag = com.ericsson.otp.erlang.OtpExternal.smallIntTag; + tcV = new TypeCode(TCKind.tk_char); + } + + + + /* wchar */ + /** + Wchar value extractor method + @return char, the value of Term + **/ + public char extract_wchar() + throws java.lang.Exception{ + + if (tcV == null) + return (char) longV; + + if (tcV.kind() == TCKind.tk_wchar) + return (char) longV; + + throw new java.lang.Exception(""); + } + + /** + Wchar value insertion method + **/ + public void insert_wchar(char c) { + longV = c; + tag = com.ericsson.otp.erlang.OtpExternal.smallIntTag; + tcV = new TypeCode(TCKind.tk_wchar); + } + + /** + Wchar value insertion method + **/ + public void insert_wchar(long l) { + longV = l; + tag = com.ericsson.otp.erlang.OtpExternal.smallIntTag; + tcV = new TypeCode(TCKind.tk_wchar); + } + + + /* octet */ + /** + Octet value extractor method + @return byte, the value of Term + **/ + public byte extract_octet() + throws java.lang.Exception{ + + if (tcV == null) + return (byte) longV; + + if (tcV.kind() == TCKind.tk_octet) + return (byte) longV; + + throw new java.lang.Exception(""); + } + + /** + Octet value insertion method + **/ + public void insert_octet(byte b){ + longV = b; + tag = com.ericsson.otp.erlang.OtpExternal.smallIntTag; + tcV = new TypeCode(TCKind.tk_octet); + } + + /** + Octet value insertion method + **/ + public void insert_octet(long l){ + longV = l; + tag = com.ericsson.otp.erlang.OtpExternal.smallIntTag; + tcV = new TypeCode(TCKind.tk_octet); + } + + + + /* string */ + + /** + String value extractor method + @return String, the value of Term + **/ + public java.lang.String extract_string() + throws java.lang.Exception{ + + if (tcV == null) { + if (stringV != null) + return stringV; + else { + is = this.extract_Streamable(); + stringV = is.read_string(); + return stringV; + } + } + else + if (tcV.kind() == TCKind.tk_string) + return stringV; + + throw new java.lang.Exception(""); + } + + /** + String value insertion method + **/ + public void insert_string(java.lang.String s) { + stringV = s; + tag = com.ericsson.otp.erlang.OtpExternal.stringTag; + tcV = new TypeCode(TCKind.tk_string); + } + + + + /* wstring */ + /** + Wstring value extractor method + @return String, the value of Term + **/ + public java.lang.String extract_wstring() + throws java.lang.Exception{ + + if (tcV == null) { + if (stringV != null) + return stringV; + else { + is = this.extract_Streamable(); + stringV = is.read_string(); + return stringV; + } + } + else + if (tcV.kind() == TCKind.tk_wstring) + return stringV; + + throw new java.lang.Exception(""); + } + + /** + Wstring value insertion method + **/ + public void insert_wstring(java.lang.String s) { + stringV = s; + tag = com.ericsson.otp.erlang.OtpExternal.stringTag; + tcV = new TypeCode(TCKind.tk_wstring); + } + + + + /* atom */ + /** + Atom value extractor method + @return atom, the value of Term + **/ + public java.lang.String extract_atom() + throws java.lang.Exception{ + + if ((tcV == null) && (atomV != null)) + return atomV; + + if (tcV.kind() == TCKind.tk_atom) + return stringV; + + throw new java.lang.Exception(""); + } + + + /** + Atom value insertion method + **/ + public void insert_atom(java.lang.String s) { + stringV = s; + tag = com.ericsson.otp.erlang.OtpExternal.atomTag; + tcV = new TypeCode(TCKind.tk_atom); + } + + + /* Pid */ + /** + Pid value extractor method + @return Pid, the value of Term + **/ + public Pid extract_Pid() + throws java.lang.Exception{ + + if ((tcV == null) && (PidV != null)) + return PidV; + + if (tcV.equal(PidHelper.type())) + return PidV; + + throw new java.lang.Exception(""); + } + + + /** + Pid value insertion method + **/ + public void insert_Pid(Pid p) { + PidV = p; + tag = com.ericsson.otp.erlang.OtpExternal.pidTag; + tcV = PidHelper.type(); + } + + + + /* Ref */ + /** + Ref value extractor method + @return Ref, the value of Term + **/ + public Ref extract_Ref() + throws java.lang.Exception{ + + if ((tcV == null) && (RefV != null)) + return RefV; + + if (tcV.equal(RefHelper.type())) + return RefV; + + throw new java.lang.Exception(""); + } + + /** + Ref value insertion method + **/ + public void insert_Ref(Ref r) { + RefV = r; + + if (r.isNewRef()) + tag = com.ericsson.otp.erlang.OtpExternal.newRefTag; + else + tag = com.ericsson.otp.erlang.OtpExternal.refTag; + + tcV = RefHelper.type(); + } + + + + /* Port */ + /** + Port value extractor method + @return Port, the value of Term + **/ + public Port extract_Port() + throws java.lang.Exception{ + + if ((tcV == null) && (PortV != null)) + return PortV; + + if (tcV.equal(PortHelper.type())) + return PortV; + + throw new java.lang.Exception(""); + } + + /** + Port value insertion method + **/ + public void insert_Port(Port p) { + PortV = p; + tag = com.ericsson.otp.erlang.OtpExternal.portTag; + tcV = PortHelper.type(); + } + + + /** + Object Stream extractor method + @return OtpInputStream, the stream value of Term + **/ + public com.ericsson.otp.erlang.OtpInputStream extract_Streamable() { + + if (is == null) { + if (os == null) { + if (stringV == null) + return null; + else { + // A sequence that become a string ! + os = new com.ericsson.otp.erlang.OtpOutputStream(); + os.write_string(stringV); + is = new com.ericsson.otp.erlang.OtpInputStream(os.toByteArray()); + } + } + else { + is = new com.ericsson.otp.erlang.OtpInputStream(os.toByteArray()); + } + } + + is.reset(); + return is; + } + + /** + Inserts Objects to Term + **/ + public void insert_Object(com.ericsson.otp.erlang.OtpErlangObject o) { + ObjV = o; + } + + /** + Extract Object value from Term + @return OtpErlangObject, the Object value of Term + **/ + public com.ericsson.otp.erlang.OtpErlangObject extract_Object() { + return ObjV; + } + + +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/ic/java_src/com/ericsson/otp/ic/TermHelper.java b/lib/ic/java_src/com/ericsson/otp/ic/TermHelper.java new file mode 100644 index 0000000000..437d38743b --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/TermHelper.java @@ -0,0 +1,139 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + Helper class for Term. + **/ + +public class TermHelper { + + // Constructors + private TermHelper() {} + + // Methods + /** + Marshal method for the Term class, encodes the Term object to the output stream. + **/ + public static void marshal(com.ericsson.otp.erlang.OtpOutputStream _out, Term _any) + throws java.lang.Exception { + + _any.write_value(_out); + } + + /** + Unmarshal method for the Term class, decodes a Term object from the stream. + @return Term, read from the input stream + **/ + public static Term unmarshal(com.ericsson.otp.erlang.OtpInputStream _in) + throws java.lang.Exception { + + Term _value = new Term(); + + int tag = _in.peek(); + if (tag == com.ericsson.otp.erlang.OtpExternal.versionTag) { + _in.read1(); + tag = _in.peek(); + } + _value.tag = tag; + + + // Allways save the object in OtpErlangObject form + _in.mark(0); + com.ericsson.otp.erlang.OtpErlangObject _obj = _in.read_any(); + _value.insert_Object(_obj); + + switch (tag) { + case com.ericsson.otp.erlang.OtpExternal.smallIntTag: + case com.ericsson.otp.erlang.OtpExternal.intTag: + case com.ericsson.otp.erlang.OtpExternal.smallBigTag: + _in.reset(); + _value.longV = _in.read_long(); + break; + + case com.ericsson.otp.erlang.OtpExternal.atomTag: + _in.reset(); + _value.atomV = _in.read_atom(); + break; + + case com.ericsson.otp.erlang.OtpExternal.floatTag: + _in.reset(); + _value.doubleV = _in.read_double(); + break; + + case com.ericsson.otp.erlang.OtpExternal.refTag: + case com.ericsson.otp.erlang.OtpExternal.newRefTag: + _in.reset(); + com.ericsson.otp.erlang.OtpErlangRef _eref = + _in.read_ref(); + + if (_eref.isNewRef()) + _value.RefV = new Ref(_eref.node(),_eref.ids(),_eref.creation()); + else + _value.RefV = new Ref(_eref.node(),_eref.id(),_eref.creation()); + + break; + + case com.ericsson.otp.erlang.OtpExternal.portTag: + _in.reset(); + com.ericsson.otp.erlang.OtpErlangPort _eport = + _in.read_port(); + + _value.PortV = new Port(_eport.node(),_eport.id(),_eport.creation()); + break; + + case com.ericsson.otp.erlang.OtpExternal.pidTag: + _in.reset(); + com.ericsson.otp.erlang.OtpErlangPid _epid = + _in.read_pid(); + + _value.PidV = new Pid(_epid.node(),_epid.id(),_epid.serial(),_epid.creation()); + break; + + case com.ericsson.otp.erlang.OtpExternal.stringTag: + _in.reset(); + _value.stringV = _in.read_string(); + break; + + case com.ericsson.otp.erlang.OtpExternal.listTag: + case com.ericsson.otp.erlang.OtpExternal.nilTag: + case com.ericsson.otp.erlang.OtpExternal.smallTupleTag: + case com.ericsson.otp.erlang.OtpExternal.largeTupleTag: + case com.ericsson.otp.erlang.OtpExternal.binTag: + + com.ericsson.otp.erlang.OtpOutputStream _os = + new com.ericsson.otp.erlang.OtpOutputStream(); + + _obj.encode(_os); + _value.insert_Streamable(_os); + break; + + case com.ericsson.otp.erlang.OtpExternal.largeBigTag: + default: + throw new com.ericsson.otp.erlang.OtpErlangDecodeException("Uknown data type: " + tag); + } + + return _value; + } + +} + + + diff --git a/lib/ic/java_src/com/ericsson/otp/ic/TermHolder.java b/lib/ic/java_src/com/ericsson/otp/ic/TermHolder.java new file mode 100644 index 0000000000..9c92de9523 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/TermHolder.java @@ -0,0 +1,58 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +package com.ericsson.otp.ic; + +/** + Holder class for Term. + **/ + +final public class TermHolder { + + /** + Term instance variable. + **/ + public Term value; + + // Constructors + public TermHolder() {} + + public TermHolder(Term initial) { + value = initial; + } + + // Methods + /** + Marshal method for the TermHolder class, encodes the Term object value to the output stream. + **/ + public void _marshal(com.ericsson.otp.erlang.OtpOutputStream out) + throws java.lang.Exception { + TermHelper.marshal(out, value); + } + + /** + Unmarshal method for the TermHolder class, decodes a Term object from the output stream + and assigns it to the Holder value field. + **/ + public void _unmarshal(com.ericsson.otp.erlang.OtpInputStream in) + throws java.lang.Exception { + value = TermHelper.unmarshal(in); + } + +} diff --git a/lib/ic/java_src/com/ericsson/otp/ic/TypeCode.java b/lib/ic/java_src/com/ericsson/otp/ic/TypeCode.java new file mode 100644 index 0000000000..6d049f75f7 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/TypeCode.java @@ -0,0 +1,875 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2009. All Rights Reserved. + * + * 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 online 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. + * + * %CopyrightEnd% + * + */ +/** + * 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) + throws java.lang.Exception{ + + return _members[__index]; + } + + /** + Insertion method for the indexed member type of TypeCode. + Sets the type of a member value of the object at the selected index.. + **/ + public void member_type(int __index, TypeCode __member_type) { + _members[__index] = __member_type; + } + + + /* + * Operation "TypeCode::member_label" + */ + + /** + Member label accessor method for TypeCode. + @return Any, the label of the member of the TypeCode object + on the selected index + **/ + public Any member_label(int __index) + throws java.lang.Exception{ + + return _member_labels[__index]; + } + + /** + Insertion method for the indexed member label of TypeCode. + Sets the label of a member value of the object at the selected index. + **/ + public void member_label(int __index, Any __member_label) { + _member_labels[__index] = __member_label; + } + + + /* + * Operation "TypeCode::discriminator_type" + */ + + /** + Discriminator type accessor method for TypeCode. + @return TypeCode, the type of the discriminator of the TypeCode object + **/ + public TypeCode discriminator_type() + throws java.lang.Exception{ + + if (_discriminator_type == null) + throw new java.lang.Exception("BAD KIND"); + + return _discriminator_type; + } + + /** + Insertion method for the type of the discriminator value of TypeCode. + Sets the discriminator type value of the object. + **/ + public void discriminator_type(TypeCode __discriminator_type) { + _discriminator_type = __discriminator_type; + } + + + /* + * Operation "TypeCode::default_index" + */ + + /** + Index accessor method for TypeCode. + @return int, the default index value of the member of the TypeCode object + **/ + public int default_index() + throws java.lang.Exception{ + + if (_default_index == -1) + throw new java.lang.Exception("BAD KIND"); + + return _default_index; + } + + /** + Insertion method for the default index value of TypeCode. + Sets the default index value of the object. + **/ + public void default_index(int __default_index) { + _default_index = __default_index; + } + + + /* + * Operation "TypeCode::length" + */ + + /** + Length accessor method for TypeCode. + @return int, the length of the TypeCode object + **/ + public int length() + throws java.lang.Exception{ + + if (_length == -1) + throw new java.lang.Exception("BAD KIND"); + + return _length; + } + + /** + Insertion method for the length value of TypeCode. + Sets the length value of the object. + **/ + public void length(int __length) { + _length = __length; + } + + + /* + * Operation "TypeCode::content_type" + */ + + /** + Content type accessor method for TypeCode. + @return TypeCode, the content type of the TypeCode object + **/ + public TypeCode content_type() + throws java.lang.Exception { + + if (_content_type == null) + throw new java.lang.Exception("BAD KIND"); + + return _content_type; + } + + /** + Insertion method for the content type value of TypeCode. + Sets the content type value of the object. + **/ + public void content_type(TypeCode __content_type) { + _content_type = __content_type; + } + + + /** + Marshal operation for TypeCode. + **/ + public static void marshal(com.ericsson.otp.erlang.OtpOutputStream _os, TypeCode _tc) + throws java.lang.Exception { + + TypeCode memberTC = null; + int len = -1; + + switch(_tc.kind().value()) { + + case TCKind._tk_short : + _os.write_atom("tk_short"); + break; + case TCKind._tk_ushort : + _os.write_atom("tk_ushort"); + break; + case TCKind._tk_long : + _os.write_atom("tk_long"); + break; + case TCKind._tk_longlong : + _os.write_atom("tk_longlong"); + break; + case TCKind._tk_ulong : + _os.write_atom("tk_ulong"); + break; + case TCKind._tk_ulonglong : + _os.write_atom("tk_ulonglong"); + break; + case TCKind._tk_float : + _os.write_atom("tk_float"); + break; + case TCKind._tk_double : + _os.write_atom("tk_double"); + break; + case TCKind._tk_boolean : + _os.write_atom("tk_boolean"); + break; + case TCKind._tk_char : + _os.write_atom("tk_char"); + break; + case TCKind._tk_wchar : + _os.write_atom("tk_wchar"); + break; + case TCKind._tk_octet : + _os.write_atom("tk_octet"); + break; + case TCKind._tk_string : + _os.write_tuple_head(2); + _os.write_atom("tk_string"); + _os.write_ulong(_tc.length()); + break; + case TCKind._tk_wstring : + _os.write_tuple_head(2); + _os.write_atom("tk_wstring"); + _os.write_ulong(_tc.length()); + break; + case TCKind._tk_struct: + len = _tc.member_count(); + _os.write_tuple_head(4); + _os.write_atom("tk_struct"); + _os.write_string(_tc.id()); + _os.write_string(_tc.name()); + // Member list + _os.write_list_head(len); + for(int i=0; i<len; i++) { + _os.write_tuple_head(2); + _os.write_string(_tc.member_name(i)); + marshal(_os,_tc.member_type(i)); + } + _os.write_nil(); + break; + case TCKind._tk_union: + len = _tc.member_count(); + _os.write_tuple_head(6); + _os.write_atom("tk_union"); + _os.write_string(_tc.id()); + _os.write_string(_tc.name()); + marshal(_os,_tc.discriminator_type()); + _os.write_int(_tc.default_index()); + // Member list + _os.write_list_head(len); + for(int i=0; i<len; i++) { + _os.write_tuple_head(3); + _tc.member_label(i).write_value(_os); + _os.write_string(_tc.member_name(i)); + marshal(_os,_tc.member_type(i)); + } + _os.write_nil(); + break; + case TCKind._tk_sequence: + _os.write_tuple_head(3); + _os.write_atom("tk_sequence"); + marshal(_os,_tc.content_type()); + _os.write_int(_tc.length()); + break; + case TCKind._tk_array: + _os.write_tuple_head(3); + _os.write_atom("tk_array"); + marshal(_os,_tc.content_type()); + _os.write_int(_tc.length()); + break; + case TCKind._tk_enum: + len = _tc.member_count(); + _os.write_tuple_head(4); + _os.write_atom("tk_enum"); + _os.write_string(_tc.id()); + _os.write_string(_tc.name()); + _os.write_list_head(len); + for(int i=0; i<len; i++) + _os.write_string(_tc.member_name(i)); + _os.write_nil(); + break; + case TCKind._tk_any: + _os.write_atom("tk_any"); + break; + case TCKind._tk_void : + _os.write_atom("tk_void"); + break; + /* + * Not supported types + */ + default : + throw new java.lang.Exception("Unsupported type"); + + } + + } + + + /** + Unmarshal operation for TypeCode. + @return TypeCode, the TypeCode read from the input stream. + **/ + public static TypeCode unmarshal(com.ericsson.otp.erlang.OtpInputStream _is) + throws java.lang.Exception { + + TypeCode _tc, __member; + TCKind __kind; + int __len; + int __tag = _is.peek(); + + switch(__tag) { + case (com.ericsson.otp.erlang.OtpExternal.atomTag): + __kind = TypeCode.kind(_is.read_atom()); + + switch(__kind.value()) { + case TCKind._tk_short : + case TCKind._tk_ushort : + case TCKind._tk_long : + case TCKind._tk_longlong : + 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_void : + case TCKind._tk_any : + _tc = new TypeCode(); + _tc.kind(__kind); + + return _tc; + default : + throw new java.lang.Exception("Unsupported type"); + } + + case (com.ericsson.otp.erlang.OtpExternal.smallTupleTag): + case (com.ericsson.otp.erlang.OtpExternal.largeTupleTag): + + __len = _is.read_tuple_head(); + __tag = _is.peek(); + + switch(__tag) { + + case (com.ericsson.otp.erlang.OtpExternal.atomTag): + + __kind = TypeCode.kind(_is.read_atom()); + _tc = new TypeCode(); + _tc.kind(__kind); + + switch(__kind.value()) { + + case TCKind._tk_string : + _tc.length((int)_is.read_ulong()); + return _tc; + + case TCKind._tk_wstring : + _tc.length((int)_is.read_ulong()); + return _tc; + + case TCKind._tk_struct: + + _tc.id(_is.read_string()); + _tc.name(_is.read_string()); + __len = _is.read_list_head(); + _tc.member_count(__len); + + for(int i=0; i<__len; i++) { + _is.read_tuple_head(); + _tc.member_name(i,_is.read_string()); + _tc.member_type(i,unmarshal(_is)); + } + _is.read_nil(); + + return _tc; + + + case TCKind._tk_union: + + _tc.id(_is.read_string()); + _tc.name(_is.read_string()); + _tc.discriminator_type(unmarshal(_is)); + _tc.default_index(_is.read_int()); + __len = _is.read_list_head(); + _tc.member_count(__len); + + for(int i=0; i<__len; i++) { + _is.read_tuple_head(); + + __tag = _is.peek(); + Any __label = new Any(); + TypeCode __label_type = new TypeCode(); + + __label_type.kind(com.ericsson.otp.ic.TCKind.tk_long); + __label.type(__label_type); + + switch(__tag) { + case (com.ericsson.otp.erlang.OtpExternal.stringTag): + java.lang.String __enum = _is.read_string(); + __label.insert_string(__enum); + break; + case (com.ericsson.otp.erlang.OtpExternal.atomTag): + java.lang.String __default = _is.read_atom(); + __label.insert_atom(__default); + break; + default: + __label.insert_long(_is.read_int()); + } + + _tc.member_label(i,__label); + _tc.member_name(i,_is.read_string()); + _tc.member_type(i,unmarshal(_is)); + } + _is.read_nil(); + + return _tc; + + + case TCKind._tk_sequence: + _tc.content_type(unmarshal(_is)); + _tc.length(_is.read_int()); + return _tc; + + + case TCKind._tk_array: + _tc.content_type(unmarshal(_is)); + _tc.length(_is.read_int()); + return _tc; + + + case TCKind._tk_enum: + + _tc.id(_is.read_string()); + _tc.name(_is.read_string()); + __len = _is.read_list_head(); + _tc.member_count(__len); + + for(int i=0; i<__len; i++) + _tc.member_name(i,_is.read_string()); + + _is.read_nil(); + + return _tc; + + default: + throw new java.lang.Exception("Unsupported type"); + + } + + default: + throw new java.lang.Exception("Unsupported type"); + } + + } + + return null; + } + +} + + diff --git a/lib/ic/java_src/com/ericsson/otp/ic/ignore_config_record.inf b/lib/ic/java_src/com/ericsson/otp/ic/ignore_config_record.inf new file mode 100644 index 0000000000..34e5586175 --- /dev/null +++ b/lib/ic/java_src/com/ericsson/otp/ic/ignore_config_record.inf @@ -0,0 +1 @@ +Dummy to speed up compilatio |