2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 * $Id: ElemDesc.java 468654 2006-10-28 07:09:23Z minchau $
21 package org.apache.xml.serializer;
23 import org.apache.xml.serializer.utils.StringToIntTable;
26 * This class has a series of flags (bit values) that describe an HTML element
28 * This class is not a public API.
29 * It is public because it is used outside of this package.
33 public final class ElemDesc
35 /** Bit flags to tell about this element type. */
39 * Table of attribute names to integers, which contain bit flags telling about
42 private StringToIntTable m_attrs = null;
44 /** Bit position if this element type is empty. */
45 static final int EMPTY = (1 << 1);
47 /** Bit position if this element type is a flow. */
48 private static final int FLOW = (1 << 2);
50 /** Bit position if this element type is a block. */
51 static final int BLOCK = (1 << 3);
53 /** Bit position if this element type is a block form. */
54 static final int BLOCKFORM = (1 << 4);
56 /** Bit position if this element type is a block form field set. */
57 static final int BLOCKFORMFIELDSET = (1 << 5);
59 /** Bit position if this element type is CDATA. */
60 private static final int CDATA = (1 << 6);
62 /** Bit position if this element type is PCDATA. */
63 private static final int PCDATA = (1 << 7);
65 /** Bit position if this element type is should be raw characters. */
66 static final int RAW = (1 << 8);
68 /** Bit position if this element type should be inlined. */
69 private static final int INLINE = (1 << 9);
71 /** Bit position if this element type is INLINEA. */
72 private static final int INLINEA = (1 << 10);
74 /** Bit position if this element type is an inline label. */
75 static final int INLINELABEL = (1 << 11);
77 /** Bit position if this element type is a font style. */
78 static final int FONTSTYLE = (1 << 12);
80 /** Bit position if this element type is a phrase. */
81 static final int PHRASE = (1 << 13);
83 /** Bit position if this element type is a form control. */
84 static final int FORMCTRL = (1 << 14);
86 /** Bit position if this element type is ???. */
87 static final int SPECIAL = (1 << 15);
89 /** Bit position if this element type is ???. */
90 static final int ASPECIAL = (1 << 16);
92 /** Bit position if this element type is an odd header element. */
93 static final int HEADMISC = (1 << 17);
95 /** Bit position if this element type is a head element (i.e. H1, H2, etc.) */
96 static final int HEAD = (1 << 18);
98 /** Bit position if this element type is a list. */
99 static final int LIST = (1 << 19);
101 /** Bit position if this element type is a preformatted type. */
102 static final int PREFORMATTED = (1 << 20);
104 /** Bit position if this element type is whitespace sensitive. */
105 static final int WHITESPACESENSITIVE = (1 << 21);
107 /** Bit position if this element type is a header element (i.e. HEAD). */
108 static final int HEADELEM = (1 << 22);
110 /** Bit position if this element is the "HTML" element */
111 static final int HTMLELEM = (1 << 23);
113 /** Bit position if this attribute type is a URL. */
114 public static final int ATTRURL = (1 << 1);
116 /** Bit position if this attribute type is an empty type. */
117 public static final int ATTREMPTY = (1 << 2);
120 * Construct an ElemDesc from a set of bit flags.
123 * @param flags Bit flags that describe the basic properties of this element type.
131 * Tell if this element type has the basic bit properties that are passed
134 * @param flags Bit flags that describe the basic properties of interest.
136 * @return true if any of the flag bits are true.
138 private boolean is(int flags)
141 // int which = (m_flags & flags);
142 return (m_flags & flags) != 0;
150 * Set an attribute name and it's bit properties.
153 * @param name non-null name of attribute, in upper case.
154 * @param flags flag bits.
156 void setAttr(String name, int flags)
160 m_attrs = new StringToIntTable();
162 m_attrs.put(name, flags);
166 * Tell if any of the bits of interest are set for a named attribute type.
168 * @param name non-null reference to attribute name, in any case.
169 * @param flags flag mask.
171 * @return true if any of the flags are set for the named attribute.
173 public boolean isAttrFlagSet(String name, int flags)
175 return (null != m_attrs)
176 ? ((m_attrs.getIgnoreCase(name) & flags) != 0)