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


Java KXmlParser.getEventType方法代码示例

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


在下文中一共展示了KXmlParser.getEventType方法的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: parseProgressFromRetryResult

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private boolean parseProgressFromRetryResult(RemoteDataPullResponse response) {
    try {
        InputStream stream = response.writeResponseToCache(syncTask.context).retrieveCache();
        KXmlParser parser = ElementParser.instantiateParser(stream);
        parser.next();
        int eventType = parser.getEventType();
        do {
            if (eventType == KXmlParser.START_TAG) {
                if (parser.getName().toLowerCase().equals("progress")) {
                    serverProgressCompletedSoFar = Integer.parseInt(
                            parser.getAttributeValue(null, "done"));
                    serverProgressTotal = Integer.parseInt(
                            parser.getAttributeValue(null, "total"));
                    return true;
                }
            }
            eventType = parser.next();
        } while (eventType != KXmlParser.END_DOCUMENT);
    } catch (IOException | XmlPullParserException e) {
        Logger.log(LogTypes.TYPE_USER,
                "Error while parsing progress values of retry result");
    }
    return false;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:25,代码来源:AsyncRestoreHelper.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: 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,代码来源:ConfigReader.java

示例6: parse

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private List<SensorData> parse(InputStream configFileStream) throws XmlPullParserException, IOException{
	
	List<SensorData> sensorNodes = 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( ContentDatasElement)) {
				// We move to the next element inside the Wires element
				parser.next();
				sensorNodes = parseMeasurementsElement(parser);
				break;
			}
		}
		
		eventType = parser.next();
	}
	
	
	return sensorNodes;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:27,代码来源:SensorNodeConfig.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: 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

示例9: 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

示例10: 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( WireAdminElement)) {
					// We move to the next element inside the Wires element
					parser.next();
					parseWires(parser);
				}
			}
			
			eventType = parser.next();
		}
	} catch (XmlPullParserException e) {
		Activator.log(LogService.LOG_INFO, "WireConfig reader, problem while reading the configuration: " + e.toString());
	}
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:25,代码来源:WireConfig.java

