本文整理汇总了Java中com.sun.org.apache.xml.internal.serializer.SerializationHandler.setEscaping方法的典型用法代码示例。如果您正苦于以下问题:Java SerializationHandler.setEscaping方法的具体用法?Java SerializationHandler.setEscaping怎么用?Java SerializationHandler.setEscaping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xml.internal.serializer.SerializationHandler
的用法示例。
在下文中一共展示了SerializationHandler.setEscaping方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: characters
import com.sun.org.apache.xml.internal.serializer.SerializationHandler; //导入方法依赖的package包/类
/**
* Dispatch the character content of a node to an output handler.
*
* The escape setting should be taken care of when outputting to
* a handler.
*/
public void characters(final int node, SerializationHandler handler)
throws TransletException
{
int nodeID = getNodeIdent(node);
if (nodeID == RTF_ROOT || nodeID == RTF_TEXT) {
boolean escapeBit = false;
boolean oldEscapeSetting = false;
try {
for (int i = 0; i < _size; i++) {
if (_dontEscape != null) {
escapeBit = _dontEscape.getBit(i);
if (escapeBit) {
oldEscapeSetting = handler.setEscaping(false);
}
}
handler.characters(_textArray[i]);
if (escapeBit) {
handler.setEscaping(oldEscapeSetting);
}
}
} catch (SAXException e) {
throw new TransletException(e);
}
}
}
示例2: copy
import com.sun.org.apache.xml.internal.serializer.SerializationHandler; //导入方法依赖的package包/类
private final void copy(final int node, SerializationHandler handler, boolean isChild)
throws TransletException
{
int nodeID = makeNodeIdentity(node);
int eType = _exptype2(nodeID);
int type = _exptype2Type(eType);
try {
switch(type)
{
case DTM.ROOT_NODE:
case DTM.DOCUMENT_NODE:
for(int c = _firstch2(nodeID); c != DTM.NULL; c = _nextsib2(c)) {
copy(makeNodeHandle(c), handler, true);
}
break;
case DTM.PROCESSING_INSTRUCTION_NODE:
copyPI(node, handler);
break;
case DTM.COMMENT_NODE:
handler.comment(getStringValueX(node));
break;
case DTM.TEXT_NODE:
boolean oldEscapeSetting = false;
boolean escapeBit = false;
if (_dontEscape != null) {
escapeBit = _dontEscape.getBit(getNodeIdent(node));
if (escapeBit) {
oldEscapeSetting = handler.setEscaping(false);
}
}
copyTextNode(nodeID, handler);
if (escapeBit) {
handler.setEscaping(oldEscapeSetting);
}
break;
case DTM.ATTRIBUTE_NODE:
copyAttribute(nodeID, eType, handler);
break;
case DTM.NAMESPACE_NODE:
handler.namespaceAfterStartElement(getNodeNameX(node), getNodeValue(node));
break;
default:
if (type == DTM.ELEMENT_NODE)
{
// Start element definition
final String name = copyElement(nodeID, eType, handler);
//if(isChild) => not to copy any namespaces from parents
// else copy all namespaces in scope
copyNS(nodeID, handler,!isChild);
copyAttributes(nodeID, handler);
// Copy element children
for (int c = _firstch2(nodeID); c != DTM.NULL; c = _nextsib2(c)) {
copy(makeNodeHandle(c), handler, true);
}
// Close element definition
handler.endElement(name);
}
// Shallow copy of attribute to output handler
else {
final String uri = getNamespaceName(node);
if (uri.length() != 0) {
final String prefix = getPrefix(node);
handler.namespaceAfterStartElement(prefix, uri);
}
handler.addAttribute(getNodeName(node), getNodeValue(node));
}
break;
}
}
catch (Exception e) {
throw new TransletException(e);
}
}