Java 8 SAXException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SAXException class.

This code example shows how to use the following methods:getMessage, getColumnNumber, getLineNumber, getSystemId
 
  // ErrorHandler 
 
  @Override 
  public void warning(SAXParseException e) {
    log.warn("XML parse warning in \""+e.getSystemId()+"\", line "+e.getLineNumber()+", column "+e.getColumnNumber()+": "+e.getMessage());
  } 
 
  @Override 
  public void error(SAXParseException e) throws SAXException {
    throw e;
  } 
 
  @Override 
  public void fatalError(SAXParseException e) throws SAXException {
    throw e;
  } 
 
  // ErrorListener 
 
7
CodeRank
This code example shows how to use the following methods:getMessage, getColumnNumber, getLineNumber, getPublicId, getSystemId
     * @param ex  PARAM 
     * @return    Returns 
     */ 
    public String print( SAXParseException ex ) {
        StringBuffer sb = new StringBuffer();
        sb.append( "Exception: " + ex.getMessage() );
        sb.append( "failed at column : " + ex.getColumnNumber() +
                " on line " + ex.getLineNumber() );
        sb.append( "entity:\n" + ex.getPublicId() + "\n" + ex.getSystemId() );
        return sb.toString();
    } 
 
    /** 
     * Sets the textArea attribute of the ValidationHandler object 
     * 
     * @param jta  The new textArea value 
     */ 
    public void setTextArea( JTextArea jta ) {
        this.jta = jta;
    } 
7
CodeRank
This code example shows how to use the following methods:getException, getMessage, getColumnNumber, getLineNumber, getPublicId
This code example shows how to use the following methods:getMessage, getLineNumber, getSystemId, toString
      xr.setDTDHandler(null);
      xr.parse(new InputSource(fileReader));
      visitor.close(null);
    } catch (SAXParseException e) {
      System.out.println("XML parsing error: " + "\n" +
          "Line:    " + e.getLineNumber() + "\n" +
          "URI:     " + e.getSystemId() + "\n" +
          "Message: " + e.getMessage());        
      visitor.close(e);
      throw new IOException(e.toString());
    } catch (SAXException e) {
      visitor.close(e);
      throw new IOException(e.toString());
    } catch (RuntimeException e) {
      visitor.close(e);
      throw e;
    } finally { 
      fileReader.close();
    } 
  } 
8
CodeRank
This code example shows how to use the following methods:getMessage, getLineNumber, getSystemId, toString
      xr.setDTDHandler(null);
      xr.parse(new InputSource(fileReader));
      visitor.close(null);
    } catch (SAXParseException e) {
      System.out.println("XML parsing error: " + "\n" +
          "Line:    " + e.getLineNumber() + "\n" +
          "URI:     " + e.getSystemId() + "\n" +
          "Message: " + e.getMessage());        
      visitor.close(e);
      throw new IOException(e.toString());
    } catch (SAXException e) {
      visitor.close(e);
      throw new IOException(e.toString());
    } catch (RuntimeException e) {
      visitor.close(e);
      throw e;
    } finally { 
      fileReader.close();
    } 
  } 
7
CodeRank
This code example shows how to use the following methods:getMessage
    contentHandler = serializer.asContentHandler();
    try { 
      contentHandler.startDocument();
      contentHandler.startElement("", "", "EDITS", new AttributesImpl());
    } catch (SAXException e) {
      throw new IOException("SAX error: " + e.getMessage());
    } 
  } 
 
  /** 
   * Start visitor (initialization) 
   */ 
  @Override 
  public void start(int version) throws IOException {
    try { 
      contentHandler.startElement("", "", "EDITS_VERSION", new AttributesImpl());
      StringBuilder bld = new StringBuilder();
      bld.append(version);
      addString(bld.toString());
      contentHandler.endElement("", "", "EDITS_VERSION");
7
CodeRank
This code example shows how to use the following methods:getException, getMessage
                    "IOException was thrown.", exception);
 
            pmdException.fillInStackTrace();
            throw pmdException;
        } catch (SAXException exception) {
            if (exception.getMessage() == REJECT_NOT_INCLUDED) {
                // Return a null rule set to indicate that it should not be included. 
                return null; 
            } 
 
            Throwable originalException = exception.getException();
 
            if (originalException instanceof PMDException) {
                throw (PMDException) originalException;
            } 
 
            String message = "SAXException was thrown.";
            PMDException pmdException = new PMDException(message, exception);
 
            pmdException.fillInStackTrace();

7
CodeRank
This code example shows how to use the following methods:getMessage
            AdtPlugin.logAndPrintError(e, AndroidManifestHelper.class.getCanonicalName(),
                    "Bad parser configuration for %s: %s", 
                    manifestFile.getOsLocation(),
                    e.getMessage());
        } catch (SAXException e) {
            AdtPlugin.logAndPrintError(e, AndroidManifestHelper.class.getCanonicalName(),
                    "Parser exception for %s: %s", 
                    manifestFile.getOsLocation(),
                    e.getMessage());
        } catch (IOException e) {
            // Don't log a console error when failing to read a non-existing file 
            if (!(e instanceof FileNotFoundException)) {
                AdtPlugin.logAndPrintError(e, AndroidManifestHelper.class.getCanonicalName(),
                        "I/O error for %s: %s", 
                        manifestFile.getOsLocation(),
                        e.getMessage());
            } 
        } catch (StreamException e) {
            AdtPlugin.logAndPrintError(e, AndroidManifestHelper.class.getCanonicalName(),
                    "Unable to read %s: %s", 
7
CodeRank
This code example shows how to use the following methods:getMessage, getColumnNumber, getLineNumber, getSystemId
    } 
     
    private void log(SAXParseException spe, String type,Array array)	{
        StringBuffer sb = new StringBuffer("["+type+"] ");
         
        String id = spe.getSystemId();
        if(!StringUtil.isEmpty(id)) {
        	int li=id.lastIndexOf('/');
        	if(li!=-1)sb.append(id.substring(li+1));
        	else sb.append(id);
        } 
        sb.append(':');
        sb.append(spe.getLineNumber());
        sb.append(':');
        sb.append(spe.getColumnNumber());
        sb.append(": ");
        sb.append(spe.getMessage());
        sb.append(" ");
        array.appendEL(sb.toString());
    } 

7
CodeRank
This code example shows how to use the following methods:getMessage, getLineNumber, getSystemId
    public void fatalError(SAXParseException e) throws SAXException {
      throw new SAXException(getMessage("Fatal Error", e));
    } 
 
    private String getMessage(String level, SAXParseException e) {
      return ("Parsing " + level + "\n" + "Line:    " + e.getLineNumber() + "\n" + "URI:     " + e.getSystemId() + "\n"
              + "Message: " + e.getMessage());
    } 
  } 
 
 
} 
6
CodeRank

Related Java 8 SAXException Questions & Answers:

Other Java 8 SAXException Examples

12:					Log.e("Error: ", e.getMessage());
13:					return null;
14:				} catch (SAXException e) {
15:					Log.e("Error: ", e.getMessage());
16:		            return null;

Read More

75:					return null;
76:				} catch (SAXException e) {
77:					Log.e("Error: ", e.getMessage());
78:		            return null;
79:				} catch (IOException e) {

Read More

75:					return null;
76:				} catch (SAXException e) {
77:					Log.e("Error: ", e.getMessage());
78:		            return null;
79:				} catch (IOException e) {

Read More

See Code Examples for Java 8 SAXException Methods: