Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMException


    public int next() throws OMException {
        try {
            // We need a loop here because we may decide to skip an event
            while (true) {
                if (done) {
                    throw new OMException();
                }
                int token = parserNext();
                if (!cache) {
                    return token;
                }
              
                // The current token should be the same as the
                // one just obtained.  This bit of code is used to
                // detect invalid parser state.
                if (doTrace) {
                    int currentParserToken = parser.getEventType();
                    if (currentParserToken != token) {
   
   
                        log.debug("WARNING: The current state of the parser is not equal to the " +
                                  "state just received from the parser. The current state in the paser is " +
                                  XMLEventUtils.getEventTypeString(currentParserToken) + " the state just received is " +
                                  XMLEventUtils.getEventTypeString(token));
   
                        /*
                          throw new OMException("The current token " + token +
                                         " does not match the current event " +
                                         "reported by the parser token.  The parser did not update its state correctly.  " +
                                         "The parser is " + parser);
                         */
                    }
                }
               
                // Now log the current state of the parser
                if (doTrace) {
                    logParserState();
                }
              
                switch (token) {
                    case XMLStreamConstants.START_ELEMENT:
                        elementLevel++;
                        lastNode = createNextOMElement();
                        break;
                    case XMLStreamConstants.CHARACTERS:
                        lastNode = createOMText(XMLStreamConstants.CHARACTERS);
                        break;
                    case XMLStreamConstants.CDATA:
                        lastNode = createOMText(XMLStreamConstants.CDATA);
                        break;
                    case XMLStreamConstants.END_ELEMENT:
                        endElement();
                        elementLevel--;
                        break;
                    case XMLStreamConstants.END_DOCUMENT:
                        done = true;
                        ((OMContainerEx) this.document).setComplete(true);
                        break;
                    case XMLStreamConstants.SPACE:
                        try {
                            lastNode = createOMText(XMLStreamConstants.SPACE);
                            if (lastNode == null) {
                                continue;
                            }
                        } catch (OMHierarchyException ex) {
                            // The OM implementation doesn't allow text nodes at the current
                            // position in the tree. Since it is only whitespace, we can safely
                            // skip this event.
                            continue;
                        }
                        break;
                    case XMLStreamConstants.COMMENT:
                        lastNode = createComment();
                        break;
                    case XMLStreamConstants.DTD:
                        createDTD();
                        break;
                    case XMLStreamConstants.PROCESSING_INSTRUCTION:
                        lastNode = createPI();
                        break;
                    case XMLStreamConstants.ENTITY_REFERENCE:
                        lastNode = createOMText(XMLStreamConstants.ENTITY_REFERENCE);
                        break;
                    default :
                        throw new OMException();
                }
                return token;
            }
        } catch (XMLStreamException e) {
            throw new OMException(e);
        }
    }
View Full Code Here


                } else {
                    next()// continue looking past whitespace etc.
                }
            }
        } catch (XMLStreamException e) {
            throw new OMException(e);
        }
    }
View Full Code Here

     */
    public OMElementImpl(String localName, OMNamespace ns, OMContainer parent,
                         OMFactory factory) {
        super(parent, factory, true);
        if (localName == null || localName.trim().length() == 0) {
            throw new OMException("localname can not be null or empty");
        }
        this.localName = localName;
        if (ns != null) {
            setNamespace(ns);
        }
View Full Code Here

                }
                setComplete(true);
            } else {
                int token = builder.next();
                if (token == XMLStreamConstants.END_DOCUMENT) {
                    throw new OMException(
                    "Parser has already reached end of the document. No siblings found");
                }
            }
        }
        return super.getNextOMSibling();
View Full Code Here

        if (child instanceof OMElement) {
            if (this.documentElement == null) {
                addChild((OMNodeImpl) child);
                this.documentElement = (OMElement) child;
            } else {
                throw new OMException("Document element already exists");
            }
        } else {
            addChild((OMNodeImpl) child);
        }
    }
View Full Code Here

    public static String getContentID(XMLStreamReader parser) {
        if (parser.getAttributeCount() > 0 &&
                parser.getAttributeLocalName(0).equals("href")) {
            return getContentIDFromHref(parser.getAttributeValue(0));
        } else {
            throw new OMException(
                    "Href attribute not found in XOP:Include element");
        }
    }
View Full Code Here

            if (reader.getEventType() == XMLStreamReader.START_DOCUMENT) {
                reader.next();
            }
            return XMLStreamReaderUtils.getElementTextAsStream(reader, true);
        } catch (XMLStreamException ex) {
            throw new OMException(ex);
        }
    }
View Full Code Here

       
        if (startNode instanceof OMDocument) {
            try {
                next();
            } catch (XMLStreamException ex) {
                throw new OMException(ex);
            }
        }
    }
View Full Code Here

                return StAXUtils.createXMLStreamReader(configuration, is.getCharacterStream());
            } else {
                throw new IllegalArgumentException();
            }
        } catch (XMLStreamException ex) {
            throw new OMException(ex);
        }
    }
View Full Code Here

    public OMNode getNextOMSibling() throws OMException {
        while (!done) {
            int token = builder.next();
            if (token == XMLStreamConstants.END_DOCUMENT) {
                throw new OMException();
            }
        }
        return super.getNextOMSibling();
    }
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.OMException

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.