diff options
author | Gurmeen Bindra <gurmeen.bindra@isode.com> | 2012-03-29 14:34:35 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-03-29 15:04:06 (GMT) |
commit | c194f7d215935cded5b2eab4daeed725a5a4069c (patch) | |
tree | 18f68f2247e4a7dd0f3fcb403dfcb2c6f9b3ff02 /src/com/isode/stroke/parser/payloadparsers/ErrorParserFactory.java | |
parent | cb4600a1612a5dd8342656241e11ec45542cd1e0 (diff) | |
download | stroke-c194f7d215935cded5b2eab4daeed725a5a4069c.zip stroke-c194f7d215935cded5b2eab4daeed725a5a4069c.tar.bz2 |
Port Error Parser to stroke
After this change, the error payload object should be populated in case of error.
The condtion, type and text field will be from the payload rather than Undefined,
Cancel and empty.
Test-information:
tested by executing adhoc-commands on an XMPP clinet in a way to result
in an error. I do see the error text and condition set as per the XMPP streams.
Reviewer: Kevin Smith <kevin.smith@isode.com>
Diffstat (limited to 'src/com/isode/stroke/parser/payloadparsers/ErrorParserFactory.java')
-rw-r--r-- | src/com/isode/stroke/parser/payloadparsers/ErrorParserFactory.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/com/isode/stroke/parser/payloadparsers/ErrorParserFactory.java b/src/com/isode/stroke/parser/payloadparsers/ErrorParserFactory.java new file mode 100644 index 0000000..1f36b19 --- /dev/null +++ b/src/com/isode/stroke/parser/payloadparsers/ErrorParserFactory.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2012 Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2011 Kevin Smith + * All rights reserved. + */ +package com.isode.stroke.parser.payloadparsers; + +import com.isode.stroke.elements.ErrorPayload; +import com.isode.stroke.parser.AttributeMap; +import com.isode.stroke.parser.PayloadParser; +import com.isode.stroke.parser.PayloadParserFactory; + +/** + * Parser factory for {@link ErrorPayload} + * + */ +public class ErrorParserFactory implements PayloadParserFactory { + private FullPayloadParserFactoryCollection factories_; + + /** + * Create the factory + * @param factories reference to Payload parser factory collection, not null + */ + public ErrorParserFactory(FullPayloadParserFactoryCollection factories) { + this.factories_ = factories; + } + + @Override + public boolean canParse(final String element, final String ns, final AttributeMap map) { + return element.equals("error"); + } + + @Override + public PayloadParser createPayloadParser() { + return new ErrorParser(factories_); + } + + @Override + public String toString() { + return ErrorParserFactory.class.getSimpleName(); + } +} |