Package org.staxnav

Examples of org.staxnav.StaxNavException


                    lang = new Locale(langISO.toLowerCase());
                } else {
                    lang = new Locale(langISO.toLowerCase(), countryISO.toLowerCase());
                }
            } else {
                throw new StaxNavException(navigator.getLocation(), "The attribute xml:lang='" + attribute
                        + "' does not represent a valid language pattern (ie: en, en-us).");
            }
        }

        String value = StaxNavUtils.getRequiredContent(navigator, false);
View Full Code Here


            if (output instanceof OutputStream) {
                if (outputEncoding != null) {
                    try {
                        writer = factory.createXMLStreamWriter((OutputStream) output, outputEncoding);
                    } catch (XMLStreamException e) {
                        throw new StaxNavException(e);
                    }
                } else {
                    try {
                        writer = factory.createXMLStreamWriter((OutputStream) output);
                    } catch (XMLStreamException e) {
                        throw new StaxNavException(null, "Exception creating XMLStreamWriter with OutputStream: " + output, e);
                    }
                }
            } else if (output instanceof Writer) {
                try {
                    writer = factory.createXMLStreamWriter((Writer) output);
                } catch (XMLStreamException e) {
                    throw new StaxNavException(null, "Exception creating XMLStreamWriter with Writer: " + output, e);
                }
            } else if (output instanceof Result) {
                try {
                    writer = factory.createXMLStreamWriter((Result) output);
                } catch (XMLStreamException e) {
                    throw new StaxNavException(null, "Exception creating XMLStreamWriter with Result: " + output, e);
                }
            } else {
                throw new IllegalStateException("Unknown output: " + output); // should never happen...
            }
        }
View Full Code Here

    }

    public static String getRequiredAttribute(StaxNavigator navigator, String attributeName) throws StaxNavException {
        String value = navigator.getAttribute(attributeName);
        if (value == null) {
            throw new StaxNavException(navigator.getLocation(), "Attribute '" + attributeName + "' is required for element '"
                    + navigator.getLocalName() + "'");
        }

        return value;
    }
View Full Code Here

        return this;
    }

    public StaxWriter<N> writeEndElement() throws StaxNavException {
        if (elementStack.isEmpty())
            throw new StaxNavException(null, "No matching startElement was found for this endElement");

        elementStack.pop().end();

        return this;
    }
View Full Code Here

            try {
                formatter.before(writer, event);
                closure.execute(writer);
                formatter.after(writer, event);
            } catch (XMLStreamException e) {
                throw new StaxNavException(e);
            }
        }
View Full Code Here

                    }
                });

                writer.flush();
            } catch (XMLStreamException e) {
                throw new StaxNavException(e);
            } finally {
                try {
                    writer.close();
                } catch (XMLStreamException e) {
                }
View Full Code Here

      {
         return nav.getContent();
      }
      else
      {
         throw new StaxNavException(nav.getLocation(), "Was expecting elemnt " + element + " to be present");
      }
   }
View Full Code Here

         SecurityConstraintMetaData securityConstraintMD = new SecurityConstraintMetaData();
         securityConstraintMD.setId(securityConstraintNav.getAttribute("id"));
         securityConstraintMD.setDisplayName(readLocalizedString(securityConstraintNav, Element.display_name));
         if (securityConstraintNav.next() != Element.portlet_collection)
         {
            throw new StaxNavException(nav.getLocation(), "Was expecting a portlet-collection element instead of " + securityConstraintNav.getName());
         }
         PortletCollectionMetaData portletCollectionMD = new PortletCollectionMetaData();
         while (securityConstraintNav.next(Element.portlet_name))
         {
            portletCollectionMD.addPortletname(securityConstraintNav.getContent());
         }
         securityConstraintMD.setPortletList(portletCollectionMD);
         if (securityConstraintNav.next() != Element.user_data_constraint)
         {
            throw new StaxNavException(nav.getLocation(), "Was expecting a security-constraint element instead of " + securityConstraintNav.getName());
         }
         UserDataConstraintMetaData userDataConstraintMD = new UserDataConstraintMetaData();
         userDataConstraintMD.setDescription(readLocalizedString(securityConstraintNav, Element.description));
         if (securityConstraintNav.next() != Element.transport_guarantee)
         {
            throw new StaxNavException(nav.getLocation(), "Was expecting a transport-guarantee element instead of " + securityConstraintNav.getName());
         }
         userDataConstraintMD.setTransportGuarantee(securityConstraintNav.parseContent(TRANSPORT_GUARANTEE));
         securityConstraintMD.setUserDataConstraint(userDataConstraintMD);
         md.addSecurityConstraint(securityConstraintMD);
      }
View Full Code Here

            if (output instanceof OutputStream) {
                if (outputEncoding != null) {
                    try {
                        writer = factory.createXMLStreamWriter((OutputStream) output, outputEncoding);
                    } catch (XMLStreamException e) {
                        throw new StaxNavException(e);
                    }
                } else {
                    try {
                        writer = factory.createXMLStreamWriter((OutputStream) output);
                    } catch (XMLStreamException e) {
                        throw new StaxNavException(null, "Exception creating XMLStreamWriter with OutputStream: " + output, e);
                    }
                }
            } else if (output instanceof Writer) {
                try {
                    writer = factory.createXMLStreamWriter((Writer) output);
                } catch (XMLStreamException e) {
                    throw new StaxNavException(null, "Exception creating XMLStreamWriter with Writer: " + output, e);
                }
            } else if (output instanceof Result) {
                try {
                    writer = factory.createXMLStreamWriter((Result) output);
                } catch (XMLStreamException e) {
                    throw new StaxNavException(null, "Exception creating XMLStreamWriter with Result: " + output, e);
                }
            } else {
                throw new IllegalStateException("Unknown output: " + output); // should never happen...
            }
        }
View Full Code Here

        return this;
    }

    public StaxWriter<N> writeEndElement() throws StaxNavException {
        if (elementStack.isEmpty())
            throw new StaxNavException(null, "No matching startElement was found for this endElement");

        elementStack.pop().end();

        return this;
    }
View Full Code Here

TOP

Related Classes of org.staxnav.StaxNavException

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.