下面列出了org.w3c.dom.traversal.NodeFilter#SHOW_CDATA_SECTION 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Given a {@link Node}, return the appropriate constant for whatToShow.
*
* @param node the node
* @return the whatToShow constant for the type of specified node
*/
static int getFlagForNode(final Node node) {
switch (node.getNodeType()) {
case Node.ELEMENT_NODE:
return NodeFilter.SHOW_ELEMENT;
case Node.ATTRIBUTE_NODE:
return NodeFilter.SHOW_ATTRIBUTE;
case Node.TEXT_NODE:
return NodeFilter.SHOW_TEXT;
case Node.CDATA_SECTION_NODE:
return NodeFilter.SHOW_CDATA_SECTION;
case Node.ENTITY_REFERENCE_NODE:
return NodeFilter.SHOW_ENTITY_REFERENCE;
case Node.ENTITY_NODE:
return NodeFilter.SHOW_ENTITY;
case Node.PROCESSING_INSTRUCTION_NODE:
return NodeFilter.SHOW_PROCESSING_INSTRUCTION;
case Node.COMMENT_NODE:
return NodeFilter.SHOW_COMMENT;
case Node.DOCUMENT_NODE:
return NodeFilter.SHOW_DOCUMENT;
case Node.DOCUMENT_TYPE_NODE:
return NodeFilter.SHOW_DOCUMENT_TYPE;
case Node.DOCUMENT_FRAGMENT_NODE:
return NodeFilter.SHOW_DOCUMENT_FRAGMENT;
case Node.NOTATION_NODE:
return NodeFilter.SHOW_NOTATION;
default:
return 0;
}
}
/**
* Given a {@link Node}, return the appropriate constant for whatToShow.
*
* @param node the node
* @return the whatToShow constant for the type of specified node
*/
static int getFlagForNode(final Node node) {
switch (node.getNodeType()) {
case Node.ELEMENT_NODE:
return NodeFilter.SHOW_ELEMENT;
case Node.ATTRIBUTE_NODE:
return NodeFilter.SHOW_ATTRIBUTE;
case Node.TEXT_NODE:
return NodeFilter.SHOW_TEXT;
case Node.CDATA_SECTION_NODE:
return NodeFilter.SHOW_CDATA_SECTION;
case Node.ENTITY_REFERENCE_NODE:
return NodeFilter.SHOW_ENTITY_REFERENCE;
case Node.ENTITY_NODE:
return NodeFilter.SHOW_ENTITY;
case Node.PROCESSING_INSTRUCTION_NODE:
return NodeFilter.SHOW_PROCESSING_INSTRUCTION;
case Node.COMMENT_NODE:
return NodeFilter.SHOW_COMMENT;
case Node.DOCUMENT_NODE:
return NodeFilter.SHOW_DOCUMENT;
case Node.DOCUMENT_TYPE_NODE:
return NodeFilter.SHOW_DOCUMENT_TYPE;
case Node.DOCUMENT_FRAGMENT_NODE:
return NodeFilter.SHOW_DOCUMENT_FRAGMENT;
case Node.NOTATION_NODE:
return NodeFilter.SHOW_NOTATION;
default:
return 0;
}
}
/**
* The end of a CDATA section.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void endCDATA (Augmentations augs) throws XNIException {
fInCDATASection = false;
if (!fDeferNodeExpansion) {
if (fFilterReject) {
return;
}
if (fCurrentCDATASection !=null) {
if (fDOMFilter !=null && !fInEntityRef &&
(fDOMFilter.getWhatToShow () & NodeFilter.SHOW_CDATA_SECTION)!= 0) {
short code = fDOMFilter.acceptNode (fCurrentCDATASection);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since CDATA section has no children.
}
case LSParserFilter.FILTER_SKIP: {
Node parent = fCurrentNode.getParentNode ();
parent.removeChild (fCurrentCDATASection);
fCurrentNode = parent;
return;
}
default: {
// accept node
}
}
}
fCurrentNode = fCurrentNode.getParentNode ();
fCurrentCDATASection = null;
}
}
else {
if (fCurrentCDATASectionIndex !=-1) {
fCurrentNodeIndex =
fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
fCurrentCDATASectionIndex = -1;
}
}
}
/**
* The end of a CDATA section.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void endCDATA (Augmentations augs) throws XNIException {
fInCDATASection = false;
if (!fDeferNodeExpansion) {
if (fFilterReject) {
return;
}
if (fCurrentCDATASection !=null) {
if (fDOMFilter !=null && !fInEntityRef &&
(fDOMFilter.getWhatToShow () & NodeFilter.SHOW_CDATA_SECTION)!= 0) {
short code = fDOMFilter.acceptNode (fCurrentCDATASection);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since CDATA section has no children.
}
case LSParserFilter.FILTER_SKIP: {
Node parent = fCurrentNode.getParentNode ();
parent.removeChild (fCurrentCDATASection);
fCurrentNode = parent;
return;
}
default: {
// accept node
}
}
}
fCurrentNode = fCurrentNode.getParentNode ();
fCurrentCDATASection = null;
}
}
else {
if (fCurrentCDATASectionIndex !=-1) {
fCurrentNodeIndex =
fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
fCurrentCDATASectionIndex = -1;
}
}
}
/**
* The end of a CDATA section.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void endCDATA (Augmentations augs) throws XNIException {
fInCDATASection = false;
if (!fDeferNodeExpansion) {
if (fFilterReject) {
return;
}
if (fCurrentCDATASection !=null) {
if (fDOMFilter !=null && !fInEntityRef &&
(fDOMFilter.getWhatToShow () & NodeFilter.SHOW_CDATA_SECTION)!= 0) {
short code = fDOMFilter.acceptNode (fCurrentCDATASection);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since CDATA section has no children.
}
case LSParserFilter.FILTER_SKIP: {
Node parent = fCurrentNode.getParentNode ();
parent.removeChild (fCurrentCDATASection);
fCurrentNode = parent;
return;
}
default: {
// accept node
}
}
}
fCurrentNode = fCurrentNode.getParentNode ();
fCurrentCDATASection = null;
}
}
else {
if (fCurrentCDATASectionIndex !=-1) {
fCurrentNodeIndex =
fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
fCurrentCDATASectionIndex = -1;
}
}
}
/**
* The end of a CDATA section.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void endCDATA (Augmentations augs) throws XNIException {
fInCDATASection = false;
if (!fDeferNodeExpansion) {
if (fFilterReject) {
return;
}
if (fCurrentCDATASection !=null) {
if (fDOMFilter !=null && !fInEntityRef &&
(fDOMFilter.getWhatToShow () & NodeFilter.SHOW_CDATA_SECTION)!= 0) {
short code = fDOMFilter.acceptNode (fCurrentCDATASection);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since CDATA section has no children.
}
case LSParserFilter.FILTER_SKIP: {
Node parent = fCurrentNode.getParentNode ();
parent.removeChild (fCurrentCDATASection);
fCurrentNode = parent;
return;
}
default: {
// accept node
}
}
}
fCurrentNode = fCurrentNode.getParentNode ();
fCurrentCDATASection = null;
}
}
else {
if (fCurrentCDATASectionIndex !=-1) {
fCurrentNodeIndex =
fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
fCurrentCDATASectionIndex = -1;
}
}
}
/**
* The end of a CDATA section.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void endCDATA (Augmentations augs) throws XNIException {
fInCDATASection = false;
if (!fDeferNodeExpansion) {
if (fFilterReject) {
return;
}
if (fCurrentCDATASection !=null) {
if (fDOMFilter !=null && !fInEntityRef &&
(fDOMFilter.getWhatToShow () & NodeFilter.SHOW_CDATA_SECTION)!= 0) {
short code = fDOMFilter.acceptNode (fCurrentCDATASection);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since CDATA section has no children.
}
case LSParserFilter.FILTER_SKIP: {
Node parent = fCurrentNode.getParentNode ();
parent.removeChild (fCurrentCDATASection);
fCurrentNode = parent;
return;
}
default: {
// accept node
}
}
}
fCurrentNode = fCurrentNode.getParentNode ();
fCurrentCDATASection = null;
}
}
else {
if (fCurrentCDATASectionIndex !=-1) {
fCurrentNodeIndex =
fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
fCurrentCDATASectionIndex = -1;
}
}
}
/**
* The end of a CDATA section.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void endCDATA (Augmentations augs) throws XNIException {
fInCDATASection = false;
if (!fDeferNodeExpansion) {
if (fFilterReject) {
return;
}
if (fCurrentCDATASection !=null) {
if (fDOMFilter !=null && !fInEntityRef &&
(fDOMFilter.getWhatToShow () & NodeFilter.SHOW_CDATA_SECTION)!= 0) {
short code = fDOMFilter.acceptNode (fCurrentCDATASection);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since CDATA section has no children.
}
case LSParserFilter.FILTER_SKIP: {
Node parent = fCurrentNode.getParentNode ();
parent.removeChild (fCurrentCDATASection);
fCurrentNode = parent;
return;
}
default: {
// accept node
}
}
}
fCurrentNode = fCurrentNode.getParentNode ();
fCurrentCDATASection = null;
}
}
else {
if (fCurrentCDATASectionIndex !=-1) {
fCurrentNodeIndex =
fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
fCurrentCDATASectionIndex = -1;
}
}
}
/**
* The end of a CDATA section.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
@SuppressWarnings("fallthrough") // by design at case LSParserFilter.FILTER_REJECT
public void endCDATA (Augmentations augs) throws XNIException {
fInCDATASection = false;
if (!fDeferNodeExpansion) {
if (fFilterReject) {
return;
}
if (fCurrentCDATASection !=null) {
if (fDOMFilter !=null && !fInEntityRef &&
(fDOMFilter.getWhatToShow () & NodeFilter.SHOW_CDATA_SECTION)!= 0) {
short code = fDOMFilter.acceptNode (fCurrentCDATASection);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since CDATA section has no children.
}
case LSParserFilter.FILTER_SKIP: {
Node parent = fCurrentNode.getParentNode ();
parent.removeChild (fCurrentCDATASection);
fCurrentNode = parent;
return;
}
default: {
// accept node
}
}
}
fCurrentNode = fCurrentNode.getParentNode ();
fCurrentCDATASection = null;
}
}
else {
if (fCurrentCDATASectionIndex !=-1) {
fCurrentNodeIndex =
fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
fCurrentCDATASectionIndex = -1;
}
}
}
/**
* The end of a CDATA section.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void endCDATA (Augmentations augs) throws XNIException {
fInCDATASection = false;
if (!fDeferNodeExpansion) {
if (fFilterReject) {
return;
}
if (fCurrentCDATASection !=null) {
if (fDOMFilter !=null && !fInEntityRef &&
(fDOMFilter.getWhatToShow () & NodeFilter.SHOW_CDATA_SECTION)!= 0) {
short code = fDOMFilter.acceptNode (fCurrentCDATASection);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since CDATA section has no children.
}
case LSParserFilter.FILTER_SKIP: {
Node parent = fCurrentNode.getParentNode ();
parent.removeChild (fCurrentCDATASection);
fCurrentNode = parent;
return;
}
default: {
// accept node
}
}
}
fCurrentNode = fCurrentNode.getParentNode ();
fCurrentCDATASection = null;
}
}
else {
if (fCurrentCDATASectionIndex !=-1) {
fCurrentNodeIndex =
fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
fCurrentCDATASectionIndex = -1;
}
}
}
/**
* The end of a CDATA section.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void endCDATA (Augmentations augs) throws XNIException {
fInCDATASection = false;
if (!fDeferNodeExpansion) {
if (fFilterReject) {
return;
}
if (fCurrentCDATASection !=null) {
if (fDOMFilter !=null && !fInEntityRef &&
(fDOMFilter.getWhatToShow () & NodeFilter.SHOW_CDATA_SECTION)!= 0) {
short code = fDOMFilter.acceptNode (fCurrentCDATASection);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since CDATA section has no children.
}
case LSParserFilter.FILTER_SKIP: {
Node parent = fCurrentNode.getParentNode ();
parent.removeChild (fCurrentCDATASection);
fCurrentNode = parent;
return;
}
default: {
// accept node
}
}
}
fCurrentNode = fCurrentNode.getParentNode ();
fCurrentCDATASection = null;
}
}
else {
if (fCurrentCDATASectionIndex !=-1) {
fCurrentNodeIndex =
fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
fCurrentCDATASectionIndex = -1;
}
}
}
/**
* The end of a CDATA section.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void endCDATA (Augmentations augs) throws XNIException {
fInCDATASection = false;
if (!fDeferNodeExpansion) {
if (fFilterReject) {
return;
}
if (fCurrentCDATASection !=null) {
if (fDOMFilter !=null && !fInEntityRef &&
(fDOMFilter.getWhatToShow () & NodeFilter.SHOW_CDATA_SECTION)!= 0) {
short code = fDOMFilter.acceptNode (fCurrentCDATASection);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since CDATA section has no children.
}
case LSParserFilter.FILTER_SKIP: {
Node parent = fCurrentNode.getParentNode ();
parent.removeChild (fCurrentCDATASection);
fCurrentNode = parent;
return;
}
default: {
// accept node
}
}
}
fCurrentNode = fCurrentNode.getParentNode ();
fCurrentCDATASection = null;
}
}
else {
if (fCurrentCDATASectionIndex !=-1) {
fCurrentNodeIndex =
fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
fCurrentCDATASectionIndex = -1;
}
}
}
/**
* The end of a CDATA section.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void endCDATA (Augmentations augs) throws XNIException {
fInCDATASection = false;
if (!fDeferNodeExpansion) {
if (fFilterReject) {
return;
}
if (fCurrentCDATASection !=null) {
if (fDOMFilter !=null && !fInEntityRef &&
(fDOMFilter.getWhatToShow () & NodeFilter.SHOW_CDATA_SECTION)!= 0) {
short code = fDOMFilter.acceptNode (fCurrentCDATASection);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since CDATA section has no children.
}
case LSParserFilter.FILTER_SKIP: {
Node parent = fCurrentNode.getParentNode ();
parent.removeChild (fCurrentCDATASection);
fCurrentNode = parent;
return;
}
default: {
// accept node
}
}
}
fCurrentNode = fCurrentNode.getParentNode ();
fCurrentCDATASection = null;
}
}
else {
if (fCurrentCDATASectionIndex !=-1) {
fCurrentNodeIndex =
fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
fCurrentCDATASectionIndex = -1;
}
}
}