当前位置: 首页>>代码示例>>Java>>正文


Java KXmlParser.next方法代码示例

本文整理汇总了Java中org.kxml2.io.KXmlParser.next方法的典型用法代码示例。如果您正苦于以下问题:Java KXmlParser.next方法的具体用法?Java KXmlParser.next怎么用?Java KXmlParser.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kxml2.io.KXmlParser的用法示例。


在下文中一共展示了KXmlParser.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
public static void main(String[] args) {
		String xmlStr =  "<start>"
			+ "<ThisIsALongTagName/>"
			+ "<ThisIsALongTagName/>"
			+ "<ThisIsALongTagName/>"
			+ "<ThisIsALongTagName/>"
			+ "<ThisIsALongTagName/>"
			+ "<ThisIsALongTagName/>"
			+ "</start>";
	System.out.println("xmlStr length: " + xmlStr.length());

	ByteArrayInputStream bais = new ByteArrayInputStream(xmlStr.getBytes());
	InputStreamReader isr = new InputStreamReader(bais);

	try {
	    KXmlParser parser = new KXmlParser();
	    parser.setInput(isr);
	    while (parser.next() != XmlPullParser.END_DOCUMENT) {
		if (parser.getEventType() == XmlPullParser.START_TAG) {
		    System.out.println("start tag: " + parser.getName());
		}
	    }
	} catch (Exception ex) {
	    ex.printStackTrace();
	}
}
 
开发者ID:stefanhaustein,项目名称:kxml2,代码行数:27,代码来源:LongStringTest.java

