Java 8 StartElement - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 StartElement class.

This code example shows how to use the following methods:getName, getNamespaces
		closeEmptyElementIfNecessary(); 
		doWriteStartElement(this.eventFactory.createStartElement(new QName(namespaceURI, localName, prefix), null, null));
	} 
 
	private void doWriteStartElement(StartElement startElement) throws XMLStreamException {
		this.eventWriter.add(startElement);
		this.endElements.add(this.eventFactory.createEndElement(startElement.getName(), startElement.getNamespaces()));
	} 
 
	@Override 
	public void writeEmptyElement(String localName) throws XMLStreamException {
		closeEmptyElementIfNecessary(); 
		writeStartElement(localName);
		this.emptyElement = true;
	} 
 
	@Override 
	public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException {
		closeEmptyElementIfNecessary(); 
		writeStartElement(namespaceURI, localName);
7
CodeRank
This code example shows how to use the following methods:getAttributes, getName, getNamespaceContext, getNamespaceURI, getNamespaces
This code example shows how to use the following methods:getAttributes, getName, getLocation
    } 
  } 
 
  private void addStartElement(XMLEvent xmlEvent) {
    StartElement se = xmlEvent.asStartElement();
    String tagName = se.getName().getLocalPart();
    globalElementPath.push(tagName);
    ElementPath current = globalElementPath.duplicate();
    StartEvent startEvent = new StartEvent(current, tagName, se.getAttributes(), se.getLocation());
    eventList.add(startEvent);
  } 
 
  private void addCharacters(XMLEvent xmlEvent) {
    Characters characters = xmlEvent.asCharacters();
    StaxEvent lastEvent = getLastEvent();
 
    if (lastEvent instanceof BodyEvent) {
      BodyEvent be = (BodyEvent) lastEvent;
      be.append(characters.getData());
    } else { 
6
CodeRank
This code example shows how to use the following methods:getAttributes, getName, getNamespaceContext, getNamespaces
This code example shows how to use the following methods:getAttributeByName, getName
            this.version = null;
        } 
    } 
     
    public PortalDataKey(StartElement startElement) {
        this.name = startElement.getName();
        this.script = getAttributeValue(startElement, SCRIPT_ATTRIBUTE_NAME);
        this.version = getAttributeValue(startElement, VERSION_ATTRIBUTE_NAME);
    } 
 
    public PortalDataKey(QName name, String script, String version) {
        Validate.notNull(name);
        this.name = name;
        this.script = script;
        this.version = version;
    } 
 
    protected String getAttributeValue(StartElement startElement, QName name) {
        final Attribute versionAttr = startElement.getAttributeByName(name);
        if (versionAttr != null) {

5
CodeRank
This code example shows how to use the following methods:getAttributeByName
    } 
  } 
 
  private SchemaVersion parseVersionFromElement(StartElement element) {
 
    Attribute schemaVersion = element.getAttributeByName(SCHEMA_VERSION_QNAME);
    if (schemaVersion != null) {
      return new SchemaVersion(schemaVersion.getValue());
    } else { 
      throw new OpenGammaRuntimeException("No schema version was found - unable to parse file"); 
    } 
  } 
 
  private XMLEventReader createXmlEventReader() throws XMLStreamException {
    XMLInputFactory factory = XMLInputFactory.newFactory();
    return factory.createXMLEventReader(_reader);
  } 
} 
5
CodeRank
This code example shows how to use the following methods:getAttributeByName
	private String getVersionValue(StartElement startElement) {
		if ( startElement == null ) {
			return null; 
		} 
 
		Attribute versionAttribute = startElement.getAttributeByName( new QName( "version" ) );
		return versionAttribute != null ? versionAttribute.getValue() : DEFAULT_VERSION;
	} 
 
	private StartElement getRootElement(XMLEventReader xmlEventReader) throws XMLStreamException {
		while ( xmlEventReader.hasNext() ) {
			XMLEvent nextEvent = xmlEventReader.nextEvent();
			if ( nextEvent.isStartElement() ) {
				return nextEvent.asStartElement();
			} 
		} 
 
		return null; 
	} 
 
5
CodeRank
This code example shows how to use the following methods:getAttributeByName
     
    public ImmutableUserLayoutXMLEventReader(XMLEventReader wrappedReader) {
        super(wrappedReader);
    } 
 
    @Override 
    protected XMLEvent filterEvent(XMLEvent event, boolean peek) {
        if (event.isStartElement()) {
            final StartElement startElement = event.asStartElement();
             
            final QName name = startElement.getName();
             
            final String localPart = name.getLocalPart();
            if ("channel".equals(localPart) || "folder".equals(localPart)) {
                return new ImmutableStartElementWrapper(startElement);
            } 
        } 
         
        return event;
    } 
5
CodeRank
This code example shows how to use the following methods:getNamespaces
        return this.startElement.getNamespaceContext();
    } 
 
    @Override 
    public Iterator<Namespace> getNamespaces() {
        return this.startElement.getNamespaces();
    } 
 
    @Override 
    public String getNamespaceURI(String prefix) {
        return this.startElement.getNamespaceURI(prefix);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getAttributeByName
 
    private Configuration parseConfigElement(XMLEventReader eventReader, XMLEvent event)
            throws XMLStreamExceptionStartElement startElement = event.asStartElement();
        String key = startElement.getAttributeByName(new QName(ExportElements.KEY.name())).getValue();
 
        String value = ParserUtil.parseNextEventAsCharacters(eventReader);
 
        return new Configuration(key, value);
    } 
} 
4
CodeRank
See Code Examples for Java 8 StartElement Methods: