@Override public void addCompletedChild( ParseContext context, String namespaceURI, String localName, Object child) throws SAXParseException { if (child instanceof String) { String s = (String) child; if ("component-type".equals(localName)) _info.componentType = s; else if ("component-class".equals(localName)) _info.componentClass = s; } }
/** Creates an XMLParseException from a SAXParseException. */ protected static XMLParseException createXMLParseException(SAXParseException exception) { final String fPublicId = exception.getPublicId(); final String fExpandedSystemId = exception.getSystemId(); final int fLineNumber = exception.getLineNumber(); final int fColumnNumber = exception.getColumnNumber(); XMLLocator location = new XMLLocator() { public String getPublicId() { return fPublicId; } public String getExpandedSystemId() { return fExpandedSystemId; } public String getBaseSystemId() { return null; } public String getLiteralSystemId() { return null; } public int getColumnNumber() { return fColumnNumber; } public int getLineNumber() { return fLineNumber; } public int getCharacterOffset() { return -1; } public String getEncoding() { return null; } public String getXMLVersion() { return null; } }; return new XMLParseException(location, exception.getMessage(),exception); }
@Override public void addCompletedChild( ParseContext context, String namespaceURI, String localName, Object child) throws SAXParseException { if (child instanceof String) { String s = (String) child; if ("component-family".equals(localName)) _info.componentFamily = s; else if ("renderer-type".equals(localName)) _info.rendererType = s; else if ("renderer-class".equals(localName)) _info.rendererClass = s; } }
/** * Returns a string of the location. */ private String getLocationString(SAXParseException ex) { StringBuilder str = new StringBuilder(); String systemId = ex.getSystemId(); if (systemId != null) { int index = systemId.lastIndexOf('/'); if (index != -1) { systemId = systemId.substring(index + 1); } str.append(systemId); } str.append(':'); str.append(ex.getLineNumber()); str.append(':'); str.append(ex.getColumnNumber()); return str.toString(); }
private @Nullable Element getFromMetadataResolver(String systemId, Exception ex) { //try MEX MetaDataResolver resolver; ServiceDescriptor serviceDescriptor = null; for (MetadataResolverFactory resolverFactory : ServiceFinder.find(MetadataResolverFactory.class)) { resolver = resolverFactory.metadataResolver(options.entityResolver); try { serviceDescriptor = resolver.resolve(new URI(systemId)); //we got the ServiceDescriptor, now break if (serviceDescriptor != null) break; } catch (URISyntaxException e) { throw new ParseException(e); } } if (serviceDescriptor != null) { errorReceiver.warning(new SAXParseException(WsdlMessages.TRY_WITH_MEX(ex.getMessage()), null, ex)); return parseMetadata(systemId, serviceDescriptor); } else { errorReceiver.error(null, WsdlMessages.PARSING_UNABLE_TO_GET_METADATA(ex.getMessage(), WscompileMessages.WSIMPORT_NO_WSDL(systemId)), ex); } return null; }
/** * Filter a fatal error event. * * @param e The error as an exception. * @exception org.xml.sax.SAXException The client may throw * an exception during processing. */ public void fatalError (SAXParseException e) throws SAXException { if (errorHandler != null) { errorHandler.fatalError(e); } }
private void error(SAXParseException message) throws BuildException { noteError(); try { if (eh != null) { eh.error(message); } } catch (SAXException e) { throw new BuildException(e); } }
/** * Forward notification of a parsing error to the application supplied * error handler (if any). * * @param exception The error information * * @exception SAXException if a parsing exception occurs */ @Override public void error(SAXParseException exception) throws SAXException { log.error("Parse Error at line " + exception.getLineNumber() + " column " + exception.getColumnNumber() + ": " + exception.getMessage(), exception); if (errorHandler != null) { errorHandler.error(exception); } }
/** * Forward notification of a parsing error to the application supplied error * handler (if any). * * @param exception * The error information * * @exception SAXException * if a parsing exception occurs */ @Override public void error(SAXParseException exception) throws SAXException { log.error("Parse Error at line " + exception.getLineNumber() + " column " + exception.getColumnNumber() + ": " + exception.getMessage(), exception); if (errorHandler != null) { errorHandler.error(exception); } }
@Override public void fatalError(SAXParseException e) throws SAXException { if (fatalErrors == null) { fatalErrors = new LinkedList<SAXParseException>(); } fatalErrors.add(e); if (fatalErrors.size() > 100) { throw e; } }
public void fatalError(SAXParseException exception) throws SAXException { try { targetHandler.error(exception); } finally { importer.error(exception); } }
public void testValidation() throws Exception { Game game = ServerTestHelper.startServerGame(getTestMap(true)); Colony colony = getStandardColony(6); Player player = game.getPlayerByNationId("model.nation.dutch"); ServerTestHelper.newTurn(); ServerTestHelper.newTurn(); String serialized = null; try { Validator validator = buildValidator("schema/data/data-game.xsd"); serialized = game.serialize(); validator.validate(new StreamSource(new StringReader(serialized))); } catch (SAXParseException e) { int col = e.getColumnNumber(); String errMsg = e.getMessage() + "\nAt line=" + e.getLineNumber() + ", column=" + col + ":\n"; if (serialized != null) { errMsg += serialized.substring(Math.max(0, col - 100), Math.min(col + 100, serialized.length())); } fail(errMsg); } ServerTestHelper.stopServerGame(); }
/** * Issues a SAX warning. * * @param poParseException the parse exception to warn about * @throws SAXException */ public void warning(SAXParseException poParseException) throws SAXException { this.oOut.println ( "WARNING: " + getParseExceptionInfo(poParseException) ); }
/** * Returns a string describing parse exception details. * * @param poParseException exception to get info from * @return string representation of the info */ private String getParseExceptionInfo(SAXParseException poParseException) { String strSystemId = poParseException.getSystemId(); if (strSystemId == null) { strSystemId = "null"; } String strErrInfo = "URI=" + strSystemId + " Line=" + poParseException.getLineNumber() + ": " + poParseException.getMessage(); return strErrInfo; }
@Override public Object endElement( ParseContext context, String namespaceURI, String localName) throws SAXParseException { return _info; }
public static SAXParseException toSAXParseException( XMLParseException e ) { if( e.getException() instanceof SAXParseException ) return (SAXParseException)e.getException(); return new SAXParseException( e.getMessage(), e.getPublicId(), e.getExpandedSystemId(), e.getLineNumber(), e.getColumnNumber(), e.getException() ); }
@Override public NodeParser startChildElement( ParseContext context, String namespaceURI, String localName, Attributes attrs ) throws SAXParseException { if ("skin-id".equals(localName) || "style-sheet-name".equals(localName) || "bundle-name".equals(localName) || "translation-source".equals(localName)) { return new StringParser(); } else if ("features".equals(localName)) { return context.getParser(SkinFeatures.class, namespaceURI, localName); } else if ("metadata".equals(localName)) { return context.getParser(CustomMetadata.class, namespaceURI, localName); } return null; }
public static void ensureLocationSet(TransformerException exception) { // SourceLocator locator = exception.getLocator(); SourceLocator locator = null; Throwable cause = exception; // Try to find the locator closest to the cause. do { if(cause instanceof SAXParseException) { locator = new SAXSourceLocator((SAXParseException)cause); } else if (cause instanceof TransformerException) { SourceLocator causeLocator = ((TransformerException)cause).getLocator(); if(null != causeLocator) locator = causeLocator; } if(cause instanceof TransformerException) cause = ((TransformerException)cause).getCause(); else if(cause instanceof SAXException) cause = ((SAXException)cause).getException(); else cause = null; } while(null != cause); exception.setLocator(locator); }
void error(String messageId, Object parameters []) throws SAXException { SAXParseException e = new SAXParseException(messages.getMessage(locale, messageId, parameters), getPublicId(), getSystemId(), getLineNumber(), getColumnNumber()); dtdHandler.error(e); }
@Override public void startElement( ParseContext context, String namespaceURI, String localName, Attributes attrs) throws SAXParseException { boolean matchesBase = "true".equals(attrs.getValue("matchesBase")); String name = getRequiredAttribute(context, attrs, "name"); String valueStr = attrs.getValue("value"); FacesConfigInfo.PropertyInfo property = _componentInfo.getPropertyInfo(name); final Object value; if (!ComponentDefinition.isValueExpression(valueStr) && (property != null) && (property.type != null)) value = Coercions.coerce(null, valueStr, property.type); else value = valueStr; Set<Accessibility> unsupportedModes = _parseUnsupportedAccessibilityModes(attrs); Set<String> unsupportedDevices = _parseUnsupportedDevices(attrs); Set<CapabilityKey> requiredCapabilities = _parseRequiredCapabilities(attrs); boolean noRTL = _parseNoRTL(attrs); _test = new TestScript.AttributeTest(name, value, matchesBase, null, _componentId, unsupportedModes, unsupportedDevices, requiredCapabilities, noRTL); }
public void warning(SAXParseException e) throws SAXException { XMLErrorHandler eh = getErrorHandler(); if (eh instanceof ErrorHandlerWrapper) { ((ErrorHandlerWrapper)eh).fErrorHandler.warning(e); } else { eh.warning("","",ErrorHandlerWrapper.createXMLParseException(e)); } }
private String toString(SAXParseException e) { StringBuilder buf = new StringBuilder(); buf.append(sourceName); buf.append(" ("); buf.append(e.getLineNumber()); buf.append(":"); buf.append(e.getColumnNumber()); buf.append(" at "); buf.append(e.getPublicId()); buf.append(") "); buf.append(e.getLocalizedMessage()); return buf.toString(); }
/** @inheritDoc */ public void error(SAXParseException ex) throws SAXException { if (IgnoreAllErrorHandler.warnOnExceptions) { log.log(java.util.logging.Level.SEVERE, "", ex); } if (IgnoreAllErrorHandler.throwExceptions) { throw ex; } }
/** * @param ex The exception to create a message from * @return A summary of what went wrong. */ private String getMessage(SAXParseException ex) { if (ex.getSystemId() != null) { return "SystemID=" + ex.getSystemId() + " Line=" + ex.getLineNumber() + ' ' + ex.getMessage(); } if (ex.getPublicId() != null) { return "PublicID=" + ex.getPublicId() + " Line=" + ex.getLineNumber() + ' ' + ex.getMessage(); } return "Line=" + ex.getLineNumber() + ' ' + ex.getMessage(); }
/** * Create a SAX exception which also understands about the location in * the digester file where the exception occurs * * @return the new exception */ public SAXException createSAXException(String message, Exception e) { if ((e != null) && (e instanceof InvocationTargetException)) { Throwable t = e.getCause(); if (t instanceof ThreadDeath) { throw (ThreadDeath) t; } if (t instanceof VirtualMachineError) { throw (VirtualMachineError) t; } if (t instanceof Exception) { e = (Exception) t; } } if (locator != null) { String error = "Error at (" + locator.getLineNumber() + ", " + locator.getColumnNumber() + ") : " + message; if (e != null) { return new SAXParseException(error, locator, e); } else { return new SAXParseException(error, locator); } } log.error("No Locator!"); if (e != null) { return new SAXException(message, e); } else { return new SAXException(message); } }
@Override public void endDocument() throws SAXException { if( isJAXBPrefixUsed && !isCustomizationUsed ) { SAXParseException e = new SAXParseException( Messages.format(Messages.WARN_INCORRECT_URI, Const.JAXB_NSURI), locator ); errorHandler.warning(e); } super.endDocument(); }
public void error(SAXParseException e) { if(debug) e.printStackTrace(); hasError = true; if((e.getSystemId() == null && e.getPublicId() == null) && (e.getCause() instanceof UnknownHostException)) { print(WscompileMessages.WSIMPORT_ERROR_MESSAGE(e.toString()), e); } else { print(WscompileMessages.WSIMPORT_ERROR_MESSAGE(e.getMessage()), e); } }
private void warning(String key, Locator loc) throws SAXException { warning(new SAXParseException(localizer.message(key), loc)); }
public void warning(SAXParseException ex) { LOGGER.warn("xml parsing: {}: {}", getLocationString(ex), ex.getMessage()); }
private void throwError(SAXParseException e) { throw ScriptRuntime.constructError("TypeError", e.getMessage(), e.getLineNumber() - 1); }
public void fatalError(SAXParseException e) throws SAXException { throw e; }
@Override public void error(SAXParseException e) throws SAXException { System.err.print("Warning: Failed to compile flag " + name + ": "); System.err.println("ERROR on "+e.getLineNumber()+":"+e.getColumnNumber()+": "+e.getMessage()); }
/** * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException) */ public void fatalError(SAXParseException arg0) throws SAXException { couldThrowSAXException(); }
public void error(SAXParseException exception) { hadError = true; if(core!=null) core.error(exception); }
@Override public void fatalError(SAXParseException error) { error( error ); }
public void warning(SAXParseException exception) throws SAXException { warnings.add(getString("Warning.7", //$NON-NLS-1$ Integer.toString(exception.getLineNumber()), exception .getMessage())); }
@Override public void error(SAXParseException exception) throws SAXException { errors.add(exception.getMessage()); }
public List<SAXParseException> getErrors() { // Internal use only - don't worry about immutability return errors; }
/** * Reports a warning. */ public final void warning( @Nullable Locator loc, String msg ) { warning( new SAXParseException(msg,loc) ); }