Package javax.xml.stream.events

Examples of javax.xml.stream.events.StartElement


    }
   
   
    private static void writeStartElementEvent(XMLEvent event, XMLStreamWriter writer)
        throws XMLStreamException {
        StartElement start = event.asStartElement();
        QName name = start.getName();
        String nsURI = name.getNamespaceURI();
        String localName = name.getLocalPart();
        String prefix = name.getPrefix();
       
        if (prefix != null) {
            writer.writeStartElement(prefix, localName, nsURI);
        } else if (nsURI != null) {
            writer.writeStartElement(localName, nsURI);
        } else {
            writer.writeStartElement(localName);
        }
        Iterator it = start.getNamespaces();
        while (it != null && it.hasNext()) {
            writeEvent((XMLEvent)it.next(), writer);
        }
       
        it = start.getAttributes();
        while (it != null && it.hasNext()) {
            writeAttributeEvent((Attribute)it.next(), writer);           
        }
    }
View Full Code Here


    }
   
   
    private static void writeStartElementEvent(XMLEvent event, XMLStreamWriter writer)
        throws XMLStreamException {
        StartElement start = event.asStartElement();
        QName name = start.getName();
        String nsURI = name.getNamespaceURI();
        String localName = name.getLocalPart();
        String prefix = name.getPrefix();
       
        if (prefix != null) {
            writer.writeStartElement(prefix, localName, nsURI);
        } else if (nsURI != null) {
            writer.writeStartElement(localName, nsURI);
        } else {
            writer.writeStartElement(localName);
        }
        Iterator it = start.getNamespaces();
        while (it != null && it.hasNext()) {
            writeEvent((XMLEvent)it.next(), writer);
        }
       
        it = start.getAttributes();
        while (it != null && it.hasNext()) {
            writeAttributeEvent((Attribute)it.next(), writer);           
        }
    }
View Full Code Here

    }
   
   
    private static void writeStartElementEvent(XMLEvent event, XMLStreamWriter writer)
        throws XMLStreamException {
        StartElement start = event.asStartElement();
        QName name = start.getName();
        String nsURI = name.getNamespaceURI();
        String localName = name.getLocalPart();
        String prefix = name.getPrefix();
       
        if (prefix != null) {
            writer.writeStartElement(prefix, localName, nsURI);
        } else if (nsURI != null) {
            writer.writeStartElement(localName, nsURI);
        } else {
            writer.writeStartElement(localName);
        }
        Iterator<XMLEvent> it = CastUtils.cast(start.getNamespaces());
        while (it != null && it.hasNext()) {
            writeEvent(it.next(), writer);
        }
       
        it = CastUtils.cast(start.getAttributes());
        while (it != null && it.hasNext()) {
            writeAttributeEvent(it.next(), writer);           
        }
    }
