1 /*
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3 * @LastModified: Oct 2017
4 */
5 /*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements. See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 package com.sun.org.apache.xerces.internal.jaxp.validation;
23
49 import java.util.ArrayList;
50 import java.util.List;
51 import javax.xml.transform.dom.DOMResult;
52 import org.w3c.dom.CDATASection;
53 import org.w3c.dom.Comment;
54 import org.w3c.dom.Document;
55 import org.w3c.dom.DocumentType;
56 import org.w3c.dom.Element;
57 import org.w3c.dom.Entity;
58 import org.w3c.dom.NamedNodeMap;
59 import org.w3c.dom.Node;
60 import org.w3c.dom.Notation;
61 import org.w3c.dom.ProcessingInstruction;
62 import org.w3c.dom.Text;
63
64
65 /**
66 * <p>DOM result builder.</p>
67 *
68 * @author Michael Glavassevich, IBM
69 */
70 final class DOMResultBuilder implements DOMDocumentHandler {
71
72 /** Table for quick check of child insertion. */
73 private final static int[] kidOK;
74
75 static {
76 kidOK = new int[13];
77 kidOK[Node.DOCUMENT_NODE] =
78 1 << Node.ELEMENT_NODE | 1 << Node.PROCESSING_INSTRUCTION_NODE |
79 1 << Node.COMMENT_NODE | 1 << Node.DOCUMENT_TYPE_NODE;
80 kidOK[Node.DOCUMENT_FRAGMENT_NODE] =
81 kidOK[Node.ENTITY_NODE] =
82 kidOK[Node.ENTITY_REFERENCE_NODE] =
83 kidOK[Node.ELEMENT_NODE] =
84 1 << Node.ELEMENT_NODE | 1 << Node.PROCESSING_INSTRUCTION_NODE |
85 1 << Node.COMMENT_NODE | 1 << Node.TEXT_NODE |
86 1 << Node.CDATA_SECTION_NODE | 1 << Node.ENTITY_REFERENCE_NODE ;
87 kidOK[Node.ATTRIBUTE_NODE] = 1 << Node.TEXT_NODE | 1 << Node.ENTITY_REFERENCE_NODE;
88 kidOK[Node.DOCUMENT_TYPE_NODE] = 0;
|
1 /*
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements. See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21 package com.sun.org.apache.xerces.internal.jaxp.validation;
22
48 import java.util.ArrayList;
49 import java.util.List;
50 import javax.xml.transform.dom.DOMResult;
51 import org.w3c.dom.CDATASection;
52 import org.w3c.dom.Comment;
53 import org.w3c.dom.Document;
54 import org.w3c.dom.DocumentType;
55 import org.w3c.dom.Element;
56 import org.w3c.dom.Entity;
57 import org.w3c.dom.NamedNodeMap;
58 import org.w3c.dom.Node;
59 import org.w3c.dom.Notation;
60 import org.w3c.dom.ProcessingInstruction;
61 import org.w3c.dom.Text;
62
63
64 /**
65 * <p>DOM result builder.</p>
66 *
67 * @author Michael Glavassevich, IBM
68 * @LastModified: Oct 2017
69 */
70 final class DOMResultBuilder implements DOMDocumentHandler {
71
72 /** Table for quick check of child insertion. */
73 private final static int[] kidOK;
74
75 static {
76 kidOK = new int[13];
77 kidOK[Node.DOCUMENT_NODE] =
78 1 << Node.ELEMENT_NODE | 1 << Node.PROCESSING_INSTRUCTION_NODE |
79 1 << Node.COMMENT_NODE | 1 << Node.DOCUMENT_TYPE_NODE;
80 kidOK[Node.DOCUMENT_FRAGMENT_NODE] =
81 kidOK[Node.ENTITY_NODE] =
82 kidOK[Node.ENTITY_REFERENCE_NODE] =
83 kidOK[Node.ELEMENT_NODE] =
84 1 << Node.ELEMENT_NODE | 1 << Node.PROCESSING_INSTRUCTION_NODE |
85 1 << Node.COMMENT_NODE | 1 << Node.TEXT_NODE |
86 1 << Node.CDATA_SECTION_NODE | 1 << Node.ENTITY_REFERENCE_NODE ;
87 kidOK[Node.ATTRIBUTE_NODE] = 1 << Node.TEXT_NODE | 1 << Node.ENTITY_REFERENCE_NODE;
88 kidOK[Node.DOCUMENT_TYPE_NODE] = 0;
|