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


Java XMLStreamReader2.next方法代码示例

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


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

示例1: parseGsafeedElement

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
private Feed parseGsafeedElement(String datasource, String feedtype, XMLStreamReader2 xmlReader) throws XMLStreamException, ParseFeedException  {
	List<FeedGroup> groups = new ArrayList<FeedGroup>();
	while (xmlReader.hasNext()) {
		xmlReader.next();
		if (xmlReader.getEventType() == XMLStreamConstants.START_ELEMENT) {
			if (XML_GSAFEED.equals(xmlReader.getLocalName())) {
				//Ignored
			}
			if (XML_HEADER.equals(xmlReader.getLocalName())) {
				//datasource
				//feedtype
			}
			if (XML_GROUP.equals(xmlReader.getLocalName())) {
				FeedGroup group = this.parseGroupElement(datasource, feedtype, xmlReader);
				groups.add(group);
			}
		}
	}
	return new FeedImpl(datasource, feedtype, groups);
}
 
开发者ID:BassJel,项目名称:Jouve-Project,代码行数:21,代码来源:FeedStaxParser.java

示例2: parseGroupElement

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
private FeedGroup parseGroupElement(String datasource, String feedtype, XMLStreamReader2 xmlReader) throws ParseFeedException, XMLStreamException {
	List<FeedRecord> records = new ArrayList<FeedRecord>();
	String action = xmlReader.getAttributeValue("", XML_GROUP_ACTION);
	while (xmlReader.hasNext()) {
		xmlReader.next();
		if (xmlReader.getEventType() == XMLStreamConstants.START_ELEMENT) {
			if (XML_RECORD.equals(xmlReader.getLocalName())) {
				FeedRecord record = this.parseRecordElement(datasource, feedtype, action, xmlReader);
				records.add(record);
			}
		}
		if (xmlReader.getEventType() == XMLStreamConstants.END_ELEMENT) {
			if (XML_GROUP.equals(xmlReader.getLocalName())) {
				break;
			}
		}		
	}	
	
	FeedGroup group = new FeedGroupImpl(action, records);
	return group;
}
 
开发者ID:BassJel,项目名称:Jouve-Project,代码行数:22,代码来源:FeedStaxParser.java

示例3: parseMetadataElement

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
private FeedMetadata parseMetadataElement(XMLStreamReader2 xmlReader) throws ParseFeedException, XMLStreamException {
	//in metadata element
	List<FeedMeta> metas = new ArrayList<FeedMeta>();
	while (xmlReader.hasNext()) {
		xmlReader.next();
		if (xmlReader.getEventType() == XMLStreamConstants.START_ELEMENT) {
			if (XML_META.equals(xmlReader.getLocalName())) {
				FeedMeta meta = this.parseMetaElement(xmlReader);
				metas.add(meta);
			}
		}
		if (xmlReader.getEventType() == XMLStreamConstants.END_ELEMENT) {
			if (XML_METADATA.equals(xmlReader.getLocalName())) {
				break;
			}
		}
	}
	FeedMetadata metadata = new FeedMetadataImpl(metas);
	return metadata;
}
 
开发者ID:BassJel,项目名称:Jouve-Project,代码行数:21,代码来源:FeedStaxParser.java

示例4: parseForwardingRule

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseForwardingRule(NetPlan netPlan, long layerId, XMLStreamReader2 xmlStreamReader , DoubleMatrix2D f_de) throws XMLStreamException
{
	long linkId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "linkId"));
	long demandId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "demandId"));
	double splittingRatio = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "splittingRatio"));

	f_de.set (mapOldId2Demand.get(Pair.of (layerId,demandId)).index , mapOldId2Link.get(Pair.of(layerId , linkId)).index  , splittingRatio);

	while(xmlStreamReader.hasNext())
	{
		xmlStreamReader.next();

		switch(xmlStreamReader.getEventType())
		{
			case XMLEvent.START_ELEMENT:
				String startElementName = xmlStreamReader.getName().toString();
				switch(startElementName)
				{
					case "attribute":
						break;

					default:
						throw new RuntimeException("Bad");
				}

				break;

			case XMLEvent.END_ELEMENT:
				String endElementName = xmlStreamReader.getName().toString();
				if (endElementName.equals("forwardingRule")) return;
				break;
		}
	}

	throw new RuntimeException("'Forwarding rule' element not parsed correctly (end tag not found)");
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:37,代码来源:ReaderNetPlanN2PVersion_3.java

