Refine search
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (localName.equals("factory")) { String className = attributes.getValue("class"); try { addClass(className); } catch (ClassNotFoundException e) { throw new SAXException("Cannot find Matcher class : " + className); } } } });
public void characters(char[] text, int start, int length) throws SAXException { try { out.write(text, start, length); } catch (IOException e) { throw new SAXException(e); } }
/** * This helper method to writes out "]]>" when closing a CDATA section. * * @throws org.xml.sax.SAXException */ protected void closeCDATA() throws org.xml.sax.SAXException { try { m_writer.write(CDATA_DELIMITER_CLOSE); // write out a CDATA section closing "]]>" m_cdataTagOpen = false; // Remember that we have done so. } catch (IOException e) { throw new SAXException(e); } }
/** * Utility to safely get an attribute. If it does not exist an exception * is thrown. * @param attributes collect to get attribute from. * @param name name of the attribute to get. * @return the value of the attribute. * @throws SAXException if the attribute does not exist. */ private static String safeGet(Attributes attributes, String name) throws SAXException { final String returnValue = attributes.getValue(name); if (returnValue == null) { // -@cs[IllegalInstantiation] SAXException is in the overridden method signature // of the only method which calls the current one throw new SAXException("missing attribute " + name); } return returnValue; }
/** * This helper method to writes out "]]>" when closing a CDATA section. * * @throws org.xml.sax.SAXException */ protected void closeCDATA() throws org.xml.sax.SAXException { try { m_writer.write(CDATA_DELIMITER_CLOSE); // write out a CDATA section closing "]]>" m_cdataTagOpen = false; // Remember that we have done so. } catch (IOException e) { throw new SAXException(e); } }
private void checkNumber(Attributes attrs) throws SAXException { if (StringTools.isEmpty(attrs.getValue("no"))) { throw new SAXException("References cannot be empty: " + "\n Line: " + pLocator.getLineNumber() + ", column: " + pLocator.getColumnNumber() + "."); } else if (Integer.parseInt(attrs.getValue("no")) < 1 && regex.length() == 0) { throw new SAXException("References must be larger than 0: " + attrs.getValue("no") + "\n Line: " + pLocator.getLineNumber() + ", column: " + pLocator.getColumnNumber() + "."); } }
/** * Receive notivication of a entityReference. * * @param name non-null reference to entity name string. * * @throws org.xml.sax.SAXException */ public final void entityReference(String name) throws org.xml.sax.SAXException { try { final java.io.Writer writer = m_writer; writer.write('&'); writer.write(name); writer.write(';'); } catch(IOException e) { throw new SAXException(e); } } /**
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { String plugin = attributes.getValue("plugin"); if (plugin == null) { return; } if (!plugin.matches("[^@]+@[^@]+")) { throw new SAXException("Malformed plugin attribute: " + plugin); } int at = plugin.indexOf('@'); String shortName = plugin.substring(0, at); VersionNumber existing = requestedPlugins.get(shortName); VersionNumber requested = new VersionNumber(plugin.substring(at + 1)); if (existing == null || existing.compareTo(requested) < 0) { requestedPlugins.put(shortName, requested); } }
/** * Receive notivication of a entityReference. * * @param name non-null reference to entity name string. * * @throws org.xml.sax.SAXException */ public final void entityReference(String name) throws org.xml.sax.SAXException { try { final java.io.Writer writer = m_writer; writer.write('&'); writer.write(name); writer.write(';'); } catch(IOException e) { throw new SAXException(e); } } /**
/** * Returns the xpath filter, initialized from given attributes. * @param attributes the attributes of xml-tag "<suppress-xpath></suppress-xpath>", * specified inside suppression file. * @return the xpath filter * @throws SAXException if an error occurs. */ private static XpathFilter getXpathFilter(Attributes attributes) throws SAXException { final String checks = attributes.getValue(ATTRIBUTE_NAME_CHECKS); final String modId = attributes.getValue(ATTRIBUTE_NAME_ID); final String message = attributes.getValue(ATTRIBUTE_NAME_MESSAGE); if (checks == null && modId == null && message == null) { // -@cs[IllegalInstantiation] SAXException is in the overridden method signature throw new SAXException("missing checks or id or message attribute for suppress-xpath"); } final XpathFilter filter; try { final String files = attributes.getValue(ATTRIBUTE_NAME_FILES); final String xpathQuery = attributes.getValue(ATTRIBUTE_NAME_QUERY); filter = new XpathFilter(files, checks, message, modId, xpathQuery); } catch (final PatternSyntaxException ex) { // -@cs[IllegalInstantiation] SAXException is in the overridden method signature throw new SAXException("invalid files or checks or message format for suppress-xpath", ex); } return filter; }
@Override public final void endElement(final String ns, final String localName, final String qName) throws SAXException { ident -= 2; try { if (openElement) { w.write("/>\n"); openElement = false; } else { writeIdent(); w.write("</" + qName + ">\n"); } } catch (IOException ex) { throw new SAXException(ex); } }
/** * Returns the suppress element, initialized from given attributes. * @param attributes the attributes of xml-tag "<suppress></suppress>", specified inside * suppression file. * @return the suppress element * @throws SAXException if an error occurs. */ private static SuppressElement getSuppressElement(Attributes attributes) throws SAXException { final String checks = attributes.getValue(ATTRIBUTE_NAME_CHECKS); final String modId = attributes.getValue(ATTRIBUTE_NAME_ID); final String message = attributes.getValue(ATTRIBUTE_NAME_MESSAGE); if (checks == null && modId == null && message == null) { // -@cs[IllegalInstantiation] SAXException is in the overridden method signature throw new SAXException("missing checks or id or message attribute"); } final SuppressElement suppress; try { final String files = attributes.getValue(ATTRIBUTE_NAME_FILES); final String lines = attributes.getValue(ATTRIBUTE_NAME_LINES); final String columns = attributes.getValue(ATTRIBUTE_NAME_COLUMNS); suppress = new SuppressElement(files, checks, message, modId, lines, columns); } catch (final PatternSyntaxException ex) { // -@cs[IllegalInstantiation] SAXException is in the overridden method signature throw new SAXException("invalid files or checks or message format", ex); } return suppress; }
public final void comment(final char[] ch, final int off, final int len) throws SAXException { try { closeElement(); writeIdent(); w.write("<!-- "); w.write(ch, off, len); w.write(" -->\n"); } catch (IOException ex) { throw new SAXException(ex); } }
final String str = attr.getValue(METRICS_VERSION_ATTR); if (str == null) { err = "Missing " + METRICS_VERSION_ATTR + " attribute"; throw new SAXException( err + " - please regenerate the font metrics file with "
/** * Report the end of DTD declarations. * @throws org.xml.sax.SAXException The application may raise an exception. * @see #startDTD */ public void endDTD() throws org.xml.sax.SAXException { try { if (m_needToOutputDocTypeDecl) { outputDocTypeDecl(m_elemContext.m_elementName, false); m_needToOutputDocTypeDecl = false; } final java.io.Writer writer = m_writer; if (!m_inDoctype) writer.write("]>"); else { writer.write('>'); } writer.write(m_lineSep, 0, m_lineSepLen); } catch (IOException e) { throw new SAXException(e); } }
private String getRequiredAttribute(Attributes attributes, String attrName, String elementName) throws SAXException { String value = attributes.getValue(attrName); if (value == null) { throw new SAXException(elementName + " element missing " + attrName + " attribute"); } return memoized(Strings.unescapeXml(value)); }
/** * If available, when the disable-output-escaping attribute is used, * output raw text without escaping. * * @param ch The characters from the XML document. * @param start The start position in the array. * @param length The number of characters to read from the array. * * @throws org.xml.sax.SAXException */ protected void charactersRaw(char ch[], int start, int length) throws org.xml.sax.SAXException { if (m_inEntityRef) return; try { if (m_elemContext.m_startTagOpen) { closeStartTag(); m_elemContext.m_startTagOpen = false; } m_ispreserve = true; m_writer.write(ch, start, length); } catch (IOException e) { throw new SAXException(e); } }
@Override public final void startElement( final String namespaceURI, final String localName, final String qName, final Attributes list) throws SAXException { if (subdocument) { subdocumentHandler.startElement(namespaceURI, localName, qName, list); } else if (localName.equals(subdocumentRoot)) { String name = list.getValue("name"); if (name == null || name.length() == 0) { throw new SAXException("Class element without name attribute."); } try { entryElement.openEntry(isXml ? name + ".class.xml" : name + ".class"); } catch (IOException ex) { throw new SAXException(ex.toString(), ex); } subdocumentHandler = subdocumentHandlerFactory.createContentHandler(); subdocumentHandler.startDocument(); subdocumentHandler.startElement(namespaceURI, localName, qName, list); subdocument = true; } }
/** * Report the end of DTD declarations. * @throws org.xml.sax.SAXException The application may raise an exception. * @see #startDTD */ public void endDTD() throws org.xml.sax.SAXException { try { if (m_needToOutputDocTypeDecl) { outputDocTypeDecl(m_elemContext.m_elementName, false); m_needToOutputDocTypeDecl = false; } final java.io.Writer writer = m_writer; if (!m_inDoctype) writer.write("]>"); else { writer.write('>'); } writer.write(m_lineSep, 0, m_lineSepLen); } catch (IOException e) { throw new SAXException(e); } }
private void pushAttrib(Type type, Attributes attribs) throws SAXException { try { FloatBuffer buf = (FloatBuffer) mesh.getBuffer(type).getData(); buf.put(parseFloat(attribs.getValue("x"))).put(parseFloat(attribs.getValue("y"))).put(parseFloat(attribs.getValue("z"))); } catch (Exception ex) { throw new SAXException("Failed to push attrib", ex); } }