Closed GoogleCodeExporter closed 8 years ago
I can patch this:
if (obj instanceof AttributeContainer) {
for (int counter = 0; counter < parser.getAttributeCount(); counter++)
{
String attributeName = parser.getAttributeName(counter);
String value = parser.getAttributeValue(counter);
((AttributeContainer) obj).addAttribute(attributeName, value);
}
}
In method:
protected void readSerializable(XmlPullParser parser, KvmSerializable obj)
throws IOException, XmlPullParserException
This way if we have a custom object that extends AttributeContainer and
implements KvmSerializable you can get the attributes.
You may also extend SoapObject for your custom object, this should work.
Original comment by dnkoutso@gmail.com
on 28 Jul 2011 at 12:27
How about you patch it and provide patch files or a pull request on github
Original comment by mosa...@gmail.com
on 28 Jul 2011 at 2:24
Ok I will be doing that shortly.
Original comment by dnkoutso@gmail.com
on 5 Aug 2011 at 3:22
Great. I look forward to the patch. Make sure the project builds... and contact
me here if you need help.
Original comment by mosa...@gmail.com
on 5 Aug 2011 at 5:06
Original comment by mosa...@gmail.com
on 5 Aug 2011 at 5:06
If you call protected void readSerializable(XmlPullParser parser, SoapObject
obj) throws IOException it should already do that .. can you test and
potentially patch as needed..
Original comment by mosa...@gmail.com
on 23 Aug 2011 at 5:22
Any update on this patch dnkoutso?
Original comment by mosa...@gmail.com
on 18 Nov 2011 at 4:59
I am actually not sure where to insert that code snippet in the method
correctly. Can you paste the complete version that works for you or provide a
patch/pull request?
Original comment by mosa...@gmail.com
on 18 Nov 2011 at 5:29
I can confirm, that dnkoutso patch works if you insert it at beginning of
readSerializable(XmlPullParser parser, KvmSerializable obj) just before while
(parser.nextTag() != XmlPullParser.END_TAG)
But IMHO it`s not very efficient when you need some of the attributes, but not
all of them. In my example there are 22 attributes and I only need 2-3 of them.
:)
Original comment by vuk...@gmail.com
on 1 Feb 2012 at 10:11
O.k. I think i have an idea. Extend KvmSerializable:
public interface KvmSerializableWithAttributes extends KvmSerializable {
ArrayList<String> AttributesNeeded();
}
All serializing classes, that needs attribute support should look like this:
public class Row extends AttributeContainer implements
KvmSerializableWithAttributes {
@Override
public ArrayList<String> AttributesNeeded() {
ArrayList<String> arrList = new ArrayList<String>();
arrList.add("ows_LinkTitle");
arrList.add("ows_AssignedTo");
arrList.add("ows_Author");
return arrList;
}
<...>
Then in
/** Read a KvmSerializable. */
protected void readSerializable(XmlPullParser parser, KvmSerializable obj)
throws IOException,
XmlPullParserException
{
int testIndex = -1; // inc at beg. of loop for perf. reasons
int propertyCount = obj.getPropertyCount();
PropertyInfo info = new PropertyInfo();
//AttributeFix-->
//if (obj instanceof AttributeContainer) {
if (obj instanceof KvmSerializableWithAttributes) {
formAttributes(parser,obj);
}
//<--AttributeFix
<...>
Additional member in SoapSerializationEnvelope class:
protected void formAttributes(XmlPullParser parser, KvmSerializable obj)
{
ArrayList<String> arrList = new ArrayList<String>();
KvmSerializableWithAttributes kvmSerializableWithAttributes;
kvmSerializableWithAttributes = (KvmSerializableWithAttributes) obj;
arrList = kvmSerializableWithAttributes.AttributesNeeded();
for (int counter = 0; counter < parser.getAttributeCount(); counter++)
{
if(arrList.contains(parser.getAttributeName(counter)))
{
String attributeName = parser.getAttributeName(counter);
String value = parser.getAttributeValue(counter);
((AttributeContainer) obj).addAttribute(attributeName, value);
}
}
}
Original comment by vuk...@gmail.com
on 1 Feb 2012 at 10:37
This should work now with some of the changes in the recent releases. Can you
try with 2.6.3 and confirm?
Original comment by mosa...@gmail.com
on 30 Apr 2012 at 6:26
No further feedback so I am closing this issue.
Original comment by mosa...@gmail.com
on 24 May 2012 at 4:08
Original issue reported on code.google.com by
dnkoutso@gmail.com
on 27 Jul 2011 at 9:31