• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SerializationHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.xml.serializer.SerializationHandler的典型用法代码示例。如果您正苦于以下问题:Java SerializationHandler类的具体用法?Java SerializationHandler怎么用?Java SerializationHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SerializationHandler类属于org.apache.xml.serializer包,在下文中一共展示了SerializationHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addAttributes

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
 * Copy DOM attributes to the result element.
 *
 * @param src Source node with the attributes
 *
 * @throws TransformerException
 */
public static void addAttributes(SerializationHandler handler, int src)
    throws TransformerException
{

    TransformerImpl transformer =
        (TransformerImpl) handler.getTransformer();
    DTM dtm = transformer.getXPathContext().getDTM(src);

    for (int node = dtm.getFirstAttribute(src);
        DTM.NULL != node;
        node = dtm.getNextAttribute(node))
    {
        addAttribute(handler, node);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:23,代码来源:SerializerUtils.java


示例2: isDefinedNSDecl

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
 * Returns whether a namespace is defined
 *
 *
 * @param attr Namespace attribute node
 * @param dtm The DTM that owns attr.
 *
 * @return True if the namespace is already defined in
 * list of namespaces
 */
public static boolean isDefinedNSDecl(
    SerializationHandler serializer,
    int attr,
    DTM dtm)
{

    if (DTM.NAMESPACE_NODE == dtm.getNodeType(attr))
    {

        // String prefix = dtm.getPrefix(attr);
        String prefix = dtm.getNodeNameX(attr);
        String uri = serializer.getNamespaceURIFromPrefix(prefix);
        //      String uri = getURI(prefix);

        if ((null != uri) && uri.equals(dtm.getStringValue(attr)))
            return true;
    }

    return false;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:31,代码来源:SerializerUtils.java


示例3: ensureNamespaceDeclDeclared

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
 * This function checks to make sure a given prefix is really
 * declared.  It might not be, because it may be an excluded prefix.
 * If it's not, it still needs to be declared at this point.
 * TODO: This needs to be done at an earlier stage in the game... -sb
 *
 * NEEDSDOC @param dtm
 * NEEDSDOC @param namespace
 *
 * @throws org.xml.sax.SAXException
 */
public static void ensureNamespaceDeclDeclared(
    SerializationHandler handler,
    DTM dtm,
    int namespace)
    throws org.xml.sax.SAXException
{

    String uri = dtm.getNodeValue(namespace);
    String prefix = dtm.getNodeNameX(namespace);

    if ((uri != null && uri.length() > 0) && (null != prefix))
    {
        String foundURI;
        NamespaceMappings ns = handler.getNamespaceMappings();
        if (ns != null)
        {

            foundURI = ns.lookupNamespace(prefix);
            if ((null == foundURI) || !foundURI.equals(uri))
            {
                handler.startPrefixMapping(prefix, uri, false);
            }
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:37,代码来源:SerializerUtils.java


示例4: resolvePrefix

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
 * Resolve the namespace into a prefix.  At this level, if no prefix exists, 
 * then return a manufactured prefix.
 *
 * @param rhandler The current result tree handler.
 * @param prefix The probable prefix if already known.
 * @param nodeNamespace  The namespace, which should not be null.
 *
 * @return The prefix to be used.
 */
protected String resolvePrefix(SerializationHandler rhandler,
                               String prefix, String nodeNamespace)
  throws TransformerException
{

  if (null != prefix && (prefix.length() == 0 || prefix.equals("xmlns")))
  {
    // Since we can't use default namespace, in this case we try and 
    // see if a prefix has already been defined or this namespace.
    prefix = rhandler.getPrefix(nodeNamespace);

    // System.out.println("nsPrefix: "+nsPrefix);           
    if (null == prefix || prefix.length() == 0 || prefix.equals("xmlns"))
    {
      if(nodeNamespace.length() > 0)
      {
          NamespaceMappings prefixMapping = rhandler.getNamespaceMappings();
          prefix = prefixMapping.generateNextPrefix();
      }
      else
        prefix = "";
    }
  }
  return prefix;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:36,代码来源:ElemAttribute.java


示例5: resolvePrefix

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
   * Resolve the namespace into a prefix.  Meant to be
   * overidded by elemAttribute if this class is derived.
   *
   * @param rhandler The current result tree handler.
   * @param prefix The probable prefix if already known.
   * @param nodeNamespace  The namespace.
   *
   * @return The prefix to be used.
   */
  protected String resolvePrefix(SerializationHandler rhandler,
                                 String prefix, String nodeNamespace)
    throws TransformerException
  {

//    if (null != prefix && prefix.length() == 0)
//    {
//      String foundPrefix = rhandler.getPrefix(nodeNamespace);
//
//      // System.out.println("nsPrefix: "+nsPrefix);           
//      if (null == foundPrefix)
//        foundPrefix = "";
//    }
    return prefix;
  }
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:26,代码来源:ElemElement.java


示例6: executeNSDecls

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
 * Send startPrefixMapping events to the result tree handler
 * for all declared prefix mappings in the stylesheet.
 *
 * @param transformer non-null reference to the the current transform-time state.
 * @param ignorePrefix string prefix to not startPrefixMapping
 *
 * @throws TransformerException
 */
void executeNSDecls(TransformerImpl transformer, String ignorePrefix) throws TransformerException
{  
  try
  {
    if (null != m_prefixTable)
    {
      SerializationHandler rhandler = transformer.getResultTreeHandler();
      int n = m_prefixTable.size();

      for (int i = n - 1; i >= 0; i--)
      {
        XMLNSDecl decl = (XMLNSDecl) m_prefixTable.get(i);

        if (!decl.getIsExcluded() && !(null != ignorePrefix && decl.getPrefix().equals(ignorePrefix)))
        {
          rhandler.startPrefixMapping(decl.getPrefix(), decl.getURI(), true);
        }
      }
    }
  }
  catch(org.xml.sax.SAXException se)
  {
    throw new TransformerException(se);
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:35,代码来源:ElemTemplateElement.java


示例7: execute

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
 * Copy the text literal to the result tree.
 *
 * @param transformer non-null reference to the the current transform-time state.
 *
 * @throws TransformerException
 */
public void execute(
        TransformerImpl transformer)
          throws TransformerException
{
  try
  {
    SerializationHandler rth = transformer.getResultTreeHandler();

      if (m_disableOutputEscaping)
    {
      rth.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
    }

    rth.characters(m_ch, 0, m_ch.length);

    if (m_disableOutputEscaping)
    {
      rth.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
    }
  }
  catch(SAXException se)
  {
    throw new TransformerException(se);
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:33,代码来源:ElemTextLiteral.java


示例8: setResult

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
   * Enables the user of the TransformerHandler to set the
   * to set the Result for the transformation.
   *
   * @param result A Result instance, should not be null.
   *
   * @throws IllegalArgumentException if result is invalid for some reason.
   */
  public void setResult(Result result) throws IllegalArgumentException
  {

    if (null == result)
      throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_RESULT_NULL, null)); //"result should not be null");

    try
    {
//      ContentHandler handler =
//        m_transformer.createResultContentHandler(result);
//      m_transformer.setContentHandler(handler);
        SerializationHandler xoh = 
            m_transformer.createSerializationHandler(result);
        m_transformer.setSerializationHandler(xoh);
    }
    catch (javax.xml.transform.TransformerException te)
    {
      throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_RESULT_COULD_NOT_BE_SET, null)); //"result could not be set");
    }

    m_result = result;
  }
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:31,代码来源:TransformerHandlerImpl.java


示例9: copyTextNode

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
 * Copy the String value of a Text node to a SerializationHandler
 */
protected final void copyTextNode(final int nodeID, SerializationHandler handler)
    throws SAXException
{
    if (nodeID != DTM.NULL) {
  	    int dataIndex = m_dataOrQName.elementAt(nodeID);
        if (dataIndex >= 0) {
            m_chars.sendSAXcharacters(handler,
                                      dataIndex >>> TEXT_LENGTH_BITS,
                                      dataIndex & TEXT_LENGTH_MAX);
        } else {
            m_chars.sendSAXcharacters(handler, m_data.elementAt(-dataIndex),
                                      m_data.elementAt(-dataIndex+1));
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:19,代码来源:SAX2DTM2.java


示例10: trace

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
@Override
public void trace(TracerEvent ev) {
  if (myTracing) return;
  myTracing = true; // prevents handling of recursive trace() events

  try {
    // init
    if (firstTrace) {
      firstTrace = false;
      final SerializationHandler handler = myTransformer.getSerializationHandler();
      myTransformer.setSerializationHandler(new TracingSerializationHandler(myDebugger, handler));
    }

    super.trace(ev);

    final DTMIterator iterator = myTransformer.getContextNodeList();
    final int node = myTransformer.getMatchedNode();
    final Debugger.SourceFrame sourceFrame = myDebugger.getSourceFrame();
    final boolean withSource;
    if (sourceFrame == null || ((MySourceFrame)sourceFrame).getMatchedNode() != node) {
      myDebugger.pushSource(new MySourceFrame(sourceFrame, iterator.getDTM(node), node));
      withSource = true;
    } else {
      withSource = false;
    }
    myDebugger.enter(new XalanStyleFrame(ev, myDebugger.getCurrentFrame(), withSource));
  } finally {
    myTracing = false;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:XalanTraceListener.java


示例11: TracingSerializationHandler

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
public TracingSerializationHandler(LocalDebugger debugger, SerializationHandler handler) {
    myDebugger = debugger;
    mySerializationHandler = handler;

//        final URL location = SerializationHandler.class.getProtectionDomain().getCodeSource().getLocation();
//        System.out.println("location = " + location);
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:TracingSerializationHandler.java


示例12: openOutputHandler

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/************************************************************************
    * Multiple output document extension.
    * See compiler/TransletOutput for actual implementation.
    ************************************************************************/

   public SerializationHandler openOutputHandler(String filename, boolean append) 
throws TransletException 
   {
try {
    final TransletOutputHandlerFactory factory 
	= TransletOutputHandlerFactory.newInstance();

           String dirStr = new File(filename).getParent();
           if ((null != dirStr) && (dirStr.length() > 0)) {
              File dir = new File(dirStr);
              dir.mkdirs();
           }

    factory.setEncoding(_encoding);
    factory.setOutputMethod(_method);
    factory.setWriter(new FileWriter(filename, append));
    factory.setOutputType(TransletOutputHandlerFactory.STREAM);

    final SerializationHandler handler 
	= factory.getSerializationHandler();

    transferOutputSettings(handler);
    handler.startDocument();
    return handler;
}
catch (Exception e) {
    throw new TransletException(e);
}
   }
 
开发者ID:apache,项目名称:servicemix-bundles,代码行数:35,代码来源:AbstractTranslet.java


示例13: closeOutputHandler

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
public void closeOutputHandler(SerializationHandler handler) {
try {
    handler.endDocument();
    handler.close();
}
catch (Exception e) {
    // what can you do?
}
   }
 
开发者ID:apache,项目名称:servicemix-bundles,代码行数:10,代码来源:AbstractTranslet.java


示例14: transform

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
    * Calls transform() with a given output handler
    */
   public final void transform(DOM document, SerializationHandler handler) 
throws TransletException {
       try {
           transform(document, document.getIterator(), handler);
       } finally {
           _keyIndexes = null;
       }
   }
 
开发者ID:apache,项目名称:servicemix-bundles,代码行数:12,代码来源:AbstractTranslet.java


示例15: characters

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
    * Used by some compiled code as a shortcut for passing strings to the
    * output handler
    */
   public final void characters(final String string,
			 SerializationHandler handler) 
throws TransletException {
       if (string != null) {
          //final int length = string.length();
          try {
              handler.characters(string);
          } catch (Exception e) {
              throw new TransletException(e);
          }
       }   
   }
 
开发者ID:apache,项目名称:servicemix-bundles,代码行数:17,代码来源:AbstractTranslet.java


示例16: addAttribute

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
 * Copy an DOM attribute to the created output element, executing
 * attribute templates as need be, and processing the xsl:use
 * attribute.
 *
 * @param handler SerializationHandler to which the attributes are added.
 * @param attr Attribute node to add to SerializationHandler.
 *
 * @throws TransformerException
 */
public static void addAttribute(SerializationHandler handler, int attr)
    throws TransformerException
{

    TransformerImpl transformer =
        (TransformerImpl) handler.getTransformer();
    DTM dtm = transformer.getXPathContext().getDTM(attr);

    if (SerializerUtils.isDefinedNSDecl(handler, attr, dtm))
        return;

    String ns = dtm.getNamespaceURI(attr);

    if (ns == null)
        ns = "";

    // %OPT% ...can I just store the node handle?
    try
    {
        handler.addAttribute(
            ns,
            dtm.getLocalName(attr),
            dtm.getNodeName(attr),
            "CDATA",
            dtm.getNodeValue(attr), false);
    }
    catch (SAXException e)
    {
        // do something?
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:42,代码来源:SerializerUtils.java


示例17: outputResultTreeFragment

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
 * Given a result tree fragment, walk the tree and
 * output it to the SerializationHandler.
 *
 * @param obj Result tree fragment object
 * @param support XPath context for the result tree fragment
 *
 * @throws org.xml.sax.SAXException
 */
public static void outputResultTreeFragment(
    SerializationHandler handler,
    XObject obj,
    XPathContext support)
    throws org.xml.sax.SAXException
{

    int doc = obj.rtf();
    DTM dtm = support.getDTM(doc);

    if (null != dtm)
    {
        for (int n = dtm.getFirstChild(doc);
            DTM.NULL != n;
            n = dtm.getNextSibling(n))
        {
            handler.flushPending();

            // I think. . . . This used to have a (true) arg
            // to flush prefixes, will that cause problems ???
            if (dtm.getNodeType(n) == DTM.ELEMENT_NODE
                    && dtm.getNamespaceURI(n) == null)
                handler.startPrefixMapping("", "");
            dtm.dispatchToEvents(n, handler);
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:37,代码来源:SerializerUtils.java


示例18: constructNode

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
 * Construct a node in the result tree.  This method is overloaded by 
 * xsl:attribute. At this class level, this method creates an element.
 *
 * @param nodeName The name of the node, which may be null.
 * @param prefix The prefix for the namespace, which may be null.
 * @param nodeNamespace The namespace of the node, which may be null.
 * @param transformer non-null reference to the the current transform-time state.
 * @param sourceNode non-null reference to the <a href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
 * @param mode reference, which may be null, to the <a href="http://www.w3.org/TR/xslt#modes">current mode</a>.
 *
 * @throws TransformerException
 */
void constructNode(
        String nodeName, String prefix, String nodeNamespace, TransformerImpl transformer)
          throws TransformerException
{

  if(null != nodeName && nodeName.length() > 0)
  {
    SerializationHandler rhandler = transformer.getSerializationHandler();

    // Evaluate the value of this attribute
    String val = transformer.transformToString(this);
    try 
    {
      // Let the result tree handler add the attribute and its String value.
      String localName = QName.getLocalPart(nodeName);
      if(prefix != null && prefix.length() > 0){
          rhandler.addAttribute(nodeNamespace, localName, nodeName, "CDATA", val, true);
      }else{
          rhandler.addAttribute("", localName, nodeName, "CDATA", val, true);
      }
    }
    catch (SAXException e)
    {
    }
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:40,代码来源:ElemAttribute.java


示例19: unexecuteNSDecls

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
 * Send endPrefixMapping events to the result tree handler
 * for all declared prefix mappings in the stylesheet.
 *
 * @param transformer non-null reference to the the current transform-time state.
 * @param ignorePrefix string prefix to not endPrefixMapping
 * 
 * @throws TransformerException
 */
void unexecuteNSDecls(TransformerImpl transformer, String ignorePrefix) throws TransformerException
{
 
  try
  {
    if (null != m_prefixTable)
    {
      SerializationHandler rhandler = transformer.getResultTreeHandler();
      int n = m_prefixTable.size();

      for (int i = 0; i < n; i++)
      {
        XMLNSDecl decl = (XMLNSDecl) m_prefixTable.get(i);

        if (!decl.getIsExcluded() && !(null != ignorePrefix && decl.getPrefix().equals(ignorePrefix)))
        {
          rhandler.endPrefixMapping(decl.getPrefix());
        }
      }
    }
  }
  catch(org.xml.sax.SAXException se)
  {
    throw new TransformerException(se);
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:36,代码来源:ElemTemplateElement.java


示例20: transform

import org.apache.xml.serializer.SerializationHandler; //导入依赖的package包/类
/**
 * Process the source tree to the output result.
 * @param xmlSource  The input for the source tree.
 * @param outputTarget The output source target.
 * @param shouldRelease  Flag indicating whether to release DTMManager. 
 *
 * @throws TransformerException
 */
public void transform(Source xmlSource, Result outputTarget, boolean shouldRelease)
        throws TransformerException
{

  synchronized (m_reentryGuard)
  {
    SerializationHandler xoh = createSerializationHandler(outputTarget);
    this.setSerializationHandler(xoh);        

    m_outputTarget = outputTarget;

    transform(xmlSource, shouldRelease);
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:23,代码来源:TransformerImpl.java



注:本文中的org.apache.xml.serializer.SerializationHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PerfCounterInfo类代码示例发布时间:2022-05-22
下一篇:
Java EFormatString类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap