本文整理汇总了Java中com.sun.org.apache.xml.internal.dtm.DTM.TEXT_NODE属性的典型用法代码示例。如果您正苦于以下问题:Java DTM.TEXT_NODE属性的具体用法?Java DTM.TEXT_NODE怎么用?Java DTM.TEXT_NODE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sun.org.apache.xml.internal.dtm.DTM
的用法示例。
在下文中一共展示了DTM.TEXT_NODE属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleTextEscaping
/**
* Creates a text-node and checks if it is a whitespace node.
*/
private void handleTextEscaping() {
if (_disableEscaping && _textNodeToProcess != DTM.NULL
&& _type(_textNodeToProcess) == DTM.TEXT_NODE) {
if (_dontEscape == null) {
_dontEscape = new BitArray(_size);
}
// Resize the _dontEscape BitArray if necessary.
if (_textNodeToProcess >= _dontEscape.size()) {
_dontEscape.resize(_dontEscape.size() * 2);
}
_dontEscape.setBit(_textNodeToProcess);
_disableEscaping = false;
}
_textNodeToProcess = DTM.NULL;
}
示例2: getNodeName
/**
* Returns the name of a node (attribute or element).
*/
public String getNodeName(final int node)
{
// Get the node type and make sure that it is within limits
int nodeh = node;
final short type = getNodeType(nodeh);
switch(type)
{
case DTM.ROOT_NODE:
case DTM.DOCUMENT_NODE:
case DTM.TEXT_NODE:
case DTM.COMMENT_NODE:
return EMPTYSTRING;
case DTM.NAMESPACE_NODE:
return this.getLocalName(nodeh);
default:
return super.getNodeName(nodeh);
}
}
示例3: characters
/**
* 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 SAXException Any SAX exception, possibly
* wrapping another exception.
* @see ContentHandler#characters
*/
public void characters(char ch[], int start, int length) throws SAXException
{
if (m_textPendingStart == -1) // First one in this block
{
m_textPendingStart = m_chars.size();
m_coalescedTextType = m_textType;
}
// Type logic: If all adjacent text is CDATASections, the
// concatentated text is treated as a single CDATASection (see
// initialization above). If any were ordinary Text, the whole
// thing is treated as Text. This may be worth %REVIEW%ing.
else if (m_textType == DTM.TEXT_NODE)
{
m_coalescedTextType = DTM.TEXT_NODE;
}
m_chars.append(ch, start, length);
}
示例4: next
public int next()
{
if (_currentNode == END)
return END;
_currentNode = END;
if (_type != NO_TYPE) {
if ((_currentNode == RTF_ROOT && _type == DTM.ROOT_NODE)
|| (_currentNode == RTF_TEXT && _type == DTM.TEXT_NODE))
return getNodeHandle(_currentNode);
}
else
return getNodeHandle(_currentNode);
return END;
}
示例5: getStringValue
/**
* Returns the string value of the entire tree
*/
public String getStringValue()
{
int child = _firstch2(ROOTNODE);
if (child == DTM.NULL) return EMPTY_STR;
// optimization: only create StringBuffer if > 1 child
if ((_exptype2(child) == DTM.TEXT_NODE) && (_nextsib2(child) == DTM.NULL))
{
int dataIndex = m_dataOrQName.elementAt(child);
if (dataIndex >= 0)
return m_chars.getString(dataIndex >>> TEXT_LENGTH_BITS, dataIndex & TEXT_LENGTH_MAX);
else
return m_chars.getString(m_data.elementAt(-dataIndex),
m_data.elementAt(-dataIndex + 1));
}
else
return getStringValueX(getDocument());
}
示例6: print
/**
* Prints the whole tree to standard output
*/
public void print(int node, int level)
{
switch(getNodeType(node))
{
case DTM.ROOT_NODE:
case DTM.DOCUMENT_NODE:
print(getFirstChild(node), level);
break;
case DTM.TEXT_NODE:
case DTM.COMMENT_NODE:
case DTM.PROCESSING_INSTRUCTION_NODE:
System.out.print(getStringValueX(node));
break;
default:
final String name = getNodeName(node);
System.out.print("<" + name);
for (int a = getFirstAttribute(node); a != DTM.NULL; a = getNextAttribute(a))
{
System.out.print("\n" + getNodeName(a) + "=\"" + getStringValueX(a) + "\"");
}
System.out.print('>');
for (int child = getFirstChild(node); child != DTM.NULL;
child = getNextSibling(child)) {
print(child, level + 1);
}
System.out.println("</" + name + '>');
break;
}
}
示例7: getExpandedTypeID
public int getExpandedTypeID(final int nodeHandle)
{
int nodeID = getNodeIdent(nodeHandle);
if (nodeID == RTF_TEXT)
return DTM.TEXT_NODE;
else if (nodeID == RTF_ROOT)
return DTM.ROOT_NODE;
else
return DTM.NULL;
}
示例8: charactersFlush
/**
* Check whether accumulated text should be stripped; if not,
* append the appropriate flavor of text/cdata node.
*/
protected void charactersFlush()
{
if (m_textPendingStart >= 0) // -1 indicates no-text-in-progress
{
int length = m_chars.size() - m_textPendingStart;
boolean doStrip = false;
if (getShouldStripWhitespace())
{
doStrip = m_chars.isWhitespace(m_textPendingStart, length);
}
if (doStrip) {
m_chars.setLength(m_textPendingStart); // Discard accumulated text
} else {
// Guard against characters/ignorableWhitespace events that
// contained no characters. They should not result in a node.
if (length > 0) {
int exName = m_expandedNameTable.getExpandedTypeID(DTM.TEXT_NODE);
int dataIndex = m_data.size();
m_previous = addNode(m_coalescedTextType, exName,
m_parents.peek(), m_previous, dataIndex, false);
m_data.addElement(m_textPendingStart);
m_data.addElement(length);
}
}
// Reset for next text block
m_textPendingStart = -1;
m_textType = m_coalescedTextType = DTM.TEXT_NODE;
}
}
示例9: getNodeType
public short getNodeType(int nodeHandle)
{
int nodeID = getNodeIdent(nodeHandle);
if (nodeID == RTF_TEXT)
return DTM.TEXT_NODE;
else if (nodeID == RTF_ROOT)
return DTM.ROOT_NODE;
else
return DTM.NULL;
}
示例10: copy
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);
}
}
示例11: getNodeTypeTest
/**
* Tell what node type to test, if not DTMFilter.SHOW_ALL.
*
* @param whatToShow Bit set defined mainly by
* {@link com.sun.org.apache.xml.internal.dtm.DTMFilter}.
* @return the node type for the whatToShow. Since whatToShow can specify
* multiple types, it will return the first bit tested that is on,
* so the caller of this function should take care that this is
* the function they really want to call. If none of the known bits
* are set, this function will return zero.
*/
public static int getNodeTypeTest(int whatToShow)
{
// %REVIEW% Is there a better way?
if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT))
return DTM.ELEMENT_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE))
return DTM.ATTRIBUTE_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_TEXT))
return DTM.TEXT_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT))
return DTM.DOCUMENT_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT))
return DTM.DOCUMENT_FRAGMENT_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE))
return DTM.NAMESPACE_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_COMMENT))
return DTM.COMMENT_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION))
return DTM.PROCESSING_INSTRUCTION_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE))
return DTM.DOCUMENT_TYPE_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_ENTITY))
return DTM.ENTITY_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE))
return DTM.ENTITY_REFERENCE_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_NOTATION))
return DTM.NOTATION_NODE;
if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION))
return DTM.CDATA_SECTION_NODE;
return 0;
}
示例12: charactersFlush
/**
* Check whether accumulated text should be stripped; if not,
* append the appropriate flavor of text/cdata node.
*/
protected final void charactersFlush() {
if (m_textPendingStart >= 0) { // -1 indicates no-text-in-progress
int length = m_chars.size() - m_textPendingStart;
boolean doStrip = false;
if (getShouldStripWhitespace()) {
doStrip = m_chars.isWhitespace(m_textPendingStart, length);
}
if (doStrip) {
m_chars.setLength(m_textPendingStart); // Discard accumulated text
} else {
// Guard against characters/ignorableWhitespace events that
// contained no characters. They should not result in a node.
if (length > 0) {
// If the offset and length do not exceed the given limits
// (offset < 2^21 and length < 2^10), then save both the offset
// and length in a bitwise encoded value.
if (length <= TEXT_LENGTH_MAX &&
m_textPendingStart <= TEXT_OFFSET_MAX) {
m_previous = addNode(m_coalescedTextType, DTM.TEXT_NODE,
m_parents.peek(), m_previous,
length + (m_textPendingStart << TEXT_LENGTH_BITS),
false);
} else {
// Store offset and length in the m_data array if one exceeds
// the given limits. Use a negative dataIndex as an indication.
int dataIndex = m_data.size();
m_previous = addNode(m_coalescedTextType, DTM.TEXT_NODE,
m_parents.peek(), m_previous, -dataIndex, false);
m_data.addElement(m_textPendingStart);
m_data.addElement(length);
}
}
}
// Reset for next text block
m_textPendingStart = -1;
m_textType = m_coalescedTextType = DTM.TEXT_NODE;
}
}
示例13: shallowCopy
/**
* Performs a shallow copy (ref. XSLs copy())
*/
public String shallowCopy(final int node, SerializationHandler handler)
throws TransletException
{
int nodeID = makeNodeIdentity(node);
int exptype = _exptype2(nodeID);
int type = _exptype2Type(exptype);
try {
switch(type)
{
case DTM.ELEMENT_NODE:
final String name = copyElement(nodeID, exptype, handler);
copyNS(nodeID, handler, true);
return name;
case DTM.ROOT_NODE:
case DTM.DOCUMENT_NODE:
return EMPTYSTRING;
case DTM.TEXT_NODE:
copyTextNode(nodeID, handler);
return null;
case DTM.PROCESSING_INSTRUCTION_NODE:
copyPI(node, handler);
return null;
case DTM.COMMENT_NODE:
handler.comment(getStringValueX(node));
return null;
case DTM.NAMESPACE_NODE:
handler.namespaceAfterStartElement(getNodeNameX(node), getNodeValue(node));
return null;
case DTM.ATTRIBUTE_NODE:
copyAttribute(nodeID, exptype, handler);
return null;
default:
final String uri1 = getNamespaceName(node);
if (uri1.length() != 0) {
final String prefix = getPrefix(node);
handler.namespaceAfterStartElement(prefix, uri1);
}
handler.addAttribute(getNodeName(node), getNodeValue(node));
return null;
}
} catch (Exception e) {
throw new TransletException(e);
}
}
示例14: isTextType
/**
* Bottleneck determination of text type.
*
* @param type oneof DTM.XXX_NODE.
*
* @return true if this is a text or cdata section.
*/
private final boolean isTextType(int type)
{
return (DTM.TEXT_NODE == type || DTM.CDATA_SECTION_NODE == type);
}