1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02:05 +01:00

Cleanup EmbeddedExtensionProvider

- Change method modifiers keyword order to JLS
- Use attributecount when creating the HashMap
- Rename 'tag' to event'
- Use diamond operator
- Use Smack formatting style
This commit is contained in:
Florian Schmaus 2015-01-01 17:49:52 +01:00
parent a87323cc33
commit 06add179ec

View file

@ -81,33 +81,33 @@ import org.xmlpull.v1.XmlPullParserException;
* *
* @author Robin Collier * @author Robin Collier
*/ */
abstract public class EmbeddedExtensionProvider<PE extends PacketExtension> extends PacketExtensionProvider<PE> public abstract class EmbeddedExtensionProvider<PE extends PacketExtension> extends PacketExtensionProvider<PE> {
{
@Override @Override
final public PE parse(XmlPullParser parser, int initialDepth) public final PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
throws XmlPullParserException, IOException, SmackException { SmackException {
String namespace = parser.getNamespace(); final String namespace = parser.getNamespace();
String name = parser.getName(); final String name = parser.getName();
Map<String, String> attMap = new HashMap<String, String>(); final int attributeCount = parser.getAttributeCount();
Map<String, String> attMap = new HashMap<>(attributeCount);
for(int i=0; i<parser.getAttributeCount(); i++)
{ for (int i = 0; i < attributeCount; i++) {
attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i)); attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i));
} }
List<PacketExtension> extensions = new ArrayList<PacketExtension>();
int tag; List<PacketExtension> extensions = new ArrayList<>();
do int event;
{ do {
tag = parser.next(); event = parser.next();
if (tag == XmlPullParser.START_TAG) if (event == XmlPullParser.START_TAG)
PacketParserUtils.addPacketExtension(extensions, parser); PacketParserUtils.addPacketExtension(extensions, parser);
} while (!(tag == XmlPullParser.END_TAG && parser.getDepth() == initialDepth)); }
while (!(event == XmlPullParser.END_TAG && parser.getDepth() == initialDepth));
return createReturnExtension(name, namespace, attMap, extensions); return createReturnExtension(name, namespace, attMap, extensions);
} }
abstract protected PE createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content); protected abstract PE createReturnExtension(String currentElement, String currentNamespace,
Map<String, String> attributeMap, List<? extends PacketExtension> content);
} }