示例5: parsePhysicalTopology

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parsePhysicalTopology(NetPlan netPlan, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
	while(xmlStreamReader.hasNext())
	{
		xmlStreamReader.next();

		switch(xmlStreamReader.getEventType())
		{
			case XMLEvent.START_ELEMENT:
				String startElementName = xmlStreamReader.getName().toString();
				switch(startElementName)
				{
					case "node":
						parseNode(netPlan, xmlStreamReader);
						break;
						
					case "link":
						parseLink(netPlan, xmlStreamReader);
						break;

					default:
						throw new RuntimeException("Bad");
				}
				break;

			case XMLEvent.END_ELEMENT:
				String endElementName = xmlStreamReader.getName().toString();
				if (endElementName.equals("physicalTopology")) return;
				break;
		}
	}

	throw new RuntimeException("'Physical topology' element not parsed correctly (end tag not found)");
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:35,代码来源:ReaderNetPlanN2PVersion_1.java

示例6: parseNode

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseNode(NetPlan netPlan, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
	long nodeId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "id"));
	double xCoord = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "xCoord"));
	double yCoord = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "yCoord"));
	String nodeName = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "name"));
	Node newNode = netPlan.addNode(xCoord, yCoord, nodeName, null);
	mapOldId2Node.put (nodeId , newNode);

	while(xmlStreamReader.hasNext())
	{
		xmlStreamReader.next();
		switch(xmlStreamReader.getEventType())
		{
			case XMLEvent.START_ELEMENT:
				String startElementName = xmlStreamReader.getName().toString();
				switch(startElementName)
				{
					case "attribute":
						String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key"));
						String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"));
						newNode.setAttribute(key, name);
						break;

					default:
						throw new RuntimeException("Bad");
				}

				break;

			case XMLEvent.END_ELEMENT:
				String endElementName = xmlStreamReader.getName().toString();
				if (endElementName.equals("node")) return;
				break;
		}
	}

	throw new RuntimeException("'Node' element not parsed correctly (end tag not found)");
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:40,代码来源:ReaderNetPlanN2PVersion_2.java

