Package org.xml.sax

Examples of org.xml.sax.SAXException


  }

  public static LogisimFile load(File file, Loader loader)
      throws IOException {
    InputStream in = new FileInputStream(file);
    SAXException firstExcept = null;
    try {
      return loadSub(in, loader);
    } catch (SAXException e) {
      firstExcept = e;
    } finally {
      in.close();
    }
   
    if (firstExcept != null) {
      // We'll now try to do it using a reader. This is to work around
      // Logisim versions prior to 2.5.1, when files were not saved using
      // UTF-8 as the encoding (though the XML file reported otherwise).
      try {
        in = new ReaderInputStream(new FileReader(file), "UTF8");
        return loadSub(in, loader);
      } catch (Throwable t) {
        loader.showError(StringUtil.format(
            Strings.get("xmlFormatError"), firstExcept.toString()));
      } finally {
        try {
          in.close();
        } catch (Throwable t) { }
      }
View Full Code Here


      if (name.equals(A3CML.ELT_DOMAIN)) {
        try {
          domain = new A3CMLDomain(atts.getValue(A3CML.ATT_NAME),
                                   atts.getValue(A3CML.ATT_NETWORK));
        } catch (Exception exc) {
          throw new SAXException(exc.getMessage());
        }
      } else if (name.equals(A3CML.ELT_SERVER)) {
        try {
          short sid;
          try {
            sid = Short.parseShort(atts.getValue(A3CML.ATT_ID));
          } catch (NumberFormatException exc) {
            throw new Exception("bad value for server id: " +
                                atts.getValue(A3CML.ATT_ID));
          }
          server = new A3CMLServer(sid,
                                   atts.getValue(A3CML.ATT_NAME),
                                   atts.getValue(A3CML.ATT_HOSTNAME));
        } catch (Exception exc) {
          throw new SAXException(exc.getMessage());
        }
      } else if (name.equals(A3CML.ELT_CLUSTER)) {
        try {
          short sid;
          try {
            sid = Short.parseShort(atts.getValue(A3CML.ATT_ID));
          } catch (NumberFormatException exc) {
            throw new Exception("bad value for cluster id: " +
                                atts.getValue(A3CML.ATT_ID));
          }
          cluster = new A3CMLCluster(sid,
                                     atts.getValue(A3CML.ATT_NAME));
        } catch (Exception exc) {
          throw new SAXException(exc.getMessage());
        }
      } else if (name.equals(A3CML.ELT_NETWORK)) {
        try {
          int port;
          try {
            port = Integer.parseInt(atts.getValue(A3CML.ATT_PORT));
          } catch (NumberFormatException exc) {
            throw new Exception("bad value for network port: " +
                                atts.getValue(A3CML.ATT_PORT));
          }
          network = new A3CMLNetwork(atts.getValue(A3CML.ATT_DOMAIN),
                                     port);
        } catch (Exception exc) {
          throw new SAXException(exc.getMessage());
        }
      } else if (name.equals(A3CML.ELT_SERVICE)) {
        service = new A3CMLService(atts.getValue(A3CML.ATT_CLASS),
                                   atts.getValue(A3CML.ATT_ARGS));
      } else if (name.equals(A3CML.ELT_PROPERTY)) {
        property = new A3CMLProperty(atts.getValue(A3CML.ATT_NAME),
                                     atts.getValue(A3CML.ATT_VALUE));
      } else if (name.equals(A3CML.ELT_NAT)) {
        nat = new A3CMLNat(Short.parseShort(atts.getValue(A3CML.ATT_SID)),
                           atts.getValue(A3CML.ATT_HOSTNAME),
                           Integer.parseInt(atts.getValue(A3CML.ATT_PORT)));
      } else if (name.equals(A3CML.ELT_JVM_ARGS)) {
        jvmArgs = atts.getValue(A3CML.ATT_VALUE);
      } else {
        throw new SAXException("unknown element \"" + name + "\"");
      }
    }
  }
View Full Code Here

            server.jvmArgs = jvmArgs;
          else if (server ==  null && cluster != null)
            cluster.jvmArgs = jvmArgs;
          jvmArgs = null;
        } else {
          throw new SAXException("unknown element \"" + name + "\"");
        }
      } catch (SAXException exc) {
        throw exc;
      } catch (Exception exc) {
        throw new SAXException(exc.getMessage());
      }
    }
  }
View Full Code Here

    }

    @Override
    public void warning(SAXParseException e) throws SAXException {
      // you can choose not to handle it
      throw new SAXException(getMessage("Warning", e));
    }
View Full Code Here

      throw new SAXException(getMessage("Warning", e));
    }

    @Override
    public void error(SAXParseException e) throws SAXException {
      throw new SAXException(getMessage("Error", e));
    }
View Full Code Here

      throw new SAXException(getMessage("Error", e));
    }

    @Override
    public void fatalError(SAXParseException e) throws SAXException {
      throw new SAXException(getMessage("Fatal Error", e));
    }
View Full Code Here

   */
  protected void doneParsing() throws SAXException
  {
    if (pageDefList.isEmpty())
    {
      throw new SAXException
          ("page-definition element needs at least one page definition.");
    }

    final CustomPageDefinition pageDefinition = new CustomPageDefinition();

View Full Code Here

  protected void doneParsing()
      throws SAXException
  {
    if (pageReadHandler == null)
    {
      throw new SAXException
          ("simple-page-definition element needs one page definition.");
    }

    final SimplePageDefinition pageDefinition =
        new SimplePageDefinition(pageReadHandler.getPageFormat(), width, height);
View Full Code Here

                    break;

            }

            throw new SAXException("Tag not yet complete: " + localName);

        }
View Full Code Here

                        else if (encodingString.equals("plain"))
                            encoding = AuthInfo.Encoding.PLAIN_TEXT;
                        else if (encodingString.equals("md5"))
                            encoding = AuthInfo.Encoding.MD5;
                        else
                            throw new SAXException("Invalid encoding type");


                        current = new AuthInfo(
                            attributes.getValue("username"),
                            attributes.getValue("password"),
                            encoding
                        );

                        // Next state
                        state = State.AUTH_INFO;
                        return;
                    }

                    break;

                case AUTH_INFO:

                    if (localName.equals("protocol")) {
                        // Next state
                        state = State.PROTOCOL;
                        return;
                    }

                    if (localName.equals("param")) {

                        currentParameter = attributes.getValue("name");
                        if (currentParameter == null)
                            throw new SAXException("Attribute \"name\" required for param tag.");

                        // Next state
                        state = State.PARAMETER;
                        return;
                    }

                    break;

            }

            throw new SAXException("Unexpected tag: " + localName);

        }
View Full Code Here

TOP

Related Classes of org.xml.sax.SAXException

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.