KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xalan > processor > XSLTElementDef


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17  * $Id: XSLTElementDef.java,v 1.18 2004/02/11 18:15:50 minchau Exp $
18  */

19 package org.apache.xalan.processor;
20
21 import java.util.Enumeration JavaDoc;
22 import java.util.Hashtable JavaDoc;
23
24 import org.apache.xalan.templates.Constants;
25 import org.apache.xml.utils.QName;
26
27 /**
28  * This class defines the allowed structure for an element in a XSLT stylesheet,
29  * is meant to reflect the structure defined in http://www.w3.org/TR/xslt#dtd, and the
30  * mapping between Xalan classes and the markup elements in the XSLT instance.
31  * This actually represents both text nodes and elements.
32  */

33 public class XSLTElementDef
34 {
35
36   /**
37    * Construct an instance of XSLTElementDef. This must be followed by a
38    * call to build().
39    */

40   XSLTElementDef(){}
41
42   /**
43    * Construct an instance of XSLTElementDef.
44    *
45    * @param namespace The Namespace URI, "*", or null.
46    * @param name The local name (without prefix), "*", or null.
47    * @param nameAlias A potential alias for the name, or null.
48    * @param elements An array of allowed child element defs, or null.
49    * @param attributes An array of allowed attribute defs, or null.
50    * @param contentHandler The element processor for this element.
51    * @param classObject The class of the object that this element def should produce.
52    */

53   XSLTElementDef(XSLTSchema schema, String JavaDoc namespace, String JavaDoc name, String JavaDoc nameAlias,
54                  XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
55                  XSLTElementProcessor contentHandler, Class JavaDoc classObject)
56   {
57     build(namespace, name, nameAlias, elements, attributes, contentHandler,
58           classObject);
59     if ( (null != namespace)
60     && (namespace.equals(Constants.S_XSLNAMESPACEURL)
61         || namespace.equals(Constants.S_BUILTIN_EXTENSIONS_URL)
62         || namespace.equals(Constants.S_BUILTIN_OLD_EXTENSIONS_URL)))
63     {
64       schema.addAvailableElement(new QName(namespace, name));
65       if(null != nameAlias)
66         schema.addAvailableElement(new QName(namespace, nameAlias));
67     }
68   }
69     
70     /**
71    * Construct an instance of XSLTElementDef.
72    *
73    * @param namespace The Namespace URI, "*", or null.
74    * @param name The local name (without prefix), "*", or null.
75    * @param nameAlias A potential alias for the name, or null.
76    * @param elements An array of allowed child element defs, or null.
77    * @param attributes An array of allowed attribute defs, or null.
78    * @param contentHandler The element processor for this element.
79    * @param classObject The class of the object that this element def should produce.
80    * @param has_required true if this element has required elements by the XSLT specification.
81    */

82   XSLTElementDef(XSLTSchema schema, String JavaDoc namespace, String JavaDoc name, String JavaDoc nameAlias,
83                  XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
84                  XSLTElementProcessor contentHandler, Class JavaDoc classObject, boolean has_required)
85   {
86         this.m_has_required = has_required;
87     build(namespace, name, nameAlias, elements, attributes, contentHandler,
88           classObject);
89     if ( (null != namespace)
90     && (namespace.equals(Constants.S_XSLNAMESPACEURL)
91         || namespace.equals(Constants.S_BUILTIN_EXTENSIONS_URL)
92         || namespace.equals(Constants.S_BUILTIN_OLD_EXTENSIONS_URL)))
93     {
94       schema.addAvailableElement(new QName(namespace, name));
95       if(null != nameAlias)
96         schema.addAvailableElement(new QName(namespace, nameAlias));
97     }
98         
99   }
100     
101     /**
102    * Construct an instance of XSLTElementDef.
103    *
104    * @param namespace The Namespace URI, "*", or null.
105    * @param name The local name (without prefix), "*", or null.
106    * @param nameAlias A potential alias for the name, or null.
107    * @param elements An array of allowed child element defs, or null.
108    * @param attributes An array of allowed attribute defs, or null.
109    * @param contentHandler The element processor for this element.
110    * @param classObject The class of the object that this element def should produce.
111    * @param has_required true if this element has required elements by the XSLT specification.
112    * @param required true if this element is required by the XSLT specification.
113    */

114   XSLTElementDef(XSLTSchema schema, String JavaDoc namespace, String JavaDoc name, String JavaDoc nameAlias,
115                  XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
116                  XSLTElementProcessor contentHandler, Class JavaDoc classObject,
117                                  boolean has_required, boolean required)
118   {
119     this(schema, namespace, name, nameAlias,
120                  elements, attributes,
121                  contentHandler, classObject, has_required);
122         this.m_required = required;
123   }
124     
125     /**
126    * Construct an instance of XSLTElementDef.
127    *
128    * @param namespace The Namespace URI, "*", or null.
129    * @param name The local name (without prefix), "*", or null.
130    * @param nameAlias A potential alias for the name, or null.
131    * @param elements An array of allowed child element defs, or null.
132    * @param attributes An array of allowed attribute defs, or null.
133    * @param contentHandler The element processor for this element.
134    * @param classObject The class of the object that this element def should produce.
135    * @param has_required true if this element has required elements by the XSLT specification.
136    * @param required true if this element is required by the XSLT specification.
137    * @param order the order this element should appear according to the XSLT specification.
138    * @param multiAllowed whether this element is allowed more than once
139    */

140   XSLTElementDef(XSLTSchema schema, String JavaDoc namespace, String JavaDoc name, String JavaDoc nameAlias,
141                  XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
142                  XSLTElementProcessor contentHandler, Class JavaDoc classObject,
143                                  boolean has_required, boolean required, int order,
144                                  boolean multiAllowed)
145   {
146         this(schema, namespace, name, nameAlias,
147                  elements, attributes,
148                  contentHandler, classObject, has_required, required);
149         this.m_order = order;
150         this.m_multiAllowed = multiAllowed;
151   }
152     
153     /**
154    * Construct an instance of XSLTElementDef.
155    *
156    * @param namespace The Namespace URI, "*", or null.
157    * @param name The local name (without prefix), "*", or null.
158    * @param nameAlias A potential alias for the name, or null.
159    * @param elements An array of allowed child element defs, or null.
160    * @param attributes An array of allowed attribute defs, or null.
161    * @param contentHandler The element processor for this element.
162    * @param classObject The class of the object that this element def should produce.
163    * @param has_required true if this element has required elements by the XSLT specification.
164    * @param required true if this element is required by the XSLT specification.
165    * @param has_order whether this element has ordered child elements
166    * @param order the order this element should appear according to the XSLT specification.
167    * @param multiAllowed whether this element is allowed more than once
168    */

169   XSLTElementDef(XSLTSchema schema, String JavaDoc namespace, String JavaDoc name, String JavaDoc nameAlias,
170                  XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
171                  XSLTElementProcessor contentHandler, Class JavaDoc classObject,
172                                  boolean has_required, boolean required, boolean has_order, int order,
173                                  boolean multiAllowed)
174   {
175         this(schema, namespace, name, nameAlias,
176                  elements, attributes,
177                  contentHandler, classObject, has_required, required);
178         this.m_order = order;
179         this.m_multiAllowed = multiAllowed;
180     this.m_isOrdered = has_order;
181   }
182     
183     /**
184    * Construct an instance of XSLTElementDef.
185    *
186    * @param namespace The Namespace URI, "*", or null.
187    * @param name The local name (without prefix), "*", or null.
188    * @param nameAlias A potential alias for the name, or null.
189    * @param elements An array of allowed child element defs, or null.
190    * @param attributes An array of allowed attribute defs, or null.
191    * @param contentHandler The element processor for this element.
192    * @param classObject The class of the object that this element def should produce.
193    * @param has_order whether this element has ordered child elements
194    * @param order the order this element should appear according to the XSLT specification.
195    * @param multiAllowed whether this element is allowed more than once
196    */

197   XSLTElementDef(XSLTSchema schema, String JavaDoc namespace, String JavaDoc name, String JavaDoc nameAlias,
198                  XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
199                  XSLTElementProcessor contentHandler, Class JavaDoc classObject,
200                                  boolean has_order, int order, boolean multiAllowed)
201   {
202     this(schema, namespace, name, nameAlias,
203                  elements, attributes,
204                  contentHandler, classObject,
205                                  order, multiAllowed);
206         this.m_isOrdered = has_order;
207   }
208     
209     /**
210    * Construct an instance of XSLTElementDef.
211    *
212    * @param namespace The Namespace URI, "*", or null.
213    * @param name The local name (without prefix), "*", or null.
214    * @param nameAlias A potential alias for the name, or null.
215    * @param elements An array of allowed child element defs, or null.
216    * @param attributes An array of allowed attribute defs, or null.
217    * @param contentHandler The element processor for this element.
218    * @param classObject The class of the object that this element def should produce.
219    * @param order the order this element should appear according to the XSLT specification.
220    * @param multiAllowed whether this element is allowed more than once
221    */

222   XSLTElementDef(XSLTSchema schema, String JavaDoc namespace, String JavaDoc name, String JavaDoc nameAlias,
223                  XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
224                  XSLTElementProcessor contentHandler, Class JavaDoc classObject,
225                                  int order, boolean multiAllowed)
226   {
227     this(schema, namespace, name, nameAlias, elements, attributes, contentHandler,
228           classObject);
229     this.m_order = order;
230         this.m_multiAllowed = multiAllowed;
231   }
232
233   /**
234    * Construct an instance of XSLTElementDef that represents text.
235    *
236    * @param classObject The class of the object that this element def should produce.
237    * @param contentHandler The element processor for this element.
238    * @param type Content type, one of T_ELEMENT, T_PCDATA, or T_ANY.
239    */

240   XSLTElementDef(Class JavaDoc classObject, XSLTElementProcessor contentHandler,
241                  int type)
242   {
243
244     this.m_classObject = classObject;
245     this.m_type = type;
246
247     setElementProcessor(contentHandler);
248   }
249
250   /**
251    * Construct an instance of XSLTElementDef.
252    *
253    * @param namespace The Namespace URI, "*", or null.
254    * @param name The local name (without prefix), "*", or null.
255    * @param nameAlias A potential alias for the name, or null.
256    * @param elements An array of allowed child element defs, or null.
257    * @param attributes An array of allowed attribute defs, or null.
258    * @param contentHandler The element processor for this element.
259    * @param classObject The class of the object that this element def should produce.
260    */

261   void build(String JavaDoc namespace, String JavaDoc name, String JavaDoc nameAlias,
262              XSLTElementDef[] elements, XSLTAttributeDef[] attributes,
263              XSLTElementProcessor contentHandler, Class JavaDoc classObject)
264   {
265
266     this.m_namespace = namespace;
267     this.m_name = name;
268     this.m_nameAlias = nameAlias;
269     this.m_elements = elements;
270     this.m_attributes = attributes;
271
272     setElementProcessor(contentHandler);
273
274     this.m_classObject = classObject;
275         
276         if (hasRequired() && m_elements != null)
277         {
278             int n = m_elements.length;
279             for (int i = 0; i < n; i++)
280             {
281                 XSLTElementDef def = m_elements[i];
282                 
283                 if (def != null && def.getRequired())
284                 {
285                     if (m_requiredFound == null)
286                         m_requiredFound = new Hashtable JavaDoc();
287                     m_requiredFound.put(def.getName(), "xsl:" +def.getName());
288                 }
289             }
290         }
291   }
292
293   /**
294    * Tell if two objects are equal, when either one may be null.
295    * If both are null, they are considered equal.
296    *
297    * @param obj1 A reference to the first object, or null.
298    * @param obj2 A reference to the second object, or null.
299    *
300    * @return true if the to objects are equal by both being null or
301    * because obj2.equals(obj1) returns true.
302    */

303   private static boolean equalsMayBeNull(Object JavaDoc obj1, Object JavaDoc obj2)
304   {
305     return (obj2 == obj1)
306            || ((null != obj1) && (null != obj2) && obj2.equals(obj1));
307   }
308
309   /**
310    * Tell if the two string refs are equal,
311    * equality being defined as:
312    * 1) Both strings are null.
313    * 2) One string is null and the other is empty.
314    * 3) Both strings are non-null, and equal.
315    *
316    * @param s1 A reference to the first string, or null.
317    * @param s2 A reference to the second string, or null.
318    *
319    * @return true if Both strings are null, or if
320    * one string is null and the other is empty, or if
321    * both strings are non-null, and equal because
322    * s1.equals(s2) returns true.
323    */

324   private static boolean equalsMayBeNullOrZeroLen(String JavaDoc s1, String JavaDoc s2)
325   {
326
327     int len1 = (s1 == null) ? 0 : s1.length();
328     int len2 = (s2 == null) ? 0 : s2.length();
329
330     return (len1 != len2) ? false
331                          : (len1 == 0) ? true
332                                  : s1.equals(s2);
333   }
334
335   /** Content type enumerations */
336   static final int T_ELEMENT = 1, T_PCDATA = 2, T_ANY = 3;
337
338   /**
339    * The type of this element.
340    */

341   private int m_type = T_ELEMENT;
342
343   /**
344    * Get the type of this element.
345    *
346    * @return Content type, one of T_ELEMENT, T_PCDATA, or T_ANY.
347    */

348   int getType()
349   {
350     return m_type;
351   }
352
353   /**
354    * Set the type of this element.
355    *
356    * @param t Content type, one of T_ELEMENT, T_PCDATA, or T_ANY.
357    */

358   void setType(int t)
359   {
360     m_type = t;
361   }
362
363   /**
364    * The allowed namespace for this element.
365    */

366   private String JavaDoc m_namespace;
367
368   /**
369    * Get the allowed namespace for this element.
370    *
371    * @return The Namespace URI, "*", or null.
372    */

373   String JavaDoc getNamespace()
374   {
375     return m_namespace;
376   }
377
378   /**
379    * The name of this element.
380    */

381   private String JavaDoc m_name;
382
383   /**
384    * Get the local name of this element.
385    *
386    * @return The local name of this element, "*", or null.
387    */

388   String JavaDoc getName()
389   {
390     return m_name;
391   }
392
393   /**
394    * The name of this element.
395    */

396   private String JavaDoc m_nameAlias;
397
398   /**
399    * Get the name of this element.
400    *
401    * @return A potential alias for the name, or null.
402    */

403   String JavaDoc getNameAlias()
404   {
405     return m_nameAlias;
406   }
407
408   /**
409    * The allowed elements for this type.
410    */

411   private XSLTElementDef[] m_elements;
412
413   /**
414    * Get the allowed elements for this type.
415    *
416    * @return An array of allowed child element defs, or null.
417    */

418   XSLTElementDef[] getElements()
419   {
420     return m_elements;
421   }
422
423   /**
424    * Set the allowed elements for this type.
425    *
426    * @param defs An array of allowed child element defs, or null.
427    */

428   void setElements(XSLTElementDef[] defs)
429   {
430     m_elements = defs;
431   }
432
433   /**
434    * Tell if the namespace URI and local name match this
435    * element.
436    * @param uri The namespace uri, which may be null.
437    * @param localName The local name of an element, which may be null.
438    *
439    * @return true if the uri and local name arguments are considered
440    * to match the uri and local name of this element def.
441    */

442   private boolean QNameEquals(String JavaDoc uri, String JavaDoc localName)
443   {
444
445     return (equalsMayBeNullOrZeroLen(m_namespace, uri)
446             && (equalsMayBeNullOrZeroLen(m_name, localName)
447                 || equalsMayBeNullOrZeroLen(m_nameAlias, localName)));
448   }
449
450   /**
451    * Given a namespace URI, and a local name, get the processor
452    * for the element, or return null if not allowed.
453    *
454    * @param uri The Namespace URI, or an empty string.
455    * @param localName The local name (without prefix), or empty string if not namespace processing.
456    *
457    * @return The element processor that matches the arguments, or null.
458    */

459   XSLTElementProcessor getProcessorFor(String JavaDoc uri, String JavaDoc localName)
460     {
461
462     XSLTElementProcessor elemDef = null; // return value
463

464     if (null == m_elements)
465       return null;
466
467     int n = m_elements.length;
468     int order = -1;
469         boolean multiAllowed = true;
470     for (int i = 0; i < n; i++)
471     {
472       XSLTElementDef def = m_elements[i];
473
474       // A "*" signals that the element allows literal result
475
// elements, so just assign the def, and continue to
476
// see if anything else matches.
477
if (def.m_name.equals("*"))
478       {
479                 
480         // Don't allow xsl elements
481
if (!equalsMayBeNullOrZeroLen(uri, Constants.S_XSLNAMESPACEURL))
482                 {
483           elemDef = def.m_elementProcessor;
484                   order = def.getOrder();
485                     multiAllowed = def.getMultiAllowed();
486                 }
487       }
488             else if (def.QNameEquals(uri, localName))
489             {
490                 if (def.getRequired())
491                     this.setRequiredFound(def.getName(), true);
492                 order = def.getOrder();
493                 multiAllowed = def.getMultiAllowed();
494                 elemDef = def.m_elementProcessor;
495                 break;
496             }
497         }
498         
499         if (elemDef != null && this.isOrdered())
500         {
501             int lastOrder = getLastOrder();
502             if (order > lastOrder)
503                 setLastOrder(order);
504             else if (order == lastOrder && !multiAllowed)
505             {
506                 return null;
507             }
508             else if (order < lastOrder && order > 0)
509             {
510                 return null;
511             }
512         }
513
514     return elemDef;
515   }
516
517   /**
518    * Given an unknown element, get the processor
519    * for the element.
520    *
521    * @param uri The Namespace URI, or an empty string.
522    * @param localName The local name (without prefix), or empty string if not namespace processing.
523    *
524    * @return normally a {@link ProcessorUnknown} reference.
525    * @see ProcessorUnknown
526    */

527   XSLTElementProcessor getProcessorForUnknown(String JavaDoc uri, String JavaDoc localName)
528   {
529
530     // XSLTElementProcessor lreDef = null; // return value
531
if (null == m_elements)
532       return null;
533
534     int n = m_elements.length;
535
536     for (int i = 0; i < n; i++)
537     {
538       XSLTElementDef def = m_elements[i];
539
540       if (def.m_name.equals("unknown") && uri.length() > 0)
541       {
542         return def.m_elementProcessor;
543       }
544     }
545
546     return null;
547   }
548
549   /**
550    * The allowed attributes for this type.
551    */

552   private XSLTAttributeDef[] m_attributes;
553
554   /**
555    * Get the allowed attributes for this type.
556    *
557    * @return An array of allowed attribute defs, or null.
558    */

559   XSLTAttributeDef[] getAttributes()
560   {
561     return m_attributes;
562   }
563
564   /**
565    * Given a namespace URI, and a local name, return the element's
566    * attribute definition, if it has one.
567    *
568    * @param uri The Namespace URI, or an empty string.
569    * @param localName The local name (without prefix), or empty string if not namespace processing.
570    *
571    * @return The attribute def that matches the arguments, or null.
572    */

573   XSLTAttributeDef getAttributeDef(String JavaDoc uri, String JavaDoc localName)
574   {
575
576     XSLTAttributeDef defaultDef = null;
577     XSLTAttributeDef[] attrDefs = getAttributes();
578     int nAttrDefs = attrDefs.length;
579
580     for (int k = 0; k < nAttrDefs; k++)
581     {
582       XSLTAttributeDef attrDef = attrDefs[k];
583       String JavaDoc uriDef = attrDef.getNamespace();
584       String JavaDoc nameDef = attrDef.getName();
585       
586       if (nameDef.equals("*") && (equalsMayBeNullOrZeroLen(uri, uriDef) ||
587           (uriDef != null && uriDef.equals("*") && uri!=null && uri.length() > 0 )))
588       {
589         return attrDef;
590       }
591       else if (nameDef.equals("*") && (uriDef == null))
592       {
593
594         // In this case, all attributes are legal, so return
595
// this as the last resort.
596
defaultDef = attrDef;
597       }
598       else if (equalsMayBeNullOrZeroLen(uri, uriDef)
599                && localName.equals(nameDef))
600       {
601         return attrDef;
602       }
603     }
604
605     if (null == defaultDef)
606     {
607       if (uri.length() > 0 && !equalsMayBeNullOrZeroLen(uri, Constants.S_XSLNAMESPACEURL))
608       {
609         return XSLTAttributeDef.m_foreignAttr;
610       }
611     }
612
613     return defaultDef;
614   }
615
616   /**
617    * If non-null, the ContentHandler/TransformerFactory for this element.
618    */

619   private XSLTElementProcessor m_elementProcessor;
620
621   /**
622    * Return the XSLTElementProcessor for this element.
623    *
624    * @return The element processor for this element.
625    */

626   XSLTElementProcessor getElementProcessor()
627   {
628     return m_elementProcessor;
629   }
630
631   /**
632    * Set the XSLTElementProcessor for this element.
633    *
634    * @param handler The element processor for this element.
635    */

636   void setElementProcessor(XSLTElementProcessor handler)
637   {
638
639     if (handler != null)
640     {
641       m_elementProcessor = handler;
642
643       m_elementProcessor.setElemDef(this);
644     }
645   }
646
647   /**
648    * If non-null, the class object that should in instantiated for
649    * a Xalan instance of this element.
650    */

651   private Class JavaDoc m_classObject;
652
653   /**
654    * Return the class object that should in instantiated for
655    * a Xalan instance of this element.
656    *
657    * @return The class of the object that this element def should produce, or null.
658    */

659   Class JavaDoc getClassObject()
660   {
661     return m_classObject;
662   }
663     
664     /**
665    * If true, this has a required element.
666    */

667   private boolean m_has_required = false;
668
669   /**
670    * Get whether or not this has a required element.
671    *
672    * @return true if this this has a required element.
673    */

674   boolean hasRequired()
675   {
676     return m_has_required;
677   }
678     
679     /**
680    * If true, this is a required element.
681    */

682   private boolean m_required = false;
683
684   /**
685    * Get whether or not this is a required element.
686    *
687    * @return true if this is a required element.
688    */

689   boolean getRequired()
690   {
691     return m_required;
692   }
693     
694     Hashtable JavaDoc m_requiredFound;
695     
696     /**
697    * Set this required element found.
698    *
699    */

700   void setRequiredFound(String JavaDoc elem, boolean found)
701   {
702    if (m_requiredFound.get(elem) != null)
703          m_requiredFound.remove(elem);
704   }
705     
706     /**
707    * Get whether all required elements were found.
708    *
709    * @return true if all required elements were found.
710    */

711   boolean getRequiredFound()
712   {
713         if (m_requiredFound == null)
714             return true;
715     return m_requiredFound.isEmpty();
716   }
717     
718     /**
719    * Get required elements that were not found.
720    *
721    * @return required elements that were not found.
722    */

723   String JavaDoc getRequiredElem()
724   {
725         if (m_requiredFound == null)
726             return null;
727         Enumeration JavaDoc elems = m_requiredFound.elements();
728         String JavaDoc s = "";
729         boolean first = true;
730         while (elems.hasMoreElements())
731         {
732             if (first)
733                 first = false;
734             else
735              s = s + ", ";
736             s = s + (String JavaDoc)elems.nextElement();
737         }
738     return s;
739   }
740     
741     boolean m_isOrdered = false;
742     
743     /**
744    * Get whether this element requires ordered children.
745    *
746    * @return true if this element requires ordered children.
747    */

748   boolean isOrdered()
749   {
750         /*if (!m_CheckedOrdered)
751         {
752             m_CheckedOrdered = true;
753             m_isOrdered = false;
754             if (null == m_elements)
755                 return false;
756
757             int n = m_elements.length;
758
759             for (int i = 0; i < n; i++)
760             {
761                 if (m_elements[i].getOrder() > 0)
762                 {
763                     m_isOrdered = true;
764                     return true;
765                 }
766             }
767             return false;
768         }
769         else*/

770             return m_isOrdered;
771   }
772     
773     /**
774    * the order that this element should appear, or -1 if not ordered
775    */

776   private int m_order = -1;
777     
778     /**
779    * Get the order that this element should appear .
780    *
781    * @return the order that this element should appear.
782    */

783   int getOrder()
784   {
785     return m_order;
786   }
787     
788     /**
789    * the highest order of child elements have appeared so far,
790    * or -1 if not ordered
791    */

792   private int m_lastOrder = -1;
793     
794     /**
795    * Get the highest order of child elements have appeared so far .
796    *
797    * @return the highest order of child elements have appeared so far.
798    */

799   int getLastOrder()
800   {
801     return m_lastOrder;
802   }
803     
804     /**
805    * Set the highest order of child elements have appeared so far .
806    *
807    * @param order the highest order of child elements have appeared so far.
808    */

809   void setLastOrder(int order)
810   {
811     m_lastOrder = order ;
812   }
813     
814     /**
815    * True if this element can appear multiple times
816    */

817   private boolean m_multiAllowed = true;
818     
819     /**
820    * Get whether this element can appear multiple times
821    *
822    * @return true if this element can appear multiple times
823    */

824   boolean getMultiAllowed()
825   {
826     return m_multiAllowed;
827   }
828 }
829
Popular Tags