private ClassDataDesc readTC_CLASSDESC() { ClassDataDesc cdd = new ClassDataDesc(); var b1 = _bb.GetByte(); print("TC_CLASSDESC - 0xb1"); if (b1 != 0x72) { throw new Exception("Error: Illegal value for TC_CLASSDESC (should be 0x72)"); } increaseIndent(); print("className"); increaseIndent(); var value = readUtf(); cdd.AddClass(value); decreaseIndent(); print("serialVersionUID - 0x" + string.Format("{0:X2}", _bb.GetByte()) + " " + string.Format("{0:X2}", _bb.GetByte()) + " " + string.Format("{0:X2}", _bb.GetByte()) + " " + string.Format("{0:X2}", _bb.GetByte()) + " " + string.Format("{0:X2}", _bb.GetByte()) + " " + string.Format("{0:X2}", _bb.GetByte()) + " " + string.Format("{0:X2}", _bb.GetByte()) + " " + string.Format("{0:X2}", _bb.GetByte())); cdd.SetLastClassHandle(newHandle()); readClassDescInfo(cdd); decreaseIndent(); return(cdd); }
//object 시작과 끝 // readNewObject에서만 사용 private void readClassData(ClassDataDesc cdd) { // ClassDetails cd; print("<<classdata>>"); increaseIndent(); if (cdd != null) { for (int classIndex = cdd.GetClassCount() - 1; classIndex >= 0; --classIndex) { var cd = cdd.GetClassDetails(classIndex); print(cd.GetClassName()); increaseIndent(); if (cd.IsSC_SERIALIZABLE()) { print("values - final"); increaseIndent(); foreach (ClassField cf in cd.GetFields()) { readClassDataField(cf); } decreaseIndent(); } if ((cd.IsSC_SERIALIZABLE() && cd.IsSC_WRITE_METHOD()) || (cd.IsSC_EXTERNALIZABLE() && cd.IsSC_BLOCKDATA())) { print("objectAnnotation"); increaseIndent(); while (_bb.Peek() != 0x78) { readContentElement(); } _bb.Skip(1); print("TC_ENDBLOCKDATA - 0x78"); } if ((cd.IsSC_EXTERNALIZABLE()) && (!cd.IsSC_BLOCKDATA())) { print("externalContents"); increaseIndent(); print("Unable to parse externalContents as the format is specific to the implementation class."); throw new Exception("Error: Unable to parse externalContents element."); } decreaseIndent(); } } else { print("N/A"); } decreaseIndent(); }
public ClassDataDesc(ClassDataDesc cdd) { this._classDetails = new ArrayList(); foreach (ClassDetails cd in cdd._classDetails) { this._classDetails.Add(new ClassDetails(cd)); } }
private ClassDataDesc readSuperClassDesc() { print("superClassDesc"); increaseIndent(); ClassDataDesc cdd = readClassDesc(); return(cdd); }
public void AddSuperClassDesc(ClassDataDesc scdd) { if (scdd != null) { for (int i = 0; i < scdd.GetClassCount(); i++) { this._classDetails.Add(scdd.GetClassDetails(i)); } } }
// TODO // return cdd or cd ?? private object readNewArray() { var b1 = _bb.GetByte(); print("TC_ARRAY - 0x" + string.Format("{0:X2}", b1)); if (b1 != 0x75) { throw new Exception("Error: Illegal value for TC_ARRAY (should be 0x75)"); } increaseIndent(); ClassDataDesc cdd = readClassDesc(); if (cdd.GetClassCount() != 1) { throw new Exception("Error: Array class description made up of more than one class."); } ClassDetails cd = cdd.GetClassDetails(0); if (cd.ClassName[0] != '[') { throw new Exception("Error: Array class name does not begin with '['."); } var handle = newHandle(); _globalObjects[handle] = cdd; var size = _bb.GetInt32BE(); print("Values"); increaseIndent(); for (int i = 0; i < size; i++) { print("Index " + i + ":"); increaseIndent(); var cf = new ClassField((byte)cd.ClassName[1]); var value = readFieldValue(cf.GetTypeCode()); cf.SetValue(value); cd.AddField(cf); decreaseIndent(); } decreaseIndent(); decreaseIndent(); return(cd); }
private ClassDataDesc readNewClassDesc() { switch (_bb.Peek()) { case 0x72: ClassDataDesc cdd = readTC_CLASSDESC(); this._classDataDescriptions.Add(cdd); return(cdd); case 0x7d: return(readTC_PROXYCLASSDESC()); } print("Invalid newClassDesc type 0x" + string.Format("{0:X2}", _bb.Peek())); throw new Exception("Error illegal newClassDesc type."); }
private void readProxyClassDescInfo(ClassDataDesc cdd) { print("proxyInterfaceNames"); var b1 = _bb.GetInt32BE(); increaseIndent(); for (int i = 0; i < b1; i++) { print(i + ":"); readUtf(); decreaseIndent(); } readClassAnnotation(); cdd.AddSuperClassDesc(readSuperClassDesc()); }
private ClassDataDesc readTC_PROXYCLASSDESC() { var cdd = new ClassDataDesc(); var b1 = _bb.GetByte(); print("TC_PROXYCLASSDESC - 0x" + string.Format("{0:X2}", b1)); if (b1 != 125) { throw new Exception("Error: Illegal value for TC_PROXYCLASSDESC (should be 0x7d)"); } increaseIndent(); newHandle(); readProxyClassDescInfo(cdd); decreaseIndent(); return(cdd); }
private void readFields(ClassDataDesc cdd) { var count = _bb.GetInt16BE(); print("fieldCOunt - " + count + " - 0xxxxx"); if (count > 0) { print("Fields"); increaseIndent(); for (int i = 0; i < count; i++) { print(i + ":"); increaseIndent(); readFieldDesc(cdd); decreaseIndent(); } decreaseIndent(); } }
private ClassDataDesc readNewObject() { var b1 = _bb.GetByte(); print("TC_OBJECT - 0x {0}"); if (b1 != 0x73) { throw new Exception("Error: Illegal value for TC_OBJECT (should be 0x73)"); } increaseIndent(); ClassDataDesc cdd = readClassDesc(); var handle = newHandle(); var dpCdd = deepCopyClassDesc(cdd); readClassData(dpCdd); decreaseIndent(); _globalObjects[handle] = dpCdd; return(dpCdd); }
private void readFieldDesc(ClassDataDesc cdd) { var b1 = _bb.GetByte(); cdd.AddFieldToLastClass(b1); switch ((char)b1) { case 'B': print("Byte - B - 0x" + string.Format("{0:X2}", b1)); break; case 'C': print("Char - C - 0x" + string.Format("{0:X2}", b1)); break; case 'D': print("Double - D - 0x" + string.Format("{0:X2}", b1)); break; case 'F': print("Float - F - 0x" + string.Format("{0:X2}", b1)); break; case 'I': print("Int - I - 0x" + string.Format("{0:X2}", b1)); break; case 'J': print("Long - L - 0x" + string.Format("{0:X2}", b1)); break; case 'S': print("Short - S - 0x" + string.Format("{0:X2}", b1)); break; case 'Z': print("Bool - Z - 0x" + string.Format("{0:X2}", b1)); break; case '[': print("Array - [ - 0x" + string.Format("{0:X2}", b1)); break; case 'L': print("Object - L - 0x" + string.Format("{0:X2}", b1)); break; default: throw new Exception("Error: Illegal field type code ('" + (char)b1 + "', 0x" + string.Format("{0:X2}", b1) + ")"); } print("fieldName"); increaseIndent(); var name = readUtf(); cdd.SetLastFieldName(name); decreaseIndent(); string value = ""; if (((char)b1 == '[') || ((char)b1 == 'L')) { print("className1"); increaseIndent(); value = readNewString(); cdd.SetLastFieldClassName1(value); decreaseIndent(); } }
private void readClassDescInfo(ClassDataDesc cdd) { string classDescFlags = ""; var b1 = _bb.GetByte(); if ((b1 & 0x1) == 1) { classDescFlags = classDescFlags + "SC_WRITE_METHOD | "; } if ((b1 & 0x2) == 2) { classDescFlags = classDescFlags + "SC_SERIALIZABLE | "; } if ((b1 & 0x4) == 4) { classDescFlags = classDescFlags + "SC_EXTERNALIZABLE | "; } if ((b1 & 0x8) == 8) { classDescFlags = classDescFlags + "SC_BLOCKDATA | "; } if (classDescFlags.Length > 0) { classDescFlags = classDescFlags.Substring(0, classDescFlags.Length - 3); } print("classDescFlags - 0x" + string.Format("{0:X2}", b1) + " - " + classDescFlags); cdd.SetLastClassDescFlags(b1); if ((b1 & 0x2) == 2) { if ((b1 & 0x4) == 4) { throw new Exception("Error: Illegal classDescFlags, SC_SERIALIZABLE is not compatible with SC_EXTERNALIZABLE."); } if ((b1 & 0x8) == 8) { throw new Exception("Error: Illegal classDescFlags, SC_SERIALIZABLE is not compatible with SC_BLOCKDATA."); } } else if ((b1 & 0x4) == 4) { if ((b1 & 0x1) == 1) { throw new Exception("Error: Illegal classDescFlags, SC_EXTERNALIZABLE is not compatible with SC_WRITE_METHOD."); } } else if (b1 != 0) { throw new Exception("Error: Illegal classDescFlags, must include either SC_SERIALIZABLE or SC_EXTERNALIZABLE."); } readFields(cdd); readClassAnnotation(); cdd.AddSuperClassDesc(readSuperClassDesc()); }
private ClassDataDesc deepCopyClassDesc(ClassDataDesc cdd) { var result = new ClassDataDesc(cdd); return(result); }