Package javax.xml.bind

Examples of javax.xml.bind.JAXBException


      return new Configuration(this);
    } else {
      try {
        return (Configuration) cl.loadClass(className).newInstance();
      } catch (Exception e) {
        throw new JAXBException("Failed to instantiate Configuration class " + className, e);
      }
    }
  }
View Full Code Here


  }

  public void addManager(JMManager pManager) throws JAXBException {
    Class elementInterface = pManager.getElementInterface();
    if (elementInterface == null) {
      throw new JAXBException("The Manager must have its elementInterface set.");
    }
    if (managersByInterface.containsKey(elementInterface)) {
      throw new JAXBException("A Manager for interface " +
                               elementInterface.getName() +
                               " is already set.");
    }

    Class elementClass = pManager.getElementClass();
    if (elementClass == null) {
      throw new JAXBException("The Manager must have its elementClass set.");
    }
    if (!elementInterface.isAssignableFrom(elementClass)) {
      throw new JAXBException("The elementClass " + elementClass.getName() +
                               " is not implementing the elementInterface " +
                               elementInterface.getName() + ".");
    }

    Class handlerClass = pManager.getHandlerClass();
    if (handlerClass == null) {
      throw new JAXBException("The Manager must have its handlerClass set.");
    }
    if (!JMHandler.class.isAssignableFrom(handlerClass)) {
      throw new JAXBException("The handlerClass " + handlerClass.getName() +
                               " is not implementing " +
                               JMHandler.class.getName() + ".");
    }

    Class marshallerClass = pManager.getMarshallerClass();
    if (marshallerClass == null) {
      throw new JAXBException("The Manager must have its marshallerClass set.");
    }
    if (!JMXmlSerializer.class.isAssignableFrom(marshallerClass)) {
      throw new JAXBException("The marshallerClass " + marshallerClass.getName() +
                               " is not implementing " +
                               JMXmlSerializer.class.getName() + ".");
    }

    QName qName = pManager.getQName();
    if (qName != null  &&  managersByQName.containsKey(qName)) {
      throw new JAXBException("A Manager for document type " + qName +
                               " is already set.");
    }

    managersByInterface.put(elementInterface, pManager);
    if (qName != null) {
View Full Code Here

    if (xmlReader == null) {
      try {
        SAXParser sp = saxParserFactory.newSAXParser();
        xmlReader = sp.getXMLReader();
      } catch (ParserConfigurationException e) {
        throw new JAXBException("Failed to create a JAXP compliant SAX parser.", e);
      } catch (SAXException e) {
        throw new JAXBException("Failed to create a JAXP compliant SAX parser.", e);
      }
    }
    return xmlReader;
  }
View Full Code Here

      InputSource is;
      InputStream istream = ss.getInputStream();
      if (istream == null) {
        Reader r = ss.getReader();
        if (r == null) {
          throw new JAXBException("The specified StreamSource must have configured either of its InputStream or Reader.");
        } else {
          is = new InputSource(r);
        }
      } else {
        is = new InputSource(istream);
      }
      is.setSystemId(ss.getSystemId());
      is.setPublicId(ss.getPublicId());
      return unmarshal(getXMLReader(), is);
    } else if (pSource instanceof DOMSource) {
      DOMSource ds = (DOMSource) pSource;
      return unmarshal(ds.getNode());
    } else {
      throw new JAXBException("Unsupported type of " + Source.class.getName() +
                              ", expected either of " +
                              SAXSource.class.getName() + ", " +
                              StreamSource.class.getName() + ", or " +
                              DOMSource.class.getName());
    }
View Full Code Here

  public final java.lang.Object unmarshal(java.net.URL pURL) throws JAXBException {
    InputSource isource;
    try {
      isource = new InputSource(pURL.openStream());
    } catch (IOException e) {
      throw new JAXBException("Failed to open URL " + pURL + ": " + e.getMessage(), e);
    }
    isource.setSystemId(pURL.toExternalForm());
    return unmarshal(getXMLReader(), isource);
  }
