001: /*
002: * The contents of this file are subject to the terms
003: * of the Common Development and Distribution License
004: * (the "License"). You may not use this file except
005: * in compliance with the License.
006: *
007: * You can obtain a copy of the license at
008: * https://jwsdp.dev.java.net/CDDLv1.0.html
009: * See the License for the specific language governing
010: * permissions and limitations under the License.
011: *
012: * When distributing Covered Code, include this CDDL
013: * HEADER in each file and include the License file at
014: * https://jwsdp.dev.java.net/CDDLv1.0.html If applicable,
015: * add the following below this CDDL HEADER, with the
016: * fields enclosed by brackets "[]" replaced with your
017: * own identifying information: Portions Copyright [yyyy]
018: * [name of copyright owner]
019: */
020: package com.sun.xml.stream.buffer;
021:
022: public abstract class AbstractCreatorProcessor {
023: /**
024: * Flag on a T_DOCUMENT to indicate if a fragment
025: */
026: protected static final int FLAG_DOCUMENT_FRAGMENT = 1 << 0;
027:
028: /*
029: * Flags on T_ELEMENT, T_ATTRIBUTE, T_NAMESPACE_ATTRIBUTE
030: * to indicate namespace information is represent
031: */
032: protected static final int FLAG_PREFIX = 1 << 0;
033: protected static final int FLAG_URI = 1 << 1;
034: protected static final int FLAG_QUALIFIED_NAME = 1 << 2;
035:
036: /*
037: * Types of content for T_TEXT and T_COMMENT
038: * <p>
039: * Highest 2 bits of lower nibble are used.
040: */
041: protected static final int CONTENT_TYPE_CHAR_ARRAY = 0 << 2;
042: protected static final int CONTENT_TYPE_CHAR_ARRAY_COPY = 1 << 2;
043: protected static final int CONTENT_TYPE_STRING = 2 << 2;
044: protected static final int CONTENT_TYPE_OBJECT = 3 << 2;
045:
046: /*
047: * Size of the length of character content for CONTENT_TYPE_CHAR_ARRAY
048: * <p>
049: * Last bit of lower nibble is used.
050: */
051: protected static final int CHAR_ARRAY_LENGTH_SMALL = 0;
052: protected static final int CHAR_ARRAY_LENGTH_MEDIUM = 1;
053: protected static final int CHAR_ARRAY_LENGTH_SMALL_SIZE = 1 << 8;
054: protected static final int CHAR_ARRAY_LENGTH_MEDIUM_SIZE = 1 << 16;
055:
056: /*
057: * Types of value for T_ATTRIBUTE
058: * <p>
059: * Highest bit of lower nibble is used.
060: */
061: protected static final int VALUE_TYPE_STRING = 0;
062: protected static final int VALUE_TYPE_OBJECT = 1 << 3;
063:
064: /*
065: * Mask for types.
066: * <p>
067: * Highest nibble is used.
068: */
069: protected static final int TYPE_MASK = 0xF0;
070: protected static final int T_END = 0x00;
071: protected static final int T_DOCUMENT = 0x10;
072: protected static final int T_ELEMENT = 0x20;
073: protected static final int T_ATTRIBUTE = 0x30;
074: protected static final int T_NAMESPACE_ATTRIBUTE = 0x40;
075: protected static final int T_TEXT = 0x50;
076: protected static final int T_COMMENT = 0x60;
077: protected static final int T_PROCESSING_INSTRUCTION = 0x70;
078: protected static final int T_UNEXPANDED_ENTITY_REFERENCE = 0x80;
079:
080: /*
081: * Composed types.
082: * <p>
083: * One octet is used.
084: */
085: protected static final int T_DOCUMENT_FRAGMENT = T_DOCUMENT
086: | FLAG_DOCUMENT_FRAGMENT;
087:
088: protected static final int T_ELEMENT_U_LN_QN = T_ELEMENT | FLAG_URI
089: | FLAG_QUALIFIED_NAME;
090: protected static final int T_ELEMENT_P_U_LN = T_ELEMENT
091: | FLAG_PREFIX | FLAG_URI;
092: protected static final int T_ELEMENT_U_LN = T_ELEMENT | FLAG_URI;
093: protected static final int T_ELEMENT_LN = T_ELEMENT;
094:
095: protected static final int T_NAMESPACE_ATTRIBUTE_P = T_NAMESPACE_ATTRIBUTE
096: | FLAG_PREFIX;
097: protected static final int T_NAMESPACE_ATTRIBUTE_P_U = T_NAMESPACE_ATTRIBUTE
098: | FLAG_PREFIX | FLAG_URI;
099: protected static final int T_NAMESPACE_ATTRIBUTE_U = T_NAMESPACE_ATTRIBUTE
100: | FLAG_URI;
101:
102: protected static final int T_ATTRIBUTE_U_LN_QN = T_ATTRIBUTE
103: | FLAG_URI | FLAG_QUALIFIED_NAME;
104: protected static final int T_ATTRIBUTE_P_U_LN = T_ATTRIBUTE
105: | FLAG_PREFIX | FLAG_URI;
106: protected static final int T_ATTRIBUTE_U_LN = T_ATTRIBUTE
107: | FLAG_URI;
108: protected static final int T_ATTRIBUTE_LN = T_ATTRIBUTE;
109: protected static final int T_ATTRIBUTE_U_LN_QN_OBJECT = T_ATTRIBUTE_U_LN_QN
110: | VALUE_TYPE_OBJECT;
111: protected static final int T_ATTRIBUTE_P_U_LN_OBJECT = T_ATTRIBUTE_P_U_LN
112: | VALUE_TYPE_OBJECT;
113: protected static final int T_ATTRIBUTE_U_LN_OBJECT = T_ATTRIBUTE_U_LN
114: | VALUE_TYPE_OBJECT;
115: protected static final int T_ATTRIBUTE_LN_OBJECT = T_ATTRIBUTE_LN
116: | VALUE_TYPE_OBJECT;
117:
118: protected static final int T_TEXT_AS_CHAR_ARRAY = T_TEXT;
119: protected static final int T_TEXT_AS_CHAR_ARRAY_SMALL = T_TEXT
120: | CHAR_ARRAY_LENGTH_SMALL;
121: protected static final int T_TEXT_AS_CHAR_ARRAY_MEDIUM = T_TEXT
122: | CHAR_ARRAY_LENGTH_MEDIUM;
123: protected static final int T_TEXT_AS_CHAR_ARRAY_COPY = T_TEXT
124: | CONTENT_TYPE_CHAR_ARRAY_COPY;
125: protected static final int T_TEXT_AS_STRING = T_TEXT
126: | CONTENT_TYPE_STRING;
127: protected static final int T_TEXT_AS_OBJECT = T_TEXT
128: | CONTENT_TYPE_OBJECT;
129:
130: protected static final int T_COMMENT_AS_CHAR_ARRAY = T_COMMENT;
131: protected static final int T_COMMENT_AS_CHAR_ARRAY_SMALL = T_COMMENT
132: | CHAR_ARRAY_LENGTH_SMALL;
133: protected static final int T_COMMENT_AS_CHAR_ARRAY_MEDIUM = T_COMMENT
134: | CHAR_ARRAY_LENGTH_MEDIUM;
135: protected static final int T_COMMENT_AS_CHAR_ARRAY_COPY = T_COMMENT
136: | CONTENT_TYPE_CHAR_ARRAY_COPY;
137: protected static final int T_COMMENT_AS_STRING = T_COMMENT
138: | CONTENT_TYPE_STRING;
139:
140: protected static final int T_END_OF_BUFFER = -1;
141:
142: protected FragmentedArray<byte[]> _currentStructureFragment;
143: protected byte[] _structure;
144: protected int _structurePtr;
145:
146: protected FragmentedArray<String[]> _currentStructureStringFragment;
147: protected String[] _structureStrings;
148: protected int _structureStringsPtr;
149:
150: protected FragmentedArray<char[]> _currentContentCharactersBufferFragment;
151: protected char[] _contentCharactersBuffer;
152: protected int _contentCharactersBufferPtr;
153:
154: protected FragmentedArray<Object[]> _currentContentObjectFragment;
155: protected Object[] _contentObjects;
156: protected int _contentObjectsPtr;
157: }
|