Package javax.xml.stream

Examples of javax.xml.stream.XMLStreamException


      ProcessingInstruction pi = (ProcessingInstruction) reader
          .nextEvent();

      return createProcessingInstruction(pi);
    } else {
      throw new XMLStreamException("Expected PI event, found: " + event);
    }
  }
View Full Code Here


  public String getElementText() throws XMLStreamException {
    StringBuffer buf = new StringBuffer();
    XMLEvent e = nextEvent();
    if (!e.isStartElement())
      throw new XMLStreamException("Precondition for readText is nextEvent().getTypeEventType() == START_ELEMENT (got "+e.getEventType()+")");
    while(hasNext()) {
      e = peek();
      if(e.isStartElement())
        throw new XMLStreamException("Unexpected Element start");
      if(e.isCharacters())
        buf.append(((Characters) e).getData());
      if(e.isEndElement())
        return buf.toString();
      nextEvent();
    }
    throw new XMLStreamException("Unexpected end of Document");

  }
View Full Code Here

    protected void checkCharValidity(int ch, boolean surrogatesOk)
        throws XMLStreamException
    {
        if (ch < 0x0020) {
            if (!isS((char) ch)) {
                throw new XMLStreamException("Illegal white space character (code 0x"+Integer.toHexString(ch)+")");
            }
        } else if (ch >= 0xD800) { // surrogates illegal at this level
            if (ch <= 0xDFFF) {
                if (!surrogatesOk) {
                    throw new XMLStreamException("Illegal character (code 0x"+Integer.toHexString(ch)+"): surrogate characters are not valid XML characters",
                                                 getLocation());
                }
            } else if (ch > MAX_UNICODE_CHAR) {
                throw new XMLStreamException("Illegal character (code 0x"+Integer.toHexString(ch)+"), past max. Unicode character 0x"+Integer.toHexString(MAX_UNICODE_CHAR),
                                             getLocation());
            }
        }
    }
View Full Code Here

    public void setFeature(String name,
                           boolean state) throws XMLStreamException
    {
        if(name == null) throw new IllegalArgumentException("feature name should not be nulll");
        if(FEATURE_PROCESS_NAMESPACES.equals(name)) {
            if(eventType != XMLStreamConstants.START_DOCUMENT) throw new XMLStreamException(
                    "namespace processing feature can only be changed before parsing",
                    getLocation());
            processNamespaces = state;
            //        } else if(FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) {
            //      if(type != XMLStreamConstants.START_DOCUMENT) throw new XMLStreamException(
            //              "namespace reporting feature can only be changed before parsing",
            // getLineNumber(), getColumnNumber(), getPositionDescription(), null);
            //            reportNsAttribs = state;
        } else if(FEATURE_NAMES_INTERNED.equals(name)) {
            if(state != false) {
                throw new XMLStreamException(
                    "interning names in this implementation is not supported");
            }
        } else if(FEATURE_PROCESS_DOCDECL.equals(name)) {
            if(state != false) {
                throw new XMLStreamException(
                    "processing DOCDECL is not supported");
            }
            //} else if(REPORT_DOCDECL.equals(name)) {
            //    paramNotifyDoctype = state;
        } else if(FEATURE_XML_ROUNDTRIP.equals(name)) {
            if(state == false) {
                throw new XMLStreamException(
                    "roundtrip feature can not be switched off");
            }
        } else {
            throw new XMLStreamException("unknown feature "+name);
        }
    }
View Full Code Here

   
    public void setProperty(String name,
                            Object value)
        throws XMLStreamException
    {
        throw new XMLStreamException("unsupported property: '"+name+"'");
    }
View Full Code Here

                return true;
            }
            breader.reset();
            return false;
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here

            setInput(r);
            if (enc != null) {
                inputEncoding = enc;
            }
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here

            reader = (inputEncoding != null) ?
                XmlReader.createReader(inputStream, inputEncoding) :
                XmlReader.createReader(inputStream);
        } catch (IOException ioe) {
            String encMsg = (inputEncoding == null) ? "(for encoding '"+inputEncoding+"')" : "";
            throw new XMLStreamException("could not create reader "+encMsg+": "+ioe,
                                         getLocation(), ioe);
        }
        setInput(reader);
        //must be  here as reest() was called in setInput() and has set this.inputEncoding to null ...
        if (inputEncoding != null) {
View Full Code Here

    }
   
   
    public boolean isEmptyElementTag() throws XMLStreamException
    {
        if(eventType != XMLStreamConstants.START_ELEMENT) throw new XMLStreamException(
                "parser must be on XMLStreamConstants.START_ELEMENT to check for empty element",
                getLocation());
        return emptyElementTag;
    }
View Full Code Here

        if (ok && name != null) {
            if (currType == START_ELEMENT || currType == END_ELEMENT
                    || currType == ENTITY_REFERENCE) {
                ok = name.equals(getLocalName());
            } else {
                throw new XMLStreamException("Using non-null local name argument for require(); "
                                                 +ElementTypeNames.getEventTypeString(currType)
                                                 +" event does not have local name",
                                             getLocation());
            }
        }
       
        if (ok && namespace != null) {
            if (currType == START_ELEMENT || currType == START_ELEMENT) {
                ok = namespace.equals(getNamespaceURI());
            }
        }
       
        if (!ok) {
            throw new XMLStreamException (
                "expected event "+ElementTypeNames.getEventTypeString(type)
                    +(name != null ? " with name '"+name+"'" : "")
                    +(namespace != null && name != null ? " and" : "")
                    +(namespace != null ? " with namespace '"+namespace+"'" : "")
                    +" but got"
View Full Code Here

TOP

Related Classes of javax.xml.stream.XMLStreamException

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.