transformeridentityimpl.java

来自「java jdk 1.4的源码」· Java 代码 · 共 1,425 行 · 第 1/4 页

JAVA
1,425
字号
   *   * @throws IllegalArgumentException If the property is not supported.   *   * @see javax.xml.transform.OutputKeys   */  public String getOutputProperty(String name) throws IllegalArgumentException  {    String value = null;    OutputProperties props = m_outputFormat;    value = props.getProperty(name);    if (null == value)    {      if (!props.isLegalPropertyKey(name))        throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, new Object[]{name})); //"output property not recognized: "                                          // + name);    }    return value;  }  /**   * Set the error event listener in effect for the transformation.   *   * @param listener The new error listener.   * @throws IllegalArgumentException if listener is null.   */  public void setErrorListener(ErrorListener listener)          throws IllegalArgumentException  {      if (listener == null)        throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_NULL_ERROR_HANDLER, null));      else        m_errorListener = listener;  }  /**   * Get the error event handler in effect for the transformation.   *   * @return The current error handler, which should never be null.   */  public ErrorListener getErrorListener()  {    return m_errorListener;  }  ////////////////////////////////////////////////////////////////////  // Default implementation of DTDHandler interface.  ////////////////////////////////////////////////////////////////////  /**   * Receive notification of a notation declaration.   *   * <p>By default, do nothing.  Application writers may override this   * method in a subclass if they wish to keep track of the notations   * declared in a document.</p>   *   * @param name The notation name.   * @param publicId The notation public identifier, or null if not   *                 available.   * @param systemId The notation system identifier.   * @throws org.xml.sax.SAXException Any SAX exception, possibly   *            wrapping another exception.   * @see org.xml.sax.DTDHandler#notationDecl   *   * @throws SAXException   */  public void notationDecl(String name, String publicId, String systemId)          throws SAXException  {    if (null != m_resultDTDHandler)      m_resultDTDHandler.notationDecl(name, publicId, systemId);  }  /**   * Receive notification of an unparsed entity declaration.   *   * <p>By default, do nothing.  Application writers may override this   * method in a subclass to keep track of the unparsed entities   * declared in a document.</p>   *   * @param name The entity name.   * @param publicId The entity public identifier, or null if not   *                 available.   * @param systemId The entity system identifier.   * @param notationName The name of the associated notation.   * @throws org.xml.sax.SAXException Any SAX exception, possibly   *            wrapping another exception.   * @see org.xml.sax.DTDHandler#unparsedEntityDecl   *   * @throws SAXException   */  public void unparsedEntityDecl(          String name, String publicId, String systemId, String notationName)            throws SAXException  {    if (null != m_resultDTDHandler)      m_resultDTDHandler.unparsedEntityDecl(name, publicId, systemId,                                            notationName);  }  ////////////////////////////////////////////////////////////////////  // Default implementation of ContentHandler interface.  ////////////////////////////////////////////////////////////////////  /**   * Receive a Locator object for document events.   *   * <p>By default, do nothing.  Application writers may override this   * method in a subclass if they wish to store the locator for use   * with other document events.</p>   *   * @param locator A locator for all SAX document events.   * @see org.xml.sax.ContentHandler#setDocumentLocator   * @see org.xml.sax.Locator   */  public void setDocumentLocator(Locator locator)  {    try    {      if (null == m_resultContentHandler)        createResultContentHandler(m_result);    }    catch (TransformerException te)    {      throw new org.apache.xml.utils.WrappedRuntimeException(te);    }    m_resultContentHandler.setDocumentLocator(locator);  }  /**   * Receive notification of the beginning of the document.   *   * <p>By default, do nothing.  Application writers may override this   * method in a subclass to take specific actions at the beginning   * of a document (such as allocating the root node of a tree or   * creating an output file).</p>   *   * @throws org.xml.sax.SAXException Any SAX exception, possibly   *            wrapping another exception.   * @see org.xml.sax.ContentHandler#startDocument   *   * @throws SAXException   */  public void startDocument() throws SAXException  {    try    {      if (null == m_resultContentHandler)        createResultContentHandler(m_result);    }    catch (TransformerException te)    {      throw new SAXException(te.getMessage(), te);    }    // Reset for multiple transforms with this transformer.    m_flushedStartDoc = false;    m_foundFirstElement = false;  }    boolean m_flushedStartDoc = false;    protected final void flushStartDoc()     throws SAXException  {    if(!m_flushedStartDoc)    {      m_resultContentHandler.startDocument();      m_flushedStartDoc = true;    }  }  /**   * Receive notification of the end of the document.   *   * <p>By default, do nothing.  Application writers may override this   * method in a subclass to take specific actions at the end   * of a document (such as finalising a tree or closing an output   * file).</p>   *   * @throws org.xml.sax.SAXException Any SAX exception, possibly   *            wrapping another exception.   * @see org.xml.sax.ContentHandler#endDocument   *   * @throws SAXException   */  public void endDocument() throws SAXException  {    flushStartDoc();    m_resultContentHandler.endDocument();  }  /**   * Receive notification of the start of a Namespace mapping.   *   * <p>By default, do nothing.  Application writers may override this   * method in a subclass to take specific actions at the start of   * each Namespace prefix scope (such as storing the prefix mapping).</p>   *   * @param prefix The Namespace prefix being declared.   * @param uri The Namespace URI mapped to the prefix.   * @throws org.xml.sax.SAXException Any SAX exception, possibly   *            wrapping another exception.   * @see org.xml.sax.ContentHandler#startPrefixMapping   *   * @throws SAXException   */  public void startPrefixMapping(String prefix, String uri)          throws SAXException  {    flushStartDoc();    m_resultContentHandler.startPrefixMapping(prefix, uri);  }  /**   * Receive notification of the end of a Namespace mapping.   *   * <p>By default, do nothing.  Application writers may override this   * method in a subclass to take specific actions at the end of   * each prefix mapping.</p>   *   * @param prefix The Namespace prefix being declared.   * @throws org.xml.sax.SAXException Any SAX exception, possibly   *            wrapping another exception.   * @see org.xml.sax.ContentHandler#endPrefixMapping   *   * @throws SAXException   */  public void endPrefixMapping(String prefix) throws SAXException  {    flushStartDoc();    m_resultContentHandler.endPrefixMapping(prefix);  }  /**   * Receive notification of the start of an element.   *   * <p>By default, do nothing.  Application writers may override this   * method in a subclass to take specific actions at the start of   * each element (such as allocating a new tree node or writing   * output to a file).</p>   *   * @param uri The Namespace URI, or the empty string if the   *        element has no Namespace URI or if Namespace   *        processing is not being performed.   * @param localName The local name (without prefix), or the   *        empty string if Namespace processing is not being   *        performed.   * @param qName The qualified name (with prefix), or the   *        empty string if qualified names are not available.   * @param attributes The specified or defaulted attributes.   * @throws org.xml.sax.SAXException Any SAX exception, possibly   *            wrapping another exception.   * @see org.xml.sax.ContentHandler#startElement   *   * @throws SAXException   */  public void startElement(          String uri, String localName, String qName, Attributes attributes)            throws SAXException  {    if (!m_foundFirstElement && null != m_serializer)    {      m_foundFirstElement = true;      Serializer newSerializer;      try      {        newSerializer = SerializerSwitcher.switchSerializerIfHTML(uri,                localName, m_outputFormat.getProperties(), m_serializer);      }      catch (TransformerException te)      {        throw new SAXException(te);      }      if (newSerializer != m_serializer)      {        try        {          m_resultContentHandler = newSerializer.asContentHandler();        }        catch (IOException ioe)  // why?        {          throw new SAXException(ioe);        }        if (m_resultContentHandler instanceof DTDHandler)          m_resultDTDHandler = (DTDHandler) m_resultContentHandler;        if (m_resultContentHandler instanceof LexicalHandler)          m_resultLexicalHandler = (LexicalHandler) m_resultContentHandler;        m_serializer = newSerializer;      }    }    flushStartDoc();    m_resultContentHandler.startElement(uri, localName, qName, attributes);  }  /**   * Receive notification of the end of an element.   *   * <p>By default, do nothing.  Application writers may override this   * method in a subclass to take specific actions at the end of   * each element (such as finalising a tree node or writing   * output to a file).</p>   *   * @param uri The Namespace URI, or the empty string if the   *        element has no Namespace URI or if Namespace   *        processing is not being performed.   * @param localName The local name (without prefix), or the   *        empty string if Namespace processing is not being   *        performed.   * @param qName The qualified name (with prefix), or the   *        empty string if qualified names are not available.   * @param attributes The specified or defaulted attributes.   *   * @throws org.xml.sax.SAXException Any SAX exception, possibly   *            wrapping another exception.   * @see org.xml.sax.ContentHandler#endElement   *   * @throws SAXException   */  public void endElement(String uri, String localName, String qName)          throws SAXException  {    m_resultContentHandler.endElement(uri, localName, qName);  }  /**   * Receive notification of character data inside an element.   *   * <p>By default, do nothing.  Application writers may override this   * method to take specific actions for each chunk of character data   * (such as adding the data to a node or buffer, or printing it to   * a file).</p>   *   * @param ch The characters.   * @param start The start position in the character array.   * @param length The number of characters to use from the   *               character array.   * @throws org.xml.sax.SAXException Any SAX exception, possibly   *            wrapping another exception.   * @see org.xml.sax.ContentHandler#characters   *   * @throws SAXException   */  public void characters(char ch[], int start, int length) throws SAXException

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?