View Full Code Here

  public final java.lang.Object unmarshal(java.io.File pFile) throws JAXBException {
    InputSource isource;
    try {
      isource = new InputSource(new FileInputStream(pFile));
    } catch (IOException e) {
      throw new JAXBException("Failed to open file " + pFile + ": " + e.getMessage(), e);
    }
    try {
      isource.setSystemId(pFile.toURL().toExternalForm());
    } catch (IOException e) {
      throw new JAXBException("Malformed URL: " + pFile, e);
    }
    return unmarshal(getXMLReader(), isource);
  }
View Full Code Here

  public void init(JMManager pManager) throws JAXBException {
    super.init(pManager);
    idTag = pManager.getProperty("ino.idTag");
    if (idTag == null  ||  idTag.length() == 0) {
      throw new JAXBException("Missing property: 'ino.idTag' (Tag name or attribute name of the element ID)");
    }
    elementTag = pManager.getProperty("ino.elementTag");
    if (elementTag == null  ||  elementTag.length() == 0) {
      throw new JAXBException("Missing property: 'ino.elementTag' (Qualified element name, including namespace prefix)");
    }
    String url = pManager.getProperty("ino.url");
    if (url == null  ||  url.length() == 0) {
      throw new JAXBException("Missing property: 'ino.url' (Tamino database URL)");
    }
    user = pManager.getProperty("ino.user");
    password = pManager.getProperty("ino.password");
    useGet = Boolean.valueOf(pManager.getProperty("ino.useGet")).booleanValue();
  }
View Full Code Here

   */
  protected String getDeleteQuery(Element pElement)
      throws JAXBException, InvocationTargetException, IllegalAccessException, NoSuchMethodException {
    String id = getId(pElement);
    if (id == null  ||  id.length() == 0) {
      throw new JAXBException("The element being deleted doesn't have an ID.");
    }
    return "_delete=" +
      java.net.URLEncoder.encode(getElementTag() + '[' + getIdTag() + '=' + id + ']');
  }
View Full Code Here

  private String getIdMethodName;

  public void init(JMManager pManager) throws JAXBException {
    String methodName = pManager.getProperty("xmldb.getIdMethodName");
    if (methodName == null  ||  methodName.length() == 0) {
      throw new JAXBException("Missing property: 'xmldb.getIdMethodName' (method name for reading the object ID)");
    }
    setGetIdMethodName(methodName);
  }
View Full Code Here

  public void init(JMManager pManager) throws JAXBException {
    super.init(pManager);

    String driverClassName = pManager.getProperty("xmldb.driver");
    if (driverClassName == null  ||  driverClassName.length() == 0) {
      throw new JAXBException("Missing property: 'xmldb.driver' (driver class name)");
    }

    String coll = pManager.getProperty("xmldb.collection");
    if (coll == null  ||  coll.length() == 0) {
      throw new JAXBException("Missing property: 'xmldb.collection' (collection name)");
    }
    setCollection(coll);
    setUser(pManager.getProperty("xmldb.user"));
    setPassword(pManager.getProperty("xmldb.password"));

    for (int i = 0;  ;  i++) {
      String p = "xmldb.property." + i;
      String v = pManager.getProperty(p);
      if (v == null) {
        break;
      }
      int offset = v.indexOf('=');
      if (offset == -1) {
        throw new JAXBException("Invalid database property value " + p + ": Expected name=value, got " + v);
      }
      String name = v.substring(0, offset);
      String value = v.substring(offset+1);
      if (databaseProperties != null) {
        databaseProperties = new HashMap();
      }
      databaseProperties.put(name, value);
    }

    Class c;
    try {
      c = Class.forName(driverClassName);
    } catch (ClassNotFoundException e) {
      try {
        c = Thread.currentThread().getContextClassLoader().loadClass(driverClassName);
      } catch (ClassNotFoundException f) {
        throw new JAXBException("Failed to load driver class " + driverClassName, e);
      }
    }
    setDriverClass(c);
  }
View Full Code Here

TOP

Related Classes of javax.xml.bind.JAXBException

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.