示例7: parseSourceRouting

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseSourceRouting(NetPlan netPlan, long layerId, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
	netPlan.setRoutingType (RoutingType.SOURCE_ROUTING , mapOldId2Layer.get(layerId));

	while(xmlStreamReader.hasNext())
	{
		xmlStreamReader.next();

		switch(xmlStreamReader.getEventType())
		{
			case XMLEvent.START_ELEMENT:
				String startElementName = xmlStreamReader.getName().toString();
				switch(startElementName)
				{
					case "protectionSegment":
						parseProtectionSegment(netPlan, layerId, xmlStreamReader);
						break;

					case "route":
						parseRoute(netPlan, layerId, xmlStreamReader);
						break;

					default:
						throw new RuntimeException("Bad");
				}
				break;

			case XMLEvent.END_ELEMENT:
				String endElementName = xmlStreamReader.getName().toString();
				if (endElementName.equals("sourceRouting")) return;
				break;
		}
	}

	throw new RuntimeException("'Source routing' element not parsed correctly (end tag not found)");
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:37,代码来源:ReaderNetPlanN2PVersion_4.java

示例8: parseSRGInfo

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseSRGInfo(NetPlan netPlan, XMLStreamReader2 xmlStreamReader) throws XMLStreamException
{
	while(xmlStreamReader.hasNext())
	{
		xmlStreamReader.next();

		switch(xmlStreamReader.getEventType())
		{
			case XMLEvent.START_ELEMENT:
				String startElementName = xmlStreamReader.getName().toString();
				switch(startElementName)
				{
					case "srg":
						parseSRG(netPlan, xmlStreamReader);
						break;

					default:
						throw new RuntimeException("Bad");
				}
				break;

			case XMLEvent.END_ELEMENT:
				String endElementName = xmlStreamReader.getName().toString();
				if (endElementName.equals("srgInfo")) return;
				break;
		}
	}

	throw new RuntimeException("'SRG info' element not parsed correctly (end tag not found)");
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:31,代码来源:ReaderNetPlanN2PVersion_1.java

示例9: parseForwardingRule

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void parseForwardingRule(NetPlan netPlan, long layerId, XMLStreamReader2 xmlStreamReader , DoubleMatrix2D f_de) throws XMLStreamException
{
	long linkId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "linkId"));
	long demandId = xmlStreamReader.getAttributeAsLong(xmlStreamReader.getAttributeIndex(null, "demandId"));
	double splittingRatio = xmlStreamReader.getAttributeAsDouble(xmlStreamReader.getAttributeIndex(null, "splittingRatio"));

	f_de.set (mapOldId2Demand.get(demandId).index , mapOldId2Link.get(linkId).index  , splittingRatio);

	while(xmlStreamReader.hasNext())
	{
		xmlStreamReader.next();

		switch(xmlStreamReader.getEventType())
		{
			case XMLEvent.START_ELEMENT:
				String startElementName = xmlStreamReader.getName().toString();
				switch(startElementName)
				{
					case "attribute":
						break;

					default:
						throw new RuntimeException("Bad");
				}

				break;

			case XMLEvent.END_ELEMENT:
				String endElementName = xmlStreamReader.getName().toString();
				if (endElementName.equals("forwardingRule")) return;
				break;
		}
	}

	throw new RuntimeException("'Forwarding rule' element not parsed correctly (end tag not found)");
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:37,代码来源:ReaderNetPlanN2PVersion_4.java

示例10: getSchemaLocation

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
/**
 * Get the xsi:schemaLocation for the OAI response
 * 
 * @return the xsi:schemaLocation value
 */
public String getSchemaLocation() throws TransformerException, ParserConfigurationException, SAXException, IOException, XMLStreamException {
    if (this.schemaLocation == null) {
        if (hasDocument()) {
            this.schemaLocation = getSingleString("/*/@xsi:schemaLocation");
            logger.debug("found schemaLocation["+schemaLocation+"] in the XML tree");
        } else {
            XMLInputFactory2 xmlif = (XMLInputFactory2) XMLInputFactory2.newInstance();
            xmlif.configureForConvenience();
            XMLStreamReader2 xmlr = (XMLStreamReader2) xmlif.createXMLStreamReader(getStream());
            int state = 1; // 1:START 0:STOP -1:ERROR
            while (state > 0) {
                int eventType = xmlr.getEventType();
                switch (eventType) {
                    case XMLEvent2.START_ELEMENT:
                        schemaLocation = xmlr.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","schemaLocation");
                        if (schemaLocation != null)
                            state = 0;
                        break;
                }
                if (xmlr.hasNext())
                    xmlr.next();
                else
                    state = state == 1? 0: -1;// if START then STOP else ERROR
            }
            xmlr.close();
            logger.debug("found schemaLocation["+schemaLocation+"] in the XML stream");
        }

        // The URIs in xsi:schemaLocation are separated by (any kind
        // of) white space. Normalize it to a single space.
        this.schemaLocation = schemaLocation.trim().replaceAll("\\s+", " ");
    }
    return schemaLocation;
}
 
开发者ID:clarin-eric,项目名称:oai-harvest-manager,代码行数:40,代码来源:HarvesterVerb.java

示例11: verifyFailure

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
protected void verifyFailure(String xml, XMLValidationSchema schema, String failMsg,
                             String failPhrase, boolean strict) throws XMLStreamException
{
    XMLStreamReader2 sr = constructStreamReader(getInputFactory(), xml);
    sr.validateAgainst(schema);
    try {
        while (sr.hasNext()) {
            /* int type = */sr.next();
        }
        fail("Expected validity exception for " + failMsg);
    } catch (XMLValidationException vex) {
        String origMsg = vex.getMessage();
        String msg = (origMsg == null) ? "" : origMsg.toLowerCase();
        if (msg.indexOf(failPhrase.toLowerCase()) < 0) {
            String actualMsg = "Expected validation exception for "
                + failMsg + ", containing phrase '" + failPhrase
                + "': got '" + origMsg + "'";
            if (strict) {
                fail(actualMsg);
            }
            warn("suppressing failure due to MSV bug, failure: '"
                 + actualMsg + "'");
        }
        // should get this specific type; not basic stream exception
    } catch (XMLStreamException sex) {
        fail("Expected XMLValidationException for " + failMsg
             + "; instead got " + sex.getMessage());
    }
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:30,代码来源:BaseValidationTest.java

示例12: testFullValidationOk

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
public void testFullValidationOk() throws XMLStreamException
{
    String XML = "<root attr='123'><leaf /></root>";
    XMLValidationSchema schema = parseDTDSchema(SIMPLE_DTD);
    XMLStreamReader2 sr = getReader(XML);
    sr.validateAgainst(schema);
    while (sr.next() != END_DOCUMENT) { }
    sr.close();
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:10,代码来源:TestDTD.java

示例13: testFullValidationIssue23

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
public void testFullValidationIssue23() throws XMLStreamException
{
    final String INPUT_DTD = "<!ELEMENT FreeFormText (#PCDATA) >\n"
            +"<!ATTLIST FreeFormText  xml:lang CDATA #IMPLIED >\n"
            ;
    String XML = "<FreeFormText xml:lang='en-US'>foobar</FreeFormText>";
    XMLInputFactory f = getInputFactory();

    /*
    Resolver resolver = new XMLResolver() {
        @Override
        public Object resolveEntity(String publicID, String systemID, String baseURI, String namespace) {
            return new StringReader(DTD);
        }
    };
    f.setXMLResolver(resolver);
    */

    XMLValidationSchemaFactory schemaFactory =
            XMLValidationSchemaFactory.newInstance(XMLValidationSchema.SCHEMA_ID_DTD);
    XMLValidationSchema schema = schemaFactory.createSchema(new StringReader(INPUT_DTD));
    XMLStreamReader2 sr = (XMLStreamReader2)f.createXMLStreamReader(
            new StringReader(XML));

    sr.validateAgainst(schema);
    while (sr.next() != END_DOCUMENT) {
        /*
        System.err.println("Curr == "+sr.getEventType());
        if (sr.getEventType() == CHARACTERS) {
            System.err.println(" text: "+sr.getText());
        }
        */
    }
    sr.close();
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:36,代码来源:TestDTD.java

示例14: testPartialValidationOk

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
/**
 * And then a test for validating starting when stream points
 * to START_ELEMENT
 */
public void testPartialValidationOk()
    throws XMLStreamException
{
    String XML = "<root attr='123'><leaf /></root>";
    XMLValidationSchema schema = parseDTDSchema(SIMPLE_DTD);
    XMLStreamReader2 sr = getReader(XML);
    assertTokenType(START_ELEMENT, sr.next());
    sr.validateAgainst(schema);
    while (sr.next() != END_DOCUMENT) { }
    sr.close();
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:16,代码来源:TestDTD.java

示例15: parseRecordElement

import org.codehaus.stax2.XMLStreamReader2; //导入方法依赖的package包/类
private FeedRecord parseRecordElement(String datasource, String feedtype, String groupAction, XMLStreamReader2 xmlReader)
		throws ParseFeedException, XMLStreamException {
	//in record element
	
	List<FeedContent> contents = new ArrayList<FeedContent>();
	List<FeedMetadata> metadatas = new ArrayList<FeedMetadata>();
	
	String url = xmlReader.getAttributeValue("", XML_RECORD_URL);
	String displayurl =  xmlReader.getAttributeValue("", XML_RECORD_DISPLAYURL);
	String action = xmlReader.getAttributeValue("", XML_RECORD_ACTION);
	String mimetype =  xmlReader.getAttributeValue("", XML_RECORD_MIMETYPE);
	String authmethod = xmlReader.getAttributeValue("", XML_RECORD_AUTHMETHOD);
	String lastModified = xmlReader.getAttributeValue("", XML_RECORD_LAST_MODIFIED);
	String lock = xmlReader.getAttributeValue("", XML_RECORD_LOCK);

	while (xmlReader.hasNext()) {
		xmlReader.next();
		if (xmlReader.getEventType() == XMLStreamConstants.START_ELEMENT) {
			if (XML_METADATA.equals(xmlReader.getLocalName())) {
				FeedMetadata metadata = parseMetadataElement(xmlReader);
				metadatas.add(metadata);
			}
			if (XML_CONTENT.equals(xmlReader.getLocalName())) {
				FeedContent content = parseContentElement(xmlReader);
				contents.add(content);
			}
		}
		if (xmlReader.getEventType() == XMLStreamConstants.END_ELEMENT) {
			if (XML_RECORD.equals(xmlReader.getLocalName())) {
				break;
			}
		}
	}
	
	FeedRecord record = new FeedRecordImpl(datasource, feedtype, groupAction, url, displayurl, action, mimetype, lastModified, lock, authmethod,
			contents, metadatas);		
	return record;
}
 
开发者ID:BassJel,项目名称:Jouve-Project,代码行数:39,代码来源:FeedStaxParser.java


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