Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2013 Naver Business Platform Corp. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 package com.handmark.pulltorefresh.configuration.xml;
 
 import java.util.Map;
 
 
PullToRefreshConfigXmlParser does parsing pulltorefresh.xml as XmlPullNodes

Author(s):
Wonjun Kim
 
Repetition limit is only one
  
 	private static final int ONLY_ONE_REPEAT = 1;
Parsed data
 

Parameters:
parser Must be not null
 
 		super(parser);
 	}
Generate a node tree matched by pulltorefresh.xml

Returns:
root node of a tree
 
 	private XmlPullNode init() {
 		// prepare a result instance
 		// make nodes 
 		XmlPullNode root = new XmlPullNode("PullToRefresh");
 		XmlPullNode loadingLayouts = new XmlPullNode("LoadingLayouts");
 		XmlPullNode indicatorLayouts = new XmlPullNode("IndicatorLayouts");
 		XmlPullNode googleStyleViewLayouts = new XmlPullNode("GoogleStyleViewLayouts");
 		XmlPullNode googleStyleProgressLayouts = new XmlPullNode("GoogleStyleProgressLayouts");
 		XmlPullNode indicatorLayout = new XmlPullNode("layout",new LayoutNodeCallback(.));
 		XmlPullNode googleStyleViewLayout = new XmlPullNode("layout",new LayoutNodeCallback(.));
 		XmlPullNode googleStyleProgressLayout = new XmlPullNode("layout",new LayoutNodeCallback(.));
 		// make a tree structure
 		root.addChildNode(loadingLayouts);
 		root.addChildNode(indicatorLayouts);
 		root.addChildNode(googleStyleViewLayouts);
 		root.addChildNode(googleStyleProgressLayouts);
 		loadingLayouts.addChildNode(loadingLayout);
 		indicatorLayouts.addChildNode(indicatorLayout);
 		googleStyleViewLayouts.addChildNode(googleStyleViewLayout);
 		googleStyleProgressLayouts.addChildNode(googleStyleProgressLayout);
 		// return root node
 		return root;
 	}

Returns:
root node of a tree
 
 	protected XmlPullNode generateRootNode() {
 		return init();
 	}

Returns:
Parsed result data as PullToRefreshNode instance
 
 	protected PullToRefreshNode getResult() {
 	}
Parsed Result to be sent to PullToRefreshNode

Author(s):
Wonjun Kim
 
 	private static class PullToRefreshResult {
 		public final Map<StringStringloadingLayoutClazzNameMap = new HashMap<StringString>();
 		public final Map<StringStringindicatorLayoutClazzNameMap = new HashMap<StringString>();
 	}

Callback of the node 'PullToRefresh/IndicatorLayouts/layout' and 'PullToRefresh/LoadingLayouts/layout'

Author(s):
Wonjun Kim
	private static class LayoutNodeCallback implements XmlPullNode.XmlPullNodeCallback {
Map storing Layouts' information

Parameters:
layoutClazzNameMap Must not be null and be clean for which put new values
		public LayoutNodeCallback(Map<StringStringlayoutClazzNameMap) {
			Assert.notNull(layoutClazzNameMap"Class Map");
			this. = layoutClazzNameMap;
		}
Be called when parser has found 'layout' node at a time
		public void process(XmlPullParser parserthrows XmlPullParserExceptionIOException {
			int attributesCount = parser.getAttributeCount();
			String attributeNameattributeValue;
			// Iterate attributes!			
			for (int i = 0; i < attributesCount; ++i) {
				attributeName = parser.getAttributeName(i);
				attributeValue = parser.getAttributeValue(i);
				// The 'name' attribute is as a layout code of each layout's class  
				if ( "name".equals(attributeName)) {
					// Skip if attribute value is null or empty 
					if ( attributeValue == null || attributeValue.length() == 0 ) {
						continue;
					}
					// Get layout's class name
					String clazzName = parser.nextText();
					// Insert new class name 
					.put(attributeValueclazzName);
					// Do 'break' because nextText() method has been called
					break;
				}
			}
		}
	}
New to GrepCode? Check out our FAQ X