corbafacility.java
来自「UCS (Ultra Corba Simulator) is one more 」· Java 代码 · 共 957 行 · 第 1/2 页
JAVA
957 行
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
*/
private static String printTypeCode(Any a, String ret, boolean includedId) {
String id;
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "TypeCode: ";
}
} else {
id = "";
}
return ret + id + a.create_input_stream().read_TypeCode();
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
*/
private static String printPrincipal(Any a, String ret, boolean includedId) {
String id;
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "Principal: ";
}
} else {
id = "";
}
// ret = ret + id +
// a.create_input_stream().read_Principal();
return ret + id + "Deprecated by CORBA 2.2.";
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
*/
private static String printObjref(Any a, String ret, boolean includedId) {
String id;
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "Objref: ";
}
} else {
id = "";
}
org.omg.CORBA.Object obj = a.create_input_stream().read_Object();
if (obj != null) {
return ret + id + orb.object_to_string(obj);
}
return ret + id + "null";
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
* @throws IdlExcept
*/
private static String printStruct(Any a, String ret, boolean includedId)
throws Exception {
String id;
String str;
DynStruct dynstruct = (DynStruct) factory.create_dyn_any(a);
org.omg.DynamicAny.NameValuePair[] members = dynstruct.get_members();
if (includedId) {
try {
id = a.type().id();
} catch (Throwable e) {
id = "Struct";
}
} else {
id = "";
}
str = ret + id + "{\n";
for (int i = 0; i < members.length; i++) {
str = str + "\t";
if (includedId) {
str = str + members[i].id + " : ";
}
str += printAny(members[i].value, includedId);
if (i < members.length - 1) {
str += " , \n";
}
}
str += "\n}";
return str;
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
* @throws Exeption
*/
private static String printUnion(Any a, String ret, boolean includedId)
throws Exception {
String id;
String str;
try {
id = a.type().id();
} catch (Throwable e) {
id = "Union";
}
str = ret + id + " ( ";
DynUnion dynunion = (DynUnion) factory.create_dyn_any(a);
try {
if (includedId) {
str = str + dynunion.member_name() + " : ";
}
str += printAny(dynunion.member().to_any(), includedId);
} catch (InvalidValue e) {
str = str + "No Active Member";
}
str += " ) ";
return str;
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
* @throws IdlExcept
*/
private static String printEnum(Any a, String ret, boolean includedId)
throws Exception {
String id;
DynEnum dynEnum = (DynEnum) factory.create_dyn_any(a);
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "Enum: ";
}
} else {
id = "";
}
return ret + id + dynEnum.get_as_string();
}
private static String printException(Any a, String ret, boolean includedId)
throws Exception {
String id;
String str;
DynStruct dynstruct = (DynStruct) factory.create_dyn_any(a);
org.omg.DynamicAny.NameValuePair[] members = dynstruct.get_members();
if (includedId) {
try {
id = a.type().id();
} catch (Throwable e) {
id = "IdlExcept";
}
} else {
id = "";
}
str = ret + id + "{\n";
for (int i = 0; i < members.length; i++) {
str = str + "\t";
if (includedId) {
str = str + members[i].id + " : ";
}
str += printAny(members[i].value, includedId);
if (i < members.length - 1) {
str += " , \n";
}
}
str += "\n}";
return str;
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
*/
private static String printString(Any a, String ret, boolean includedId) {
String id;
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "String: ";
}
} else {
id = "";
}
return ret + id + a.create_input_stream().read_string();
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
* @throws IdlExcept
*/
private static String printSequence(Any a, String ret, boolean includedId)
throws Exception {
String id;
String str;
DynSequence dynseq = (DynSequence) factory.create_dyn_any(a);
Any[] contents = dynseq.get_elements();
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "Sequence: ";
}
} else {
id = "";
}
str = ret + id + "Sequence of length: " + contents.length + " ( \n";
for (int i = 0; i < contents.length; i++) {
str = str + "\t";
str += printAny(contents[i], includedId);
if (i < contents.length - 1) {
str += " ; \n";
}
}
str += " \n) ";
return str;
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
* @throws IdlExcept
*/
private static String printArray(Any a, String ret, boolean includedId)
throws Exception {
String id;
String str;
DynArray dynarray = (DynArray) factory.create_dyn_any(a);
Any[] arrayContents = dynarray.get_elements();
try {
id = a.type().id();
} catch (Throwable e) {
id = "Array";
}
str = ret + id + " ( \n";
for (int i = 0; i < arrayContents.length; i++) {
str = str + "\t";
str += printAny(arrayContents[i], includedId);
if (i < arrayContents.length - 1) {
str += " ; \n";
}
}
str += " \n) ";
return str;
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
*/
private static String printLonglong(Any a, String ret, boolean includedId) {
String id;
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "LongLong: ";
}
} else {
id = "";
}
return ret + id + a.create_input_stream().read_longlong();
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
*/
private static String printUlonglong(Any a, String ret, boolean includedId) {
String id;
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "ULongLong: ";
}
} else {
id = "";
}
return ret + id + a.create_input_stream().read_ulonglong();
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
*/
private static String printLongdouble(Any a, String ret, boolean includedId) {
String id;
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "LongDouble: ";
}
} else {
id = "";
}
return ret + id + a.create_input_stream().read_double();
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
*/
private static String printWchar(Any a, String ret, boolean includedId) {
String id;
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "WChar: ";
}
} else {
id = "";
}
return ret + id + a.create_input_stream().read_wchar();
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
*/
private static String printWstring(Any a, String ret, boolean includedId) {
String id;
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "WString: ";
}
} else {
id = "";
}
return ret + id + a.create_input_stream().read_wstring();
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
*/
private static String printFixed(Any a, String ret, boolean includedId) {
String id;
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "Fixed: ";
}
} else {
id = "";
}
return ret + id + a.create_input_stream().read_fixed();
}
/**
* @param a
* Any type
* @param ret
* string which the results should be appended to.
* @param includedId
* if true, then included id information if false, then ignor id
* information
* @return a String that describes the Any.
*/
private static String printValue(Any a, String ret, boolean includedId) {
String id;
if (includedId) {
try {
id = a.type().id() + ": ";
} catch (Throwable e) {
id = "Value: ";
}
} else {
id = "";
}
return ret + id + a.extract_Value();
}
}
/* EOF */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?