View Full Code Here

      while (r.hasNext()) {
        XMLEvent event = r.nextEvent();

        if (event.isStartElement()) {
          StartElement start = event.asStartElement();

          String tag = start.getName().getLocalPart();

          if (tag.equalsIgnoreCase("domain")) {
            if (start.getAttributeByName(new QName("", "value")) != null) {
              domain = start.getAttributeByName(
                  new QName("", "value")).getValue();
              rule.setDomain(domain);
            }

            continue;
          }

          if (tag.equalsIgnoreCase("alias")) {
            Alias alias = new Alias();
            alias.setName(start.getAttributeByName(
                new QName("", "name")).getValue());
            alias.setKey(Integer.valueOf(start.getAttributeByName(
                new QName("", "key")).getValue()));

            rule.getAliasPool().put(alias.getName(), alias);

            continue;
          }
         
          if (tag.equalsIgnoreCase("inner-key")){
            InnerKey innerKey = new InnerKey();
           
            innerKey.setKey(Integer.parseInt(start.getAttributeByName(
                new QName("", "key")).getValue()));
           
            boolean isExist = false;
           
            for(InnerKey ik : rule.getInnerKeyPool())
            {
              if (ik.getKey() == innerKey.getKey())
              {
                logger.error("duplicate innerkey define, key :" + innerKey.getKey());
               
                isExist = true;
                break;
              }
            }
           
            if (!isExist)
            {
              if (innerKey.setFile(start.getAttributeByName(
                  new QName("", "file")).getValue()))
                rule.getInnerKeyPool().add(innerKey);
              else
                logger.error("inner-key set error, file : " + innerKey.getFile());
             
            }
           
            continue;
           
          }

          if (tag.equalsIgnoreCase("global-condition")) {
            if (start.getAttributeByName(new QName("", "value")) != null) {
              if (globalConditions.length() > 0) {
                globalConditions.append("&"
                    + start.getAttributeByName(
                        new QName("", "value"))
                        .getValue());
              } else {
                globalConditions.append(start
                    .getAttributeByName(
                        new QName("", "value"))
                    .getValue());
              }

            }

            continue;
          }

          if (tag.equalsIgnoreCase("global-mapClass")) {
            if (start.getAttributeByName(new QName("", "value")) != null) {
              globalMapClass.add(start.getAttributeByName(
                  new QName("", "value")).getValue());
            }

            continue;
          }

          if (tag.equalsIgnoreCase("global-valuefilter")) {
            if (start.getAttributeByName(new QName("", "value")) != null) {
              globalValuefilter.append(
                  start.getAttributeByName(
                      new QName("", "value")).getValue())
                  .append("&");
            }

            continue;
View Full Code Here

    }
   
   
    private static void writeStartElementEvent(XMLEvent event, XMLStreamWriter writer)
        throws XMLStreamException {
        StartElement start = event.asStartElement();
        QName name = start.getName();
        String nsURI = name.getNamespaceURI();
        String localName = name.getLocalPart();
        String prefix = name.getPrefix();
       
        if (prefix != null) {
            writer.writeStartElement(prefix, localName, nsURI);
        } else if (nsURI != null) {
            writer.writeStartElement(localName, nsURI);
        } else {
            writer.writeStartElement(localName);
        }
        Iterator<XMLEvent> it = CastUtils.cast(start.getNamespaces());
        while (it != null && it.hasNext()) {
            writeEvent(it.next(), writer);
        }
       
        it = CastUtils.cast(start.getAttributes());
        while (it != null && it.hasNext()) {
            writeAttributeEvent(it.next(), writer);           
        }
    }
View Full Code Here

      {
         XMLEvent event = reader.nextEvent();
         switch (event.getEventType())
         {
            case XMLStreamConstants.START_ELEMENT :
               StartElement startElement = event.asStartElement();

               Map<String, String> attr = new HashMap<String, String>();

               Iterator attributes = startElement.getAttributes();
               while (attributes.hasNext())
               {
                  Attribute attribute = (Attribute)attributes.next();
                  attr.put(attribute.getName().getLocalPart(), attribute.getValue());
               }

               String localName = startElement.getName().getLocalPart();
               if (localName.equals(REFERENCE_ELEMENT))
               {
                  String bindName = attr.get(BIND_NAME_ATTR);
                  String className = attr.get(CLASS_NAME_ATTR);
                  String factoryName = attr.get(FACTORY_ATTR);
View Full Code Here

                    while (xmlReader.hasNext())
                    {
                        xmlEvent = xmlReader.nextEvent();
                        if (isStartOfBinarySecurityToken(xmlEvent))
                        {
                            final StartElement bstElement = (StartElement) xmlEvent;
                            BinarySecurityToken bst = new BinarySecurityToken();
                            bst.setEncodingType(bstElement.getAttributeByName(encodingTypeQName).getValue());
                            bst.setValueType(bstElement.getAttributeByName(valueTypeQName).getValue());

                            final StringBuilder data = new StringBuilder();
                            while (xmlReader.hasNext())
                            {
                                final XMLEvent nextEvent = xmlReader.nextEvent();
View Full Code Here

                    message.append("events of different types: ").append(eventA).append(", ").append(eventB);
                    return false;
                }

                if (eventType == XMLStreamConstants.START_ELEMENT) {
                    StartElement startA = eventA.asStartElement();
                    StartElement startB = eventB.asStartElement();
                    if (!startA.getName().getLocalPart().equals(startB.getName().getLocalPart())) {
                        message.append("Different elements ").append(startA.getName()).append(", ").append(startB.getName()).append(" at location ").append(eventA.getLocation());
                        return false;
                    }
                } else if (eventType == XMLStreamConstants.END_ELEMENT) {
                    EndElement endA = eventA.asEndElement();
                    EndElement endB = eventB.asEndElement();
View Full Code Here

            XMLEvent docStart = xmlReader.nextEvent();

            XMLEvent rootElement = xmlReader.nextTag();

            if (rootElement instanceof StartElement) {
                StartElement startElement = (StartElement)rootElement;
                Attribute toAttribute = startElement.getAttributeByName(ATTRIBUTE_TO);
                if (toAttribute != null) {
                    to = toAttribute.getValue();
                }
            }
            while (true) {
View Full Code Here

    }
   
   
    private static void writeStartElementEvent(XMLEvent event, XMLStreamWriter writer)
        throws XMLStreamException {
        StartElement start = event.asStartElement();
        QName name = start.getName();
        String nsURI = name.getNamespaceURI();
        String localName = name.getLocalPart();
        String prefix = name.getPrefix();
       
        if (prefix != null) {
            writer.writeStartElement(prefix, localName, nsURI);
        } else if (nsURI != null) {
            writer.writeStartElement(localName, nsURI);
        } else {
            writer.writeStartElement(localName);
        }
        Iterator it = start.getNamespaces();
        while (it != null && it.hasNext()) {
            writeEvent((XMLEvent)it.next(), writer);
        }
       
        it = start.getAttributes();
        while (it != null && it.hasNext()) {
            writeAttributeEvent((Attribute)it.next(), writer);           
        }
    }
View Full Code Here

TOP

Related Classes of javax.xml.stream.events.StartElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.