Thu, 31 Aug 2017 15:18:52 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.xml.internal.stream.buffer; |
aoqi@0 | 27 | |
aoqi@0 | 28 | @SuppressWarnings("PointlessBitwiseExpression") |
aoqi@0 | 29 | public abstract class AbstractCreatorProcessor { |
aoqi@0 | 30 | /** |
aoqi@0 | 31 | * Flag on a T_DOCUMENT to indicate if a fragment |
aoqi@0 | 32 | */ |
aoqi@0 | 33 | protected static final int FLAG_DOCUMENT_FRAGMENT = 1 << 0; |
aoqi@0 | 34 | |
aoqi@0 | 35 | /* |
aoqi@0 | 36 | * Flags on T_ELEMENT, T_ATTRIBUTE, T_NAMESPACE_ATTRIBUTE |
aoqi@0 | 37 | * to indicate namespace information is represent |
aoqi@0 | 38 | */ |
aoqi@0 | 39 | protected static final int FLAG_PREFIX = 1 << 0; |
aoqi@0 | 40 | protected static final int FLAG_URI = 1 << 1; |
aoqi@0 | 41 | protected static final int FLAG_QUALIFIED_NAME = 1 << 2; |
aoqi@0 | 42 | |
aoqi@0 | 43 | /* |
aoqi@0 | 44 | * Types of content for T_TEXT and T_COMMENT |
aoqi@0 | 45 | * <p> |
aoqi@0 | 46 | * Highest 2 bits of lower nibble are used. |
aoqi@0 | 47 | */ |
aoqi@0 | 48 | protected static final int CONTENT_TYPE_CHAR_ARRAY = 0 << 2; |
aoqi@0 | 49 | protected static final int CONTENT_TYPE_CHAR_ARRAY_COPY = 1 << 2; |
aoqi@0 | 50 | protected static final int CONTENT_TYPE_STRING = 2 << 2; |
aoqi@0 | 51 | protected static final int CONTENT_TYPE_OBJECT = 3 << 2; |
aoqi@0 | 52 | |
aoqi@0 | 53 | /* |
aoqi@0 | 54 | * Size of the length of character content for CONTENT_TYPE_CHAR_ARRAY |
aoqi@0 | 55 | * <p> |
aoqi@0 | 56 | * Last bit of lower nibble is used. |
aoqi@0 | 57 | */ |
aoqi@0 | 58 | protected static final int CHAR_ARRAY_LENGTH_SMALL = 0; |
aoqi@0 | 59 | protected static final int CHAR_ARRAY_LENGTH_MEDIUM = 1; |
aoqi@0 | 60 | protected static final int CHAR_ARRAY_LENGTH_SMALL_SIZE = 1 << 8; |
aoqi@0 | 61 | protected static final int CHAR_ARRAY_LENGTH_MEDIUM_SIZE = 1 << 16; |
aoqi@0 | 62 | |
aoqi@0 | 63 | /* |
aoqi@0 | 64 | * Types of value for T_ATTRIBUTE |
aoqi@0 | 65 | * <p> |
aoqi@0 | 66 | * Highest bit of lower nibble is used. |
aoqi@0 | 67 | */ |
aoqi@0 | 68 | protected static final int VALUE_TYPE_STRING = 0; |
aoqi@0 | 69 | protected static final int VALUE_TYPE_OBJECT = 1 << 3; |
aoqi@0 | 70 | |
aoqi@0 | 71 | /* |
aoqi@0 | 72 | * Mask for types. |
aoqi@0 | 73 | * <p> |
aoqi@0 | 74 | * Highest nibble is used. |
aoqi@0 | 75 | */ |
aoqi@0 | 76 | protected static final int TYPE_MASK = 0xF0; |
aoqi@0 | 77 | protected static final int T_DOCUMENT = 0x10; |
aoqi@0 | 78 | protected static final int T_ELEMENT = 0x20; |
aoqi@0 | 79 | protected static final int T_ATTRIBUTE = 0x30; |
aoqi@0 | 80 | protected static final int T_NAMESPACE_ATTRIBUTE = 0x40; |
aoqi@0 | 81 | protected static final int T_TEXT = 0x50; |
aoqi@0 | 82 | protected static final int T_COMMENT = 0x60; |
aoqi@0 | 83 | protected static final int T_PROCESSING_INSTRUCTION = 0x70; |
aoqi@0 | 84 | protected static final int T_UNEXPANDED_ENTITY_REFERENCE = 0x80; |
aoqi@0 | 85 | protected static final int T_END = 0x90; |
aoqi@0 | 86 | |
aoqi@0 | 87 | /* |
aoqi@0 | 88 | * Composed types. |
aoqi@0 | 89 | * <p> |
aoqi@0 | 90 | * One octet is used. |
aoqi@0 | 91 | */ |
aoqi@0 | 92 | protected static final int T_DOCUMENT_FRAGMENT = T_DOCUMENT | FLAG_DOCUMENT_FRAGMENT; |
aoqi@0 | 93 | |
aoqi@0 | 94 | protected static final int T_ELEMENT_U_LN_QN = T_ELEMENT | FLAG_URI | FLAG_QUALIFIED_NAME; |
aoqi@0 | 95 | protected static final int T_ELEMENT_P_U_LN = T_ELEMENT | FLAG_PREFIX | FLAG_URI; |
aoqi@0 | 96 | protected static final int T_ELEMENT_U_LN = T_ELEMENT | FLAG_URI; |
aoqi@0 | 97 | protected static final int T_ELEMENT_LN = T_ELEMENT; |
aoqi@0 | 98 | |
aoqi@0 | 99 | protected static final int T_NAMESPACE_ATTRIBUTE_P = T_NAMESPACE_ATTRIBUTE | FLAG_PREFIX; |
aoqi@0 | 100 | protected static final int T_NAMESPACE_ATTRIBUTE_P_U = T_NAMESPACE_ATTRIBUTE | FLAG_PREFIX | FLAG_URI; |
aoqi@0 | 101 | protected static final int T_NAMESPACE_ATTRIBUTE_U = T_NAMESPACE_ATTRIBUTE | FLAG_URI; |
aoqi@0 | 102 | |
aoqi@0 | 103 | protected static final int T_ATTRIBUTE_U_LN_QN = T_ATTRIBUTE | FLAG_URI | FLAG_QUALIFIED_NAME; |
aoqi@0 | 104 | protected static final int T_ATTRIBUTE_P_U_LN = T_ATTRIBUTE | FLAG_PREFIX | FLAG_URI; |
aoqi@0 | 105 | protected static final int T_ATTRIBUTE_U_LN = T_ATTRIBUTE | FLAG_URI; |
aoqi@0 | 106 | protected static final int T_ATTRIBUTE_LN = T_ATTRIBUTE; |
aoqi@0 | 107 | protected static final int T_ATTRIBUTE_U_LN_QN_OBJECT = T_ATTRIBUTE_U_LN_QN | VALUE_TYPE_OBJECT; |
aoqi@0 | 108 | protected static final int T_ATTRIBUTE_P_U_LN_OBJECT = T_ATTRIBUTE_P_U_LN | VALUE_TYPE_OBJECT; |
aoqi@0 | 109 | protected static final int T_ATTRIBUTE_U_LN_OBJECT = T_ATTRIBUTE_U_LN | VALUE_TYPE_OBJECT; |
aoqi@0 | 110 | protected static final int T_ATTRIBUTE_LN_OBJECT = T_ATTRIBUTE_LN | VALUE_TYPE_OBJECT; |
aoqi@0 | 111 | |
aoqi@0 | 112 | protected static final int T_TEXT_AS_CHAR_ARRAY = T_TEXT; |
aoqi@0 | 113 | protected static final int T_TEXT_AS_CHAR_ARRAY_SMALL = T_TEXT | CHAR_ARRAY_LENGTH_SMALL; |
aoqi@0 | 114 | protected static final int T_TEXT_AS_CHAR_ARRAY_MEDIUM = T_TEXT | CHAR_ARRAY_LENGTH_MEDIUM; |
aoqi@0 | 115 | protected static final int T_TEXT_AS_CHAR_ARRAY_COPY = T_TEXT | CONTENT_TYPE_CHAR_ARRAY_COPY; |
aoqi@0 | 116 | protected static final int T_TEXT_AS_STRING = T_TEXT | CONTENT_TYPE_STRING; |
aoqi@0 | 117 | protected static final int T_TEXT_AS_OBJECT = T_TEXT | CONTENT_TYPE_OBJECT; |
aoqi@0 | 118 | |
aoqi@0 | 119 | protected static final int T_COMMENT_AS_CHAR_ARRAY = T_COMMENT; |
aoqi@0 | 120 | protected static final int T_COMMENT_AS_CHAR_ARRAY_SMALL = T_COMMENT | CHAR_ARRAY_LENGTH_SMALL; |
aoqi@0 | 121 | protected static final int T_COMMENT_AS_CHAR_ARRAY_MEDIUM = T_COMMENT | CHAR_ARRAY_LENGTH_MEDIUM; |
aoqi@0 | 122 | protected static final int T_COMMENT_AS_CHAR_ARRAY_COPY = T_COMMENT | CONTENT_TYPE_CHAR_ARRAY_COPY; |
aoqi@0 | 123 | protected static final int T_COMMENT_AS_STRING = T_COMMENT | CONTENT_TYPE_STRING; |
aoqi@0 | 124 | |
aoqi@0 | 125 | protected static final int T_END_OF_BUFFER = -1; |
aoqi@0 | 126 | |
aoqi@0 | 127 | protected FragmentedArray<byte[]> _currentStructureFragment; |
aoqi@0 | 128 | protected byte[] _structure; |
aoqi@0 | 129 | protected int _structurePtr; |
aoqi@0 | 130 | |
aoqi@0 | 131 | protected FragmentedArray<String[]> _currentStructureStringFragment; |
aoqi@0 | 132 | protected String[] _structureStrings; |
aoqi@0 | 133 | protected int _structureStringsPtr; |
aoqi@0 | 134 | |
aoqi@0 | 135 | protected FragmentedArray<char[]> _currentContentCharactersBufferFragment; |
aoqi@0 | 136 | protected char[] _contentCharactersBuffer; |
aoqi@0 | 137 | protected int _contentCharactersBufferPtr; |
aoqi@0 | 138 | |
aoqi@0 | 139 | protected FragmentedArray<Object[]> _currentContentObjectFragment; |
aoqi@0 | 140 | protected Object[] _contentObjects; |
aoqi@0 | 141 | protected int _contentObjectsPtr; |
aoqi@0 | 142 | } |