~vcs-imports/xena/trunk

« back to all changes in this revision

Viewing changes to ext/src/xalan-j_2_7_1/src/org/apache/xml/utils/ElemDesc.java

  • Committer: matthewoliver
  • Date: 2009-12-10 03:18:07 UTC
  • Revision ID: vcs-imports@canonical.com-20091210031807-l086qguzdlljtkl9
Merged Xena Testing into Xena Stable for the Xena 5 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
9
 *
 
10
 *     http://www.apache.org/licenses/LICENSE-2.0
 
11
 *
 
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.
 
17
 */
 
18
/*
 
19
 * $Id: ElemDesc.java,v 1.2 2009/12/10 03:18:23 matthewoliver Exp $
 
20
 */
 
21
package org.apache.xml.utils;
 
22
 
 
23
import java.util.Hashtable;
 
24
 
 
25
/**
 
26
 * This class is in support of SerializerToHTML, and acts as a sort
 
27
 * of element representative for HTML elements.
 
28
 * @xsl.usage internal
 
29
 */
 
30
class ElemDesc
 
31
{
 
32
 
 
33
  /** Table of attributes for the element */
 
34
  Hashtable m_attrs = null;
 
35
 
 
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. */
 
42
  int m_flags;
 
43
 
 
44
  /** Defines mnemonic and bit-value for the EMPTY flag */
 
45
  static final int EMPTY = (1 << 1);
 
46
 
 
47
  /** Defines mnemonic and bit-value for the FLOW flag  */
 
48
  static final int FLOW = (1 << 2);
 
49
 
 
50
  /** Defines mnemonic and bit-value for the BLOCK flag          */
 
51
  static final int BLOCK = (1 << 3);
 
52
 
 
53
  /** Defines mnemonic and bit-value for the BLOCKFORM  flag         */
 
54
  static final int BLOCKFORM = (1 << 4);
 
55
 
 
56
  /** Defines mnemonic and bit-value for the BLOCKFORMFIELDSET flag          */
 
57
  static final int BLOCKFORMFIELDSET = (1 << 5);
 
58
 
 
59
  /** Defines mnemonic and bit-value for the CDATA flag         */
 
60
  static final int CDATA = (1 << 6);
 
61
 
 
62
  /** Defines mnemonic and bit-value for the PCDATA flag          */
 
63
  static final int PCDATA = (1 << 7);
 
64
 
 
65
  /** Defines mnemonic and bit-value for the RAW flag         */
 
66
  static final int RAW = (1 << 8);
 
67
 
 
68
  /** Defines mnemonic and bit-value for the INLINE flag          */
 
69
  static final int INLINE = (1 << 9);
 
70
 
 
71
  /** Defines mnemonic and bit-value for the INLINEA flag          */
 
72
  static final int INLINEA = (1 << 10);
 
73
 
 
74
  /** Defines mnemonic and bit-value for the INLINELABEL flag          */
 
75
  static final int INLINELABEL = (1 << 11);
 
76
 
 
77
  /** Defines mnemonic and bit-value for the FONTSTYLE flag          */
 
78
  static final int FONTSTYLE = (1 << 12);
 
79
 
 
80
  /** Defines mnemonic and bit-value for the PHRASE flag          */
 
81
  static final int PHRASE = (1 << 13);
 
82
 
 
83
  /** Defines mnemonic and bit-value for the FORMCTRL flag         */
 
84
  static final int FORMCTRL = (1 << 14);
 
85
 
 
86
  /** Defines mnemonic and bit-value for the SPECIAL flag         */
 
87
  static final int SPECIAL = (1 << 15);
 
88
 
 
89
  /** Defines mnemonic and bit-value for the ASPECIAL flag         */
 
90
  static final int ASPECIAL = (1 << 16);
 
91
 
 
92
  /** Defines mnemonic and bit-value for the HEADMISC flag         */
 
93
  static final int HEADMISC = (1 << 17);
 
94
 
 
95
  /** Defines mnemonic and bit-value for the HEAD flag         */
 
96
  static final int HEAD = (1 << 18);
 
97
 
 
98
  /** Defines mnemonic and bit-value for the LIST flag         */
 
99
  static final int LIST = (1 << 19);
 
100
 
 
101
  /** Defines mnemonic and bit-value for the PREFORMATTED flag         */
 
102
  static final int PREFORMATTED = (1 << 20);
 
103
 
 
104
  /** Defines mnemonic and bit-value for the WHITESPACESENSITIVE flag         */
 
105
  static final int WHITESPACESENSITIVE = (1 << 21);
 
106
 
 
107
  /** Defines mnemonic and bit-value for the ATTRURL flag         */
 
108
  static final int ATTRURL = (1 << 1);
 
109
 
 
110
  /** Defines mnemonic and bit-value for the ATTREMPTY flag         */
 
111
  static final int ATTREMPTY = (1 << 2);
 
112
 
 
113
  /**
 
114
   * Construct an ElementDescription with an initial set of flags.
 
115
   *
 
116
   * @param flags Element flags
 
117
   * @see m_flags
 
118
   */
 
119
  ElemDesc(int flags)
 
120
  {
 
121
    m_flags = flags;
 
122
  }
 
123
 
 
124
  /**
 
125
   * "is (this element described by these flags)".
 
126
   * 
 
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".
 
132
   *
 
133
   * @param flags Vector of flags to compare against this element's flags
 
134
   *
 
135
   * @return true if the flags set in the parameter are also set in the
 
136
   * element's stored flags.
 
137
   * 
 
138
   * @see m_flags
 
139
   * @see isAttrFlagSet
 
140
   */
 
141
  boolean is(int flags)
 
142
  {
 
143
    // int which = (m_flags & flags);
 
144
    return (m_flags & flags) != 0;
 
145
  }
 
146
 
 
147
  /**
 
148
   * Set a new attribute for this element 
 
149
   *
 
150
   *
 
151
   * @param name Attribute name
 
152
   * @param flags Attibute flags
 
153
   */
 
154
  void setAttr(String name, int flags)
 
155
  {
 
156
 
 
157
    if (null == m_attrs)
 
158
      m_attrs = new Hashtable();
 
159
 
 
160
    m_attrs.put(name, new Integer(flags));
 
161
  }
 
162
 
 
163
  /**
 
164
   * Find out if a flag is set in a given attribute of this element 
 
165
   *
 
166
   *
 
167
   * @param name Attribute name
 
168
   * @param flags Flag to check
 
169
   *
 
170
   * @return True if the flag is set in the attribute. Returns false
 
171
   * if the attribute is not found 
 
172
   * @see m_flags
 
173
   */
 
174
  boolean isAttrFlagSet(String name, int flags)
 
175
  {
 
176
 
 
177
    if (null != m_attrs)
 
178
    {
 
179
      Integer _flags = (Integer) m_attrs.get(name);
 
180
 
 
181
      if (null != _flags)
 
182
      {
 
183
        return (_flags.intValue() & flags) != 0;
 
184
      }
 
185
    }
 
186
 
 
187
    return false;
 
188
  }
 
189
}