示例11: parseWires

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private void parseWires( KXmlParser parser) throws XmlPullParserException, IOException{
	
	int eventType = parser.getEventType();
	while( eventType != XmlPullParser.END_TAG) {
		
		if(eventType == XmlPullParser.START_TAG) {
			if(parser.getName().equals( WireElement)) {
				// We move to the next elemeent inside the Wire elemente
				parser.next();
				parseWire(parser);
			}
		}
		
		eventType = parser.next();
	}
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:17,代码来源:WireConfig.java

示例12: _parse

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
static XmlNode _parse(KXmlParser parser, boolean ignoreWhitespaces) throws Exception {
    XmlNode node = new XmlNode();

    if (parser.getEventType() != XmlPullParser.START_TAG) {
        if (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
            return node;
        }
        throw new Exception("Illegal XML state: " + parser.getName() + ", " + parser.getEventType());
    } else {
        node.name = parser.getName();

        for (int i = 0; i < parser.getAttributeCount(); i++) {
            node.attributes.put(parser.getAttributeName(i), parser.getAttributeValue(i));
        }

        parser.next();

        while (parser.getEventType() != XmlPullParser.END_TAG) {
            if (parser.getEventType() == XmlPullParser.START_TAG) {
                node.children.add(_parse(parser, ignoreWhitespaces));
            } else if (parser.getEventType() == XmlPullParser.TEXT && !ignoreWhitespaces || !parser.isWhitespace()) {
                node.text += parser.getText();
            }
            parser.next();
        }
    }
    return node;
}
 
开发者ID:Ericsson-LMF,项目名称:IoT-Gateway,代码行数:29,代码来源:XmlParser.java

示例13: parsePinElement

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private PinConfig parsePinElement(KXmlParser parser) throws XmlPullParserException, IOException {
	
	PinConfig pin = new PinConfig();
	
	int eventType = parser.getEventType();
	while( eventType != XmlPullParser.END_TAG) {
		
		if(eventType == XmlPullParser.START_TAG) {
			if (parser.getName().equals(IdentificationElement)) {
				pin.setIdentification(parseGetText(parser));
			} else if (parser.getName().equals(ScopeElement)) {
				pin.setScope(parseGetText(parser));
			} else if (parser.getName().equals(UnitElement)) {
				pin.setUnit(parseGetText(parser));
			} else if (parser.getName().equals(ScalingElement)) {
				pin.setScale(Double.valueOf(parseGetText(parser)));
			} else if (parser.getName().equals(OffsetElement)) {
				pin.setOffset(Double.valueOf(parseGetText(parser)));	
			} else if (parser.getName().equals(DirectionIn)) {
				pin.setDirectionIn(Boolean.valueOf(parseGetText(parser)));	
			} else if (parser.getName().equals(Digital)) {
				pin.setDigital(Boolean.valueOf(parseGetText(parser)));	
			} else if (parser.getName().equals(PinNumber)) {
				pin.setPinNumber(Integer.valueOf(parseGetText(parser)));	
			}
		}
		
		eventType = parser.next();
	}
	
	return pin;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:33,代码来源:ConfigReader.java

示例14: parseMeasurementElement

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private SensorData parseMeasurementElement(KXmlParser parser) throws XmlPullParserException, IOException {
	
	SensorData sensorData = new SensorData();
	
	int eventType = parser.getEventType();
	while( eventType != XmlPullParser.END_TAG) {
		
		if(eventType == XmlPullParser.START_TAG) {
			if (parser.getName().equals(DataIdElement)) {
				sensorData.setId(Integer.valueOf(parseGetText(parser)));
			} else if (parser.getName().equals(IdentificationElement)) {
				sensorData.setIdentification(parseGetText(parser));
			} else if (parser.getName().equals(ScopeElement)) {
				sensorData.setScope(parseGetText(parser));
			} else if (parser.getName().equals(UnitElement)) {
				sensorData.setUnit(parseGetText(parser));
			} else if (parser.getName().equals(ScalingElement)) {
				sensorData.setScale(Double.valueOf(parseGetText(parser)));
			} else if (parser.getName().equals(OffsetElement)) {
				sensorData.setOffset(Double.valueOf(parseGetText(parser)));	
			}
		}
		
		eventType = parser.next();
	}
	
	return sensorData;
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:29,代码来源:SensorNodeConfig.java

示例15: parseModbusDeviceElement

import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
public void parseModbusDeviceElement(KXmlParser parser) throws XmlPullParserException, IOException {
		
	int eventType = parser.getEventType();
	while( eventType != XmlPullParser.END_TAG) {
		
		if(eventType == XmlPullParser.START_TAG) {
			if (parser.getName().equals(ReferencesElement)) {
				this.parseReferencesElement(parser);
			} else if (parser.getName().equals(MeasurementsElement)) {
				this.parseMeasurementsElement(parser);
			} else if (parser.getName().equals(StatesElement)) {
				this.parseStatesElement(parser);
			} else if( parser.getName().equals(CoilsElement)) {
				this.parseCoilsElement(parser);
			}
		}
		
		eventType = parser.next();
	}
	
	// Finaly, if we have found all properties necessary, 
	if(( port != null) & (id != null) & (compositeIdentity != null) & (poolingRate != null)) {
		
		try {
			ModbusDevice newDevice = null;
			if( isMock.booleanValue()) {
				newDevice = new ModbusDeviceMockImpl(this.pid, compositeIdentity, port, id.intValue(), poolingRate.intValue(), references,measurements, states, switches);
			} else {
			//... then whe can create a new modbus device
				newDevice = new ModbusDeviceImpl(this.pid, compositeIdentity, port, id.intValue(), poolingRate.intValue(), references, measurements, states, switches);
			}
			// .. and add it to the factory (id creation went ok.
			factory.add(pid, newDevice);
		} catch ( Exception ex) {
			
		}
	}
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:39,代码来源:ModbusDeviceConfig.java


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