示例2: hasLayoutParams

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
@VisibleForTesting
static boolean hasLayoutParams(@NonNull Reader reader)
        throws XmlPullParserException, IOException {
    KXmlParser parser = new KXmlParser();
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
    parser.setInput(reader);

    while (true) {
        int event = parser.next();
        if (event == XmlPullParser.START_TAG) {
            for (int i = 0; i < parser.getAttributeCount(); i++) {
                if (parser.getAttributeName(i).startsWith(ATTR_LAYOUT_RESOURCE_PREFIX)) {
                    String prefix = parser.getAttributePrefix(i);
                    if (prefix != null && !prefix.isEmpty() &&
                            ANDROID_URI.equals(parser.getNamespace(prefix))) {
                        return true;
                    }
                }
            }

            return false;
        } else if (event == XmlPullParser.END_DOCUMENT) {
            return false;
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:LayoutInflationDetector.java

示例3: parse

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private List<PinConfig> parse(InputStream configFileStream) throws XmlPullParserException, IOException{
	
	List<PinConfig> pins = null;
	KXmlParser parser = new KXmlParser();
	
	// We set to null the encoding type. The parser should then dected it from the file stream.
	parser.setInput(configFileStream, null);
	
	int eventType = parser.getEventType();
	while( eventType != XmlPullParser.END_DOCUMENT) {
	
		if( eventType == XmlPullParser.START_TAG){
			if( parser.getName().equals( PinsElement)) {
				// We move to the next element inside the Wires element
				parser.next();
				pins = parsePinsElement(parser);
				break;
			}
		}
		
		eventType = parser.next();
	}
	return pins;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:25,代码来源:ConfigReader.java

示例4: parsePinsElement

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private List<PinConfig> parsePinsElement(KXmlParser parser) throws XmlPullParserException, IOException {
	
	List<PinConfig> pins = new ArrayList<PinConfig>();
	
	int eventType = parser.getEventType();
	while( eventType != XmlPullParser.END_TAG) {
		
		if(eventType == XmlPullParser.START_TAG) {
			if (parser.getName().equals(PinElement)) {
				pins.add(this.parsePinElement(parser));
			}
		}
		
		eventType = parser.next();
	}
	
	return pins;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:19,代码来源:ConfigReader.java

示例5: parseStatesElement

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private void parseStatesElement(KXmlParser parser) throws XmlPullParserException, IOException {
	
	int eventType = parser.next();
	while( eventType != XmlPullParser.END_TAG) {
		
		if(eventType == XmlPullParser.START_TAG) {
			if(parser.getName().equals( StateElement)) {
				ModbusState mdbSt= parseStateElement(parser);
				if( mdbSt != null) {
					states.add(mdbSt);
				}
			}
		}
		eventType = parser.next();
	}
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:17,代码来源:ModbusDeviceConfig.java

示例6: parseElement

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private String parseElement(KXmlParser parser) throws XmlPullParserException, IOException {
	
	int eventType = parser.getEventType();
	String element = null;
	
	eventType = parser.next();
	while( eventType != XmlPullParser.END_TAG) {
		
		if( eventType == XmlPullParser.TEXT) {
			element = parser.getText();
			if(element.trim().length() == 0) element = null;
		} else if( eventType == XmlPullParser.START_TAG) {
			// We skip this subtree
			parser.skipSubTree();
			// SkipSubTree position us on the corresponding end tag
		}
		eventType = parser.next();
	}
	
	return element;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:22,代码来源:WireConfig.java

示例7: parseMeasurementsElement

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private List<SensorData> parseMeasurementsElement(KXmlParser parser) throws XmlPullParserException, IOException {
	
	List<SensorData> sensorDatas = new ArrayList<SensorData>();
	
	int eventType = parser.getEventType();
	while( eventType != XmlPullParser.END_TAG) {
		
		if(eventType == XmlPullParser.START_TAG) {
			if (parser.getName().equals(ContentDataElement)) {
				sensorDatas.add(this.parseMeasurementElement(parser));
			}
		}
		
		eventType = parser.next();
	}
	
	return sensorDatas;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:19,代码来源:SensorNodeConfig.java

示例8: parseGetText

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private String parseGetText(KXmlParser parser) throws XmlPullParserException, IOException {
	
	int eventType = parser.getEventType();
	String text = null;
	
	eventType = parser.next();
	while( eventType != XmlPullParser.END_TAG) {
		
		if( eventType == XmlPullParser.TEXT) {
			text = parser.getText();
			if(text.trim().length() == 0) text = null;
		} else if( eventType == XmlPullParser.START_TAG) {
			// We skip this subtree
			parser.skipSubTree();
			// SkipSubTree position us on the corresponding end tag
		}
		eventType = parser.next();
	}
	
	return text;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:22,代码来源:SensorNodeConfig.java

示例9: parse

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
public void parse(InputStream configFileStream) throws IOException {
	
	KXmlParser parser = new KXmlParser();
	try {
		// We set to null the encoding type. The parser should then dected it from the file stream.
		parser.setInput(configFileStream, null);
		
		int eventType = parser.getEventType();
		while( eventType != XmlPullParser.END_DOCUMENT) {
		
			if( eventType == XmlPullParser.START_TAG){
				if( parser.getName().equals( ModbusDeviceElement)) {
					// We move to the next element inside the Wires element
					parser.next();
					parseModbusDeviceElement(parser);
					break;
				}
			}
			
			eventType = parser.next();
		}
	} catch (XmlPullParserException e) {
		Activator.log(LogService.LOG_INFO, "ModbusDeviceConfig reader, problem while reading the configuration: " + e.toString());
	}
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:26,代码来源:ModbusDeviceConfig.java

示例10: parseReferencesElement

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private void parseReferencesElement(KXmlParser parser) throws XmlPullParserException, IOException {

	int eventType = parser.next();
	while( eventType != XmlPullParser.END_TAG) {
		
		if(eventType == XmlPullParser.START_TAG) {
			if(parser.getName().equals( ReferenceElement)) {
				ModbusReference mdbRef= parseReferenceElement(parser);
				if( mdbRef != null) {
					references.add(mdbRef);
				}
			}
		}
		eventType = parser.next();
	}

}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:18,代码来源:ModbusDeviceConfig.java

示例11: parseMeasurementsElement

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private void parseMeasurementsElement(KXmlParser parser) throws XmlPullParserException, IOException {

	int eventType = parser.next();
	while( eventType != XmlPullParser.END_TAG) {
		
		if(eventType == XmlPullParser.START_TAG) {
			if(parser.getName().equals( MeasurementElement)) {
				ModbusMeasurement mdbMsr= parseMeasurementElement(parser);
				if( mdbMsr != null) {
					measurements.add(mdbMsr);
				}
			}
		}
		eventType = parser.next();
	}
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:17,代码来源:ModbusDeviceConfig.java

示例12: parseCoilsElement

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private void parseCoilsElement(KXmlParser parser) throws XmlPullParserException, IOException {
	
	int eventType = parser.next();
	while( eventType != XmlPullParser.END_TAG) {
		
		if(eventType == XmlPullParser.START_TAG) {
			if(parser.getName().equals( CoilElement)) {
				ModbusSwitch mdbSw= parseCoilElement(parser);
				if( mdbSw != null) {
					switches.add(mdbSw);
				}
			}
		}
		eventType = parser.next();
	}
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:17,代码来源:ModbusDeviceConfig.java

示例13: parseStateElement

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private ModbusState parseStateElement(KXmlParser parser ) throws XmlPullParserException, IOException {
	
	ModbusState mdbState = null;
	
	String identification = null;
	String scope = null;
	int adress = 0;
	int length = 0;
	
	int eventType = parser.getEventType();
	while( eventType != XmlPullParser.END_TAG) {
		
		if(eventType == XmlPullParser.START_TAG) {
			if(parser.getName().equals( IdentificationElement)) {
				identification = parseGetText(parser);
			} else if (parser.getName().equals(ScopeElement)) {
				scope = parseGetText(parser);
			} else if (parser.getName().equals(AdressElement)) {
				adress = (new Integer(parseGetText(parser))).intValue();
			} else if (parser.getName().equals(LengthElement)) {
				length = (new Integer(parseGetText(parser))).intValue();
			}
		}
	
		eventType = parser.next();
	}
	
	if(( identification != null) && ( scope != null) && (length > 0)){
		mdbState = new ModbusState(identification, scope, adress, length);
	}
	
	return mdbState;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:34,代码来源:ModbusDeviceConfig.java

示例14: parseWire

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private void parseWire( KXmlParser parser) throws XmlPullParserException, IOException {
	
	int eventType = parser.getEventType();
	
	String consumer = null;
	String producer = null;
	String consumerFilter = null;
	String producerFilter = null;
	
	while( eventType != XmlPullParser.END_TAG) {
		
		if(eventType == XmlPullParser.START_TAG ) {
			if(parser.getName().equals(ConsumerElement)){
				consumer = parseElement(parser);
			} else if(parser.getName().equals(ProducerElement)){
				producer = parseElement(parser);
			} else if ( parser.getName().equals(ConsumerFilter)) {
				consumerFilter = parseElement(parser);
			} else if ( parser.getName().equals(ProducerFilter)) {
				producerFilter = parseElement(parser);
			}
		}
		
		eventType = parser.next();
	}
	
	if( consumer != null & producer != null ){
		wireAdmin.createWire(producer,consumer,null);
		producer = null;
		consumer = null;
	} else {
		wireAdmin.createWire(producer, producerFilter, consumer, consumerFilter, null);
	}
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:35,代码来源:WireConfig.java

示例15: parse

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
public static XmlNode parse(Reader reader, boolean ignoreWhitespaces) throws Exception {
    KXmlParser parser = new KXmlParser();
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
    parser.setInput(reader);
    parser.next();
    XmlNode node = _parse(parser, ignoreWhitespaces);

    return node;
}
 
开发者ID:Ericsson-LMF,项目名称:IoT-Gateway,代码行数:10,代码来源:XmlParser.java


注:本文中的org.kxml2.io.KXmlParser.next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。