public static void Load(this JavaGenericConstraints gcs, XmlReader reader) { reader.MoveToContent(); if (reader.IsEmptyElement) { reader.Read(); } else { reader.Read(); do { reader.MoveToContent(); if (reader.NodeType == XmlNodeType.EndElement) { break; // </genericConstraints> } if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "genericConstraint") { throw XmlUtil.UnexpectedElementOrContent("genericConstraints", reader, "genericConstraint"); } var gc = new JavaGenericConstraint(); gc.Load(reader); gcs.GenericConstraints.Add(gc); } while (true); XmlUtil.VerifyEndElement(reader, "genericConstraints"); reader.Read(); } }
public static void Load(this JavaTypeParameter tp, XmlReader reader) { tp.Name = XmlUtil.GetRequiredAttribute(reader, "name"); tp.ExtendedJniClassBound = reader.GetAttribute("jni-classBound"); // such an ill-named attribute... tp.ExtendedClassBound = reader.GetAttribute("classBound"); // and un-structuring attribute... tp.ExtendedInterfaceBounds = reader.GetAttribute("interfaceBounds"); tp.ExtendedJniInterfaceBounds = reader.GetAttribute("jni-interfaceBounds"); XmlUtil.CheckExtraneousAttributes("typeParameter", reader, "name", "jni-classBound", "jni-interfaceBounds", "classBound", "interfaceBounds"); if (reader.IsEmptyElement) { reader.Read(); } else { reader.Read(); do { reader.MoveToContent(); if (reader.NodeType == XmlNodeType.EndElement) { break; // </typeParameter> } if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "genericConstraints") { throw XmlUtil.UnexpectedElementOrContent("typeParameter", reader, "genericConstraints"); } var gc = new JavaGenericConstraints(); gc.Load(reader); tp.GenericConstraints = gc; } while (true); XmlUtil.VerifyEndElement(reader, "typeParameter"); reader.Read(); } // Now we have to deal with the format difference... // Some versions of class-parse stopped generating <genericConstraints> but started // generating "classBound" and "interfaceBounds" attributes instead. // They don't make sense and blocking this effort, but we have to deal with that... if (!string.IsNullOrEmpty(tp.ExtendedClassBound) || !string.IsNullOrEmpty(tp.ExtendedInterfaceBounds)) { var gcs = new JavaGenericConstraints(); if (!string.IsNullOrEmpty(tp.ExtendedClassBound)) { gcs.GenericConstraints.Add(new JavaGenericConstraint() { Type = tp.ExtendedClassBound }); } if (!string.IsNullOrEmpty(tp.ExtendedInterfaceBounds)) { foreach (var ic in tp.ExtendedInterfaceBounds.Split(':')) { gcs.GenericConstraints.Add(new JavaGenericConstraint() { Type = ic }); } } tp.GenericConstraints = gcs; } }