Package org.mybatis.generator.exception

Examples of org.mybatis.generator.exception.XMLParserException


      Document document = null;
      try {
        document = builder.parse(inputSource);
      } catch (SAXParseException e) {
        throw new XMLParserException(parseErrors);
      } catch (SAXException e) {
        if (e.getException() == null) {
          parseErrors.add(e.getMessage());
        } else {
          parseErrors.add(e.getException().getMessage());
        }
      }

      if (parseErrors.size() > 0) {
        throw new XMLParserException(parseErrors);
      }

      Configuration config;
      Element rootNode = document.getDocumentElement();
      DocumentType docType = document.getDoctype();
      if (rootNode.getNodeType() == Node.ELEMENT_NODE
          && docType.getPublicId().equals(XmlConstants.IBATOR_CONFIG_PUBLIC_ID)) {
        config = parseIbatorConfiguration(rootNode);
      } else if (rootNode.getNodeType() == Node.ELEMENT_NODE
          && docType.getPublicId().equals(XmlConstants.MYBATIS_GENERATOR_CONFIG_PUBLIC_ID)) {
        config = parseMyBatisGeneratorConfiguration(rootNode);
      } else {
        throw new XMLParserException(getString("RuntimeError.5")); //$NON-NLS-1$
      }

      if (parseErrors.size() > 0) {
        throw new XMLParserException(parseErrors);
      }

      return config;
    } catch (ParserConfigurationException e) {
      parseErrors.add(e.getMessage());
      throw new XMLParserException(parseErrors);
    }
  }
View Full Code Here


    Properties attributes = parseAttributes(node);
    String resource = attributes.getProperty("resource"); //$NON-NLS-1$
    String url = attributes.getProperty("url"); //$NON-NLS-1$

    if (!stringHasValue(resource) && !stringHasValue(url)) {
      throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
    }

    if (stringHasValue(resource) && stringHasValue(url)) {
      throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
    }

    URL resourceUrl;

    try {
      if (stringHasValue(resource)) {
        resourceUrl = Thread.currentThread().getContextClassLoader().getResource(resource);
        if (resourceUrl == null) {
          throw new XMLParserException(getString("RuntimeError.15", resource)); //$NON-NLS-1$
        }
      } else {
        resourceUrl = new URL(url);
      }

      InputStream inputStream = resourceUrl.openConnection().getInputStream();

      properties.load(inputStream);
      inputStream.close();
    } catch (IOException e) {
      if (stringHasValue(resource)) {
        throw new XMLParserException(getString("RuntimeError.16", resource)); //$NON-NLS-1$
      } else {
        throw new XMLParserException(getString("RuntimeError.17", url)); //$NON-NLS-1$
      }
    }
  }
View Full Code Here

    Properties attributes = parseAttributes(node);
    String resource = attributes.getProperty("resource"); //$NON-NLS-1$
    String url = attributes.getProperty("url"); //$NON-NLS-1$

    if (!stringHasValue(resource) && !stringHasValue(url)) {
      throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
    }

    if (stringHasValue(resource) && stringHasValue(url)) {
      throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
    }

    URL resourceUrl;

    try {
      if (stringHasValue(resource)) {
        resourceUrl = Thread.currentThread().getContextClassLoader().getResource(resource);
        if (resourceUrl == null) {
          throw new XMLParserException(getString("RuntimeError.15", resource)); //$NON-NLS-1$
        }
      } else {
        resourceUrl = new URL(url);
      }

      InputStream inputStream = resourceUrl.openConnection().getInputStream();

      properties.load(inputStream);
      inputStream.close();
    } catch (IOException e) {
      if (stringHasValue(resource)) {
        throw new XMLParserException(getString("RuntimeError.16", resource)); //$NON-NLS-1$
      } else {
        throw new XMLParserException(getString("RuntimeError.17", url)); //$NON-NLS-1$
      }
    }
  }
View Full Code Here

        String resource = attributes.getProperty("resource"); //$NON-NLS-1$
        String url = attributes.getProperty("url"); //$NON-NLS-1$

        if (!stringHasValue(resource)
                && !stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        if (stringHasValue(resource)
                && stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        URL resourceUrl;

        try {
            if (stringHasValue(resource)) {
                resourceUrl = ObjectFactory.getResource(resource);
                if (resourceUrl == null) {
                    throw new XMLParserException(getString(
                            "RuntimeError.15", resource)); //$NON-NLS-1$
                }
            } else {
                resourceUrl = new URL(url);
            }

            InputStream inputStream = resourceUrl.openConnection()
                    .getInputStream();

            properties.load(inputStream);
            inputStream.close();
        } catch (IOException e) {
            if (stringHasValue(resource)) {
                throw new XMLParserException(getString(
                        "RuntimeError.16", resource)); //$NON-NLS-1$
            } else {
                throw new XMLParserException(getString(
                        "RuntimeError.17", url)); //$NON-NLS-1$
            }
        }
    }
View Full Code Here

        String resource = attributes.getProperty("resource"); //$NON-NLS-1$
        String url = attributes.getProperty("url"); //$NON-NLS-1$

        if (!stringHasValue(resource)
                && !stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        if (stringHasValue(resource)
                && stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        URL resourceUrl;

        try {
            if (stringHasValue(resource)) {
                resourceUrl = ObjectFactory.getResource(resource);
                if (resourceUrl == null) {
                    throw new XMLParserException(getString(
                            "RuntimeError.15", resource)); //$NON-NLS-1$
                }
            } else {
                resourceUrl = new URL(url);
            }

            InputStream inputStream = resourceUrl.openConnection()
                    .getInputStream();

            properties.load(inputStream);
            inputStream.close();
        } catch (IOException e) {
            if (stringHasValue(resource)) {
                throw new XMLParserException(getString(
                        "RuntimeError.16", resource)); //$NON-NLS-1$
            } else {
                throw new XMLParserException(getString(
                        "RuntimeError.17", url)); //$NON-NLS-1$
            }
        }
    }
View Full Code Here

            Document document = null;
            try {
                document = builder.parse(inputSource);
            } catch (SAXParseException e) {
                throw new XMLParserException(parseErrors);
            } catch (SAXException e) {
                if (e.getException() == null) {
                    parseErrors.add(e.getMessage());
                } else {
                    parseErrors.add(e.getException().getMessage());
                }
            }

            if (parseErrors.size() > 0) {
                throw new XMLParserException(parseErrors);
            }

            Configuration config;
            Element rootNode = document.getDocumentElement();
            DocumentType docType = document.getDoctype();
            if (rootNode.getNodeType() == Node.ELEMENT_NODE
                    && docType.getPublicId().equals(
                            XmlConstants.IBATOR_CONFIG_PUBLIC_ID)) {
                config = parseIbatorConfiguration(rootNode);
            } else if (rootNode.getNodeType() == Node.ELEMENT_NODE
                    && docType.getPublicId().equals(
                            XmlConstants.MYBATIS_GENERATOR_CONFIG_PUBLIC_ID)) {
                config = parseMyBatisGeneratorConfiguration(rootNode);
            } else {
                throw new XMLParserException(getString("RuntimeError.5")); //$NON-NLS-1$
            }

            if (parseErrors.size() > 0) {
                throw new XMLParserException(parseErrors);
            }

            return config;
        } catch (ParserConfigurationException e) {
            parseErrors.add(e.getMessage());
            throw new XMLParserException(parseErrors);
        }
    }
View Full Code Here

        String resource = attributes.getProperty("resource"); //$NON-NLS-1$
        String url = attributes.getProperty("url"); //$NON-NLS-1$

        if (!stringHasValue(resource)
                && !stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        if (stringHasValue(resource)
                && stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        URL resourceUrl;

        try {
            if (stringHasValue(resource)) {
                resourceUrl = Thread.currentThread().getContextClassLoader()
                        .getResource(resource);
                if (resourceUrl == null) {
                    throw new XMLParserException(getString(
                            "RuntimeError.15", resource)); //$NON-NLS-1$
                }
            } else {
                resourceUrl = new URL(url);
            }

            InputStream inputStream = resourceUrl.openConnection()
                    .getInputStream();

            properties.load(inputStream);
            inputStream.close();
        } catch (IOException e) {
            if (stringHasValue(resource)) {
                throw new XMLParserException(getString(
                        "RuntimeError.16", resource)); //$NON-NLS-1$
            } else {
                throw new XMLParserException(getString(
                        "RuntimeError.17", url)); //$NON-NLS-1$
            }
        }
    }
View Full Code Here

        String resource = attributes.getProperty("resource"); //$NON-NLS-1$
        String url = attributes.getProperty("url"); //$NON-NLS-1$

        if (!stringHasValue(resource)
                && !stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        if (stringHasValue(resource)
                && stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        URL resourceUrl;

        try {
            if (stringHasValue(resource)) {
                resourceUrl = Thread.currentThread().getContextClassLoader()
                        .getResource(resource);
                if (resourceUrl == null) {
                    throw new XMLParserException(getString(
                            "RuntimeError.15", resource)); //$NON-NLS-1$
                }
            } else {
                resourceUrl = new URL(url);
            }

            InputStream inputStream = resourceUrl.openConnection()
                    .getInputStream();

            properties.load(inputStream);
            inputStream.close();
        } catch (IOException e) {
            if (stringHasValue(resource)) {
                throw new XMLParserException(getString(
                        "RuntimeError.16", resource)); //$NON-NLS-1$
            } else {
                throw new XMLParserException(getString(
                        "RuntimeError.17", url)); //$NON-NLS-1$
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.mybatis.generator.exception.XMLParserException

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.