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,v 1.2 2009/12/10 03:18:23 matthewoliver Exp $
21
package org.apache.xml.utils;
23
import java.util.Hashtable;
26
* This class is in support of SerializerToHTML, and acts as a sort
27
* of element representative for HTML elements.
33
/** Table of attributes for the element */
34
Hashtable m_attrs = null;
36
/** Element's flags, describing the role this element plays during
37
* formatting of the document. This is used as a bitvector; more than one flag
38
* may be set at a time, bitwise-ORed together. Mnemonic and bits
39
* have been assigned to the flag values. NOTE: Some bits are
40
* currently assigned multiple mnemonics; it is the caller's
41
* responsibility to disambiguate these if necessary. */
44
/** Defines mnemonic and bit-value for the EMPTY flag */
45
static final int EMPTY = (1 << 1);
47
/** Defines mnemonic and bit-value for the FLOW flag */
48
static final int FLOW = (1 << 2);
50
/** Defines mnemonic and bit-value for the BLOCK flag */
51
static final int BLOCK = (1 << 3);
53
/** Defines mnemonic and bit-value for the BLOCKFORM flag */
54
static final int BLOCKFORM = (1 << 4);
56
/** Defines mnemonic and bit-value for the BLOCKFORMFIELDSET flag */
57
static final int BLOCKFORMFIELDSET = (1 << 5);
59
/** Defines mnemonic and bit-value for the CDATA flag */
60
static final int CDATA = (1 << 6);
62
/** Defines mnemonic and bit-value for the PCDATA flag */
63
static final int PCDATA = (1 << 7);
65
/** Defines mnemonic and bit-value for the RAW flag */
66
static final int RAW = (1 << 8);
68
/** Defines mnemonic and bit-value for the INLINE flag */
69
static final int INLINE = (1 << 9);
71
/** Defines mnemonic and bit-value for the INLINEA flag */
72
static final int INLINEA = (1 << 10);
74
/** Defines mnemonic and bit-value for the INLINELABEL flag */
75
static final int INLINELABEL = (1 << 11);
77
/** Defines mnemonic and bit-value for the FONTSTYLE flag */
78
static final int FONTSTYLE = (1 << 12);
80
/** Defines mnemonic and bit-value for the PHRASE flag */
81
static final int PHRASE = (1 << 13);
83
/** Defines mnemonic and bit-value for the FORMCTRL flag */
84
static final int FORMCTRL = (1 << 14);
86
/** Defines mnemonic and bit-value for the SPECIAL flag */
87
static final int SPECIAL = (1 << 15);
89
/** Defines mnemonic and bit-value for the ASPECIAL flag */
90
static final int ASPECIAL = (1 << 16);
92
/** Defines mnemonic and bit-value for the HEADMISC flag */
93
static final int HEADMISC = (1 << 17);
95
/** Defines mnemonic and bit-value for the HEAD flag */
96
static final int HEAD = (1 << 18);
98
/** Defines mnemonic and bit-value for the LIST flag */
99
static final int LIST = (1 << 19);
101
/** Defines mnemonic and bit-value for the PREFORMATTED flag */
102
static final int PREFORMATTED = (1 << 20);
104
/** Defines mnemonic and bit-value for the WHITESPACESENSITIVE flag */
105
static final int WHITESPACESENSITIVE = (1 << 21);
107
/** Defines mnemonic and bit-value for the ATTRURL flag */
108
static final int ATTRURL = (1 << 1);
110
/** Defines mnemonic and bit-value for the ATTREMPTY flag */
111
static final int ATTREMPTY = (1 << 2);
114
* Construct an ElementDescription with an initial set of flags.
116
* @param flags Element flags
125
* "is (this element described by these flags)".
127
* This might more properly be called areFlagsSet(). It accepts an
128
* integer (being used as a bitvector) and checks whether all the
129
* corresponding bits are set in our internal flags. Note that this
130
* test is performed as a bitwise AND, not an equality test, so a
131
* 0 bit in the input means "don't test", not "must be set false".
133
* @param flags Vector of flags to compare against this element's flags
135
* @return true if the flags set in the parameter are also set in the
136
* element's stored flags.
141
boolean is(int flags)
143
// int which = (m_flags & flags);
144
return (m_flags & flags) != 0;
148
* Set a new attribute for this element
151
* @param name Attribute name
152
* @param flags Attibute flags
154
void setAttr(String name, int flags)
158
m_attrs = new Hashtable();
160
m_attrs.put(name, new Integer(flags));
164
* Find out if a flag is set in a given attribute of this element
167
* @param name Attribute name
168
* @param flags Flag to check
170
* @return True if the flag is set in the attribute. Returns false
171
* if the attribute is not found
174
boolean isAttrFlagSet(String name, int flags)
179
Integer _flags = (Integer) m_attrs.get(name);
183
return (_flags.intValue() & flags) != 0;