當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLStreamReader.START_ELEMENT屬性代碼示例

本文整理匯總了Java中javax.xml.stream.XMLStreamReader.START_ELEMENT屬性的典型用法代碼示例。如果您正苦於以下問題:Java XMLStreamReader.START_ELEMENT屬性的具體用法?Java XMLStreamReader.START_ELEMENT怎麽用?Java XMLStreamReader.START_ELEMENT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.xml.stream.XMLStreamReader的用法示例。


在下文中一共展示了XMLStreamReader.START_ELEMENT屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readResponse

final Object readResponse(Object[] args, XMLStreamReader r, AttachmentSet att) throws JAXBException {
    Object obj;
    AttachmentUnmarshallerImpl au = (att != null)?new AttachmentUnmarshallerImpl(att):null;
    if (bridge instanceof RepeatedElementBridge) {
        RepeatedElementBridge rbridge = (RepeatedElementBridge)bridge;
        ArrayList list = new ArrayList();
        QName name = r.getName();
        while (r.getEventType()==XMLStreamReader.START_ELEMENT && name.equals(r.getName())) {
            list.add(rbridge.unmarshal(r, au));
            XMLStreamReaderUtil.toNextTag(r, name);
        }
        obj = rbridge.collectionHandler().convert(list);
    } else {
        obj = bridge.unmarshal(r, au);
    }
    return setter.put(obj,args);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:ResponseBuilder.java

示例2: readRequest

void readRequest( Object[] args, XMLStreamReader r, AttachmentSet att) throws JAXBException {
    Object obj = null;
    AttachmentUnmarshallerImpl au = (att != null)?new AttachmentUnmarshallerImpl(att):null;
    if (bridge instanceof RepeatedElementBridge) {
        RepeatedElementBridge rbridge = (RepeatedElementBridge)bridge;
        ArrayList list = new ArrayList();
        QName name = r.getName();
        while (r.getEventType()==XMLStreamReader.START_ELEMENT && name.equals(r.getName())) {
            list.add(rbridge.unmarshal(r, au));
            XMLStreamReaderUtil.toNextTag(r, name);
        }
        obj = rbridge.collectionHandler().convert(list);
    } else {
        obj = bridge.unmarshal(r, au);
    }
    setter.put(obj,args);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:EndpointArgumentsBuilder.java

示例3: readWrappedRequest

protected void readWrappedRequest(Message msg, Object[] args) throws JAXBException, XMLStreamException {
    if (!msg.hasPayload()) {
        throw new WebServiceException("No payload. Expecting payload with "+wrapperName+" element");
    }
    XMLStreamReader reader = msg.readPayload();
    XMLStreamReaderUtil.verifyTag(reader,wrapperName);
    reader.nextTag();
    while(reader.getEventType()==XMLStreamReader.START_ELEMENT) {
        // TODO: QName has a performance issue
        QName name = reader.getName();
        WrappedPartBuilder part = wrappedParts.get(name);
        if(part==null) {
            // no corresponding part found. ignore
            XMLStreamReaderUtil.skipElement(reader);
            reader.nextTag();
        } else {
            part.readRequest(args,reader, msg.getAttachments());
        }
        XMLStreamReaderUtil.toNextTag(reader, name);
    }

    // we are done with the body
    reader.close();
    XMLStreamReaderFactory.recycle(reader);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:EndpointArgumentsBuilder.java

示例4: soapBodyFirstChildReader

protected XMLStreamReader soapBodyFirstChildReader() {
    if (soapBodyFirstChildReader != null) return soapBodyFirstChildReader;
    soapBodyFirstChild();
    if (soapBodyFirstChild != null) {
        soapBodyFirstChildReader = getXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader == null) soapBodyFirstChildReader =
            createXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader.getEventType() == XMLStreamReader.START_DOCUMENT) {
            try {
                while(soapBodyFirstChildReader.getEventType() != XMLStreamReader.START_ELEMENT)
                    soapBodyFirstChildReader.next();
            } catch (XMLStreamException e) {
                throw new RuntimeException(e);
            }
        }
        return soapBodyFirstChildReader;
    } else {
        payloadLocalName = null;
        payloadNamespace = null;
        return null;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:SAAJMessage.java

示例5: readTag

/**
 * Reads the next tag from the pull parser and throws an exception if its name does not
 * match <var>expectedTagName</var>.
 *
 * @param xmlPullParser The pull parser to read from
 * @param expectedTagName The tag name expected
 */
public static void readTag(XMLStreamReader xmlStreamReader, String expectedTagName) {
  // Look for any start tag event
  int event;
  try {
    do {
      event = xmlStreamReader.next();
    } while (event == XMLStreamReader.CHARACTERS || event == XMLStreamReader.END_ELEMENT || event == XMLStreamReader.COMMENT);
  } catch (Exception e) {
    throw new RuntimeException("Error reading data from the XML pull parser", e);
  }

  if (event == XMLStreamReader.START_ELEMENT) {
    if (!expectedTagName.equals(xmlStreamReader.getLocalName())) {
      throw new IllegalArgumentException("Expected tag [" + expectedTagName + "] but got [" + xmlStreamReader.getLocalName() + "]");
    }

  } else if (event == XMLStreamReader.END_DOCUMENT) {
    throw new IllegalStateException("Unexpected end of document while looking for tag [" + expectedTagName + "]");

  } else {
    throw new IllegalStateException("Expecting a tag but found [" + event + "]");
  }
}
 
開發者ID:alfasoftware,項目名稱:morf,代碼行數:30,代碼來源:XmlPullProcessor.java

示例6: storeDocumentAndChildren

private void storeDocumentAndChildren(XMLStreamReader reader) throws XMLStreamException {
    storeStructure(T_DOCUMENT);

    _eventType = reader.next();
    while (_eventType != XMLStreamReader.END_DOCUMENT) {
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                storeElementAndChildren(reader);
                continue;
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
        _eventType = reader.next();
    }

    storeStructure(T_END);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:StreamReaderBufferCreator.java

示例7: store

private void store(XMLStreamReader reader) throws XMLStreamException {
    if (!reader.hasNext()) {
        return;
    }

    _eventType = reader.getEventType();
    switch (_eventType) {
        case XMLStreamReader.START_DOCUMENT:
            storeDocumentAndChildren(reader);
            break;
        case XMLStreamReader.START_ELEMENT:
            storeElementAndChildren(reader);
            break;
        default:
            throw new XMLStreamException("XMLStreamReader not positioned at a document or element");
    }

    increaseTreeCount();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:StreamReaderBufferCreator.java

示例8: readNextTagInsideParent

/**
 * Reads the next tag name from the XML parser so long as it lies within the parent tag name.
 * If the close tag event for the parent is read this method will return null. Otherwise it
 * returns the name of the tag read.
 *
 * @param parentTagName The enclosing tag that forms the limit for the read operation.
 * @return The next tag name or null if there are no more tags to read inside the specified parent.
 */
protected String readNextTagInsideParent(String parentTagName) {
  int event;
  try {
    do {
      event = xmlStreamReader.next();
    } while (event == XMLStreamReader.CHARACTERS ||
             event == XMLStreamReader.COMMENT ||
             event == XMLStreamReader.END_ELEMENT && !xmlStreamReader.getLocalName().equals(parentTagName));
  } catch (Exception e) {
    throw new RuntimeException("Error reading data from the XML pull parser", e);
  }

  if (event == XMLStreamReader.START_ELEMENT) {
    return xmlStreamReader.getLocalName();

  } else if (event == XMLStreamReader.END_ELEMENT) {
    return null;

  } else if (event == XMLStreamReader.END_DOCUMENT) {
    throw new IllegalStateException("Unexpected end of document while looking for a tag inside [" + parentTagName + "]");

  } else {
    throw new IllegalStateException("Expecting a tag inside [" + parentTagName + "] but got [" + event + "]");
  }
}
 
開發者ID:alfasoftware,項目名稱:morf,代碼行數:33,代碼來源:XmlPullProcessor.java

示例9: testStartElement

@Test
public void testStartElement() {
    try {
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader xsr = xif.createXMLStreamReader(this.getClass().getResource(INPUT_FILE).toExternalForm(),
                this.getClass().getResourceAsStream(INPUT_FILE));

        while (xsr.hasNext()) {
            int event = xsr.next();
            if (event == XMLStreamReader.START_ELEMENT) {
                String localName = xsr.getLocalName();
                boolean print = "para".equals(localName);
                int nrOfAttr = xsr.getAttributeCount();
                if (print) {
                    Assert.assertTrue(nrOfAttr > 0, "Default attribute declared in DTD is missing");
                }

            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Exception occured: " + e.getMessage());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:Bug6370703.java

示例10: getParameters

public static void getParameters(XMLStreamReader reader, APICall query) throws Exception
{
	while (reader.hasNext()) 
	{
		int currentEvent = reader.next();
		if(currentEvent ==  XMLStreamReader.START_ELEMENT)
		{
			if(reader.getLocalName().equalsIgnoreCase("query"))
			{
				query.addParameter(reader.getElementText());
				return;
			}
		}
	}
}
 
開發者ID:scriptkittie,項目名稱:bandcamp-api,代碼行數:15,代碼來源:ConfigUtil.java

示例11: getNextSpectrumFromSeekable

private T getNextSpectrumFromSeekable() {
	FromXMLStreamBuilder<T> spectrumBuilder = null;
	try {
		InputStream is = Channels.newInputStream(this.seekable);
		XMLStreamReader xr = XMLInputFactory.newInstance()
			.createXMLStreamReader(is);
		
		while (xr.hasNext()) {
			xr.next();
			
			if (spectrumBuilder != null) {
				spectrumBuilder.accept(xr);
			}

			if(xr.getEventType() == XMLStreamReader.START_ELEMENT){
				if(xr.getLocalName().equals("spectrum")) {
					spectrumBuilder = this.factory.create(this.xml.toString(), xr);
				} else if( xr.getLocalName().equals("referenceableParamGroupRef")) {
					LOGGER.log(Level.WARN, "Random access to spectra will not parse referenceable params");
				}
			} else if(xr.getEventType() == XMLStreamReader.END_ELEMENT) {
				if(xr.getLocalName().equals("spectrum")) {
					return spectrumBuilder.build();
				}					
			}
		}
	} catch (XMLStreamException | FactoryConfigurationError e) {
		LOGGER.log(Level.ERROR, e.toString());
	} 

	return null;
}
 
開發者ID:digitalproteomics,項目名稱:dp-mzml,代碼行數:32,代碼來源:MzMLStAXParser.java

示例12: moveToNextElement

private int moveToNextElement(XMLStreamReader streamReader) throws XMLStreamException {
	int event = streamReader.getEventType();
	while (event != XMLStreamReader.START_ELEMENT && event != XMLStreamReader.END_DOCUMENT) {
		event = streamReader.next();
	}
	return event;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:7,代碼來源:Jaxb2CollectionHttpMessageConverter.java

示例13: createElementFragment

/**
 * Creates the buffer from a stream reader that is an element fragment.
 * <p>
 * The stream reader will be moved to the position of the next start of
 * an element if the stream reader is not already positioned at the start
 * of an element.
 * <p>
 * The element and all its children will be stored and after storing the stream
 * will be positioned at the next event after the end of the element.
 * <p>
 * @param storeInScopeNamespaces true if in-scope namespaces of the element
 *        fragment should be stored.
 * @return the mutable stream buffer.
 * @throws XMLStreamException if the stream reader cannot be positioned at
 *         the start of an element.
 */
public MutableXMLStreamBuffer createElementFragment(XMLStreamReader reader,
        boolean storeInScopeNamespaces) throws XMLStreamException {
    if (_buffer == null) {
        createBuffer();
    }

    if (!reader.hasNext()) {
        return _buffer;
    }

    _storeInScopeNamespacesOnElementFragment = storeInScopeNamespaces;

    _eventType = reader.getEventType();
    if (_eventType != XMLStreamReader.START_ELEMENT) {
        do {
            _eventType = reader.next();
        } while(_eventType != XMLStreamReader.START_ELEMENT && _eventType != XMLStreamReader.END_DOCUMENT);
    }

    if (storeInScopeNamespaces) {
        _inScopePrefixes = new HashMap<String,Integer>();
    }

    storeElementAndChildren(reader);

    return getXMLStreamBuffer();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:43,代碼來源:StreamReaderBufferCreator.java

示例14: nextTag

@Override
public int nextTag() throws XMLStreamException {
    int e = next();
    if (e == XMLStreamReader.END_DOCUMENT) return e;
    while (e != XMLStreamReader.END_DOCUMENT) {
        if (e == XMLStreamReader.START_ELEMENT) return e;
        if (e == XMLStreamReader.END_ELEMENT) return e;
        e = next();
    }
    return e;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:XMLReaderComposite.java

示例15: getEventType

@Override
public int getEventType() {
    switch (state) {
    case StartTag: return XMLStreamReader.START_ELEMENT;
    case EndTag: return XMLStreamReader.END_ELEMENT;
    case Payload:
    default:
        return payloadReader.getEventType();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:XMLReaderComposite.java


注:本文中的javax.xml.stream.XMLStreamReader.START_ELEMENT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。