KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > apache > xerces > validators > common > SimpleContentModel


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 1999,2000 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package org.enhydra.apache.xerces.validators.common;
59
60 import org.enhydra.apache.xerces.framework.XMLContentSpec;
61 import org.enhydra.apache.xerces.utils.ImplementationMessages;
62 import org.enhydra.apache.xerces.utils.QName;
63 import org.enhydra.apache.xerces.validators.schema.SchemaGrammar;
64 import org.enhydra.apache.xerces.validators.schema.SubstitutionGroupComparator;
65
66 /**
67  * SimpleContentModel is a derivative of the abstract content model base
68  * class that handles a small set of simple content models that are just
69  * way overkill to give the DFA treatment.
70  * <p>
71  * This class handles the following scenarios:
72  * <ul>
73  * <li> a
74  * <li> a?
75  * <li> a*
76  * <li> a+
77  * <li> a,b
78  * <li> a|b
79  * </ul>
80  * <p>
81  * These all involve a unary operation with one element type, or a binary
82  * operation with two elements. These are very simple and can be checked
83  * in a simple way without a DFA and without the overhead of setting up a
84  * DFA for such a simple check.
85  *
86  * @version $Id: SimpleContentModel.java,v 1.2 2005/01/26 08:28:44 jkjome Exp $
87  */

88 public class SimpleContentModel
89     implements XMLContentModel {
90
91     //
92
// Data
93
//
94

95     /**
96      * The element decl pool indices of the first (and optional second)
97      * child node. The operation code tells us whether the second child
98      * is used or not.
99      */

100     private QName fFirstChild = new QName();
101
102     /**
103      * The element decl pool indices of the first (and optional second)
104      * child node. The operation code tells us whether the second child
105      * is used or not.
106      */

107     private QName fSecondChild = new QName();
108
109     /**
110      * The operation that this object represents. Since this class only
111      * does simple contents, there is only ever a single operation
112      * involved (i.e. the children of the operation are always one or
113      * two leafs.) This is one of the XMLDTDParams.CONTENTSPECNODE_XXX values.
114      */

115     private int fOp;
116
117     /** Boolean to allow DTDs to validate even with namespace support. */
118     private boolean fDTD;
119
120     /* this is the SubstitutionGroupComparator object */
121     private SubstitutionGroupComparator comparator = null;
122
123     //
124
// Constructors
125
//
126

127     /**
128      * Constructs a simple content model.
129      *
130      * @param firstChildIndex The first child index
131      * @parma secondChildIndex The second child index.
132      * @param cmOp The content model operator.
133      *
134      * @see XMLContentSpec
135      */

136     public SimpleContentModel(QName firstChild, QName secondChild, int cmOp) {
137         this(firstChild, secondChild, cmOp, false);
138     }
139
140     /**
141      * Constructs a simple content model.
142      *
143      * @param firstChildIndex The first child index
144      * @parma secondChildIndex The second child index.
145      * @param cmOp The content model operator.
146      *
147      * @see XMLContentSpec
148      */

149     public SimpleContentModel(QName firstChild, QName secondChild,
150                               int cmOp, boolean dtd) {
151         //
152
// Store away the children and operation. This is all we need to
153
// do the content model check.
154
//
155
// The operation is one of the ContentSpecNode.NODE_XXX values!
156
//
157
fFirstChild.setValues(firstChild);
158         if (secondChild != null) {
159             fSecondChild.setValues(secondChild);
160         }
161         else {
162             fSecondChild.clear();
163         }
164         fOp = cmOp;
165         fDTD = dtd;
166     }
167
168     // Unique Particle Attribution
169
public void checkUniqueParticleAttribution(SchemaGrammar gram) throws Exception JavaDoc {
170         // rename back
171
fFirstChild.uri = gram.getContentSpecOrgUri(fFirstChild.uri);
172         fSecondChild.uri = gram.getContentSpecOrgUri(fSecondChild.uri);
173
174         // only possible violation is when it's a choice
175
if (fOp == XMLContentSpec.CONTENTSPECNODE_CHOICE &&
176             ElementWildcard.conflict(XMLContentSpec.CONTENTSPECNODE_LEAF,
177                                      fFirstChild.localpart, fFirstChild.uri,
178                                      XMLContentSpec.CONTENTSPECNODE_LEAF,
179                                      fSecondChild.localpart, fSecondChild.uri,
180                                      comparator)) {
181         }
182     }
183     // Unique Particle Attribution
184

185     //
186
// XMLContentModel methods
187
//
188

189     /**
190      * Check that the specified content is valid according to this
191      * content model. This method can also be called to do 'what if'
192      * testing of content models just to see if they would be valid.
193      * <p>
194      * A value of -1 in the children array indicates a PCDATA node. All other
195      * indexes will be positive and represent child elements. The count can be
196      * zero, since some elements have the EMPTY content model and that must be
197      * confirmed.
198      *
199      * @param children The children of this element. Each integer is an index within
200      * the <code>StringPool</code> of the child element name. An index
201      * of -1 is used to indicate an occurrence of non-whitespace character
202      * data.
203      * @param offset Offset into the array where the children starts.
204      * @param length The number of entries in the <code>children</code> array.
205      *
206      * @return The value -1 if fully valid, else the 0 based index of the child
207      * that first failed. If the value returned is equal to the number
208      * of children, then the specified children are valid but additional
209      * content is required to reach a valid ending state.
210      *
211      * @exception Exception Thrown on error.
212      */

213     public int validateContent(QName children[], int offset, int length) throws Exception JavaDoc {
214
215         //
216
// According to the type of operation, we do the correct type of
217
// content check.
218
//
219
switch(fOp)
220         {
221             case XMLContentSpec.CONTENTSPECNODE_LEAF :
222                 // If there is not a child, then report an error at index 0
223
if (length == 0)
224                     return 0;
225
226                 // If the 0th child is not the right kind, report an error at 0
227
if (fDTD) {
228                     if (children[offset].rawname != fFirstChild.rawname) {
229                         return 0;
230                     }
231                 }
232                 else {
233                     if (children[offset].uri != fFirstChild.uri ||
234                         children[offset].localpart != fFirstChild.localpart)
235                         return 0;
236                 }
237
238                 // If more than one child, report an error at index 1
239
if (length > 1)
240                     return 1;
241                 break;
242
243             case XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE :
244                 //
245
// If there is one child, make sure its the right type. If not,
246
// then its an error at index 0.
247
//
248
if (length == 1) {
249                     if (fDTD) {
250                         if (children[offset].rawname != fFirstChild.rawname) {
251                             return 0;
252                         }
253                     }
254                     else {
255                         if (children[offset].uri != fFirstChild.uri ||
256                          children[offset].localpart != fFirstChild.localpart)
257                         return 0;
258                     }
259                 }
260
261                 //
262
// If the child count is greater than one, then obviously
263
// bad, so report an error at index 1.
264
//
265
if (length > 1)
266                     return 1;
267                 break;
268
269             case XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE :
270                 //
271
// If the child count is zero, that's fine. If its more than
272
// zero, then make sure that all children are of the element
273
// type that we stored. If not, report the index of the first
274
// failed one.
275
//
276
if (length > 0)
277                 {
278                     if (fDTD) {
279                         for (int index = 0; index < length; index++) {
280                             if (children[offset + index].rawname != fFirstChild.rawname) {
281                                 return index;
282                             }
283                         }
284                     }
285                     else {
286                         for (int index = 0; index < length; index++)
287                         {
288                             if (children[offset + index].uri != fFirstChild.uri ||
289                                 children[offset + index].localpart != fFirstChild.localpart)
290                                 return index;
291                         }
292                     }
293                 }
294                 break;
295
296             case XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE :
297                 //
298
// If the child count is zero, that's an error so report
299
// an error at index 0.
300
//
301
if (length == 0)
302                     return 0;
303
304                 //
305
// Otherwise we have to check them all to make sure that they
306
// are of the correct child type. If not, then report the index
307
// of the first one that is not.
308
//
309
if (fDTD) {
310                     for (int index = 0; index < length; index++) {
311                         if (children[offset + index].rawname != fFirstChild.rawname) {
312                             return index;
313                         }
314                     }
315                 }
316                 else {
317                     for (int index = 0; index < length; index++)
318                     {
319                         if (children[offset + index].uri != fFirstChild.uri ||
320                             children[offset + index].localpart != fFirstChild.localpart)
321                             return index;
322                     }
323                 }
324                 break;
325
326             case XMLContentSpec.CONTENTSPECNODE_CHOICE :
327                 //
328
// There must be one and only one child, so if the element count
329
// is zero, return an error at index 0.
330
//
331
if (length == 0)
332                     return 0;
333
334                 // If the zeroth element isn't one of our choices, error at 0
335
if (fDTD) {
336                     if ((children[offset].rawname != fFirstChild.rawname) &&
337                         (children[offset].rawname != fSecondChild.rawname)) {
338                         return 0;
339                     }
340                 }
341                 else {
342                     if ((children[offset].uri != fFirstChild.uri || children[offset].localpart != fFirstChild.localpart) &&
343                         (children[offset].uri != fSecondChild.uri || children[offset].localpart != fSecondChild.localpart))
344                         return 0;
345                 }
346
347                 // If there is more than one element, then an error at 1
348
if (length > 1)
349                     return 1;
350                 break;
351
352             case XMLContentSpec.CONTENTSPECNODE_SEQ :
353                 //
354
// There must be two children and they must be the two values
355
// we stored, in the stored order.
356
//
357
if (length == 2) {
358                     if (fDTD) {
359                         if (children[offset].rawname != fFirstChild.rawname) {
360                             return 0;
361                         }
362                         if (children[offset + 1].rawname != fSecondChild.rawname) {
363                             return 1;
364                         }
365                     }
366                     else {
367                         if (children[offset].uri != fFirstChild.uri || children[offset].localpart != fFirstChild.localpart)
368                             return 0;
369
370                         if (children[offset + 1].uri != fSecondChild.uri || children[offset + 1].localpart != fSecondChild.localpart)
371                             return 1;
372                     }
373                 }
374                 else {
375                     if (length > 2) {
376                         return 2;
377                     }
378
379                     return length;
380                 }
381
382                 break;
383
384             default :
385                 throw new CMException(ImplementationMessages.VAL_CST);
386         }
387
388         // We survived, so return success status
389
return -1;
390     }
391
392     public int validateContentSpecial(QName children[], int offset, int length) throws Exception JavaDoc{
393
394         if (comparator==null) {
395             return validateContent(children,offset, length);
396         }
397         //
398
// According to the type of operation, we do the correct type of
399
// content check.
400
//
401
switch(fOp)
402         {
403             case XMLContentSpec.CONTENTSPECNODE_LEAF :
404                 // If there is not a child, then report an error at index 0
405
if (length == 0)
406                     return 0;
407
408                 // If the 0th child is not the right kind, report an error at 0
409
if (children[offset].uri != fFirstChild.uri ||
410                     children[offset].localpart != fFirstChild.localpart)
411                     if (!comparator.isEquivalentTo(children[offset], fFirstChild))
412                         return 0;
413
414                 // If more than one child, report an error at index 1
415
if (length > 1)
416                     return 1;
417                 break;
418
419             case XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE :
420                 //
421
// If there is one child, make sure its the right type. If not,
422
// then its an error at index 0.
423
//
424
if (length == 1 &&
425                     (children[offset].uri != fFirstChild.uri ||
426                      children[offset].localpart != fFirstChild.localpart))
427                     if (!comparator.isEquivalentTo(children[offset], fFirstChild))
428                         return 0;
429
430                 //
431
// If the child count is greater than one, then obviously
432
// bad, so report an error at index 1.
433
//
434
if (length > 1)
435                     return 1;
436                 break;
437
438             case XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE :
439                 //
440
// If the child count is zero, that's fine. If its more than
441
// zero, then make sure that all children are of the element
442
// type that we stored. If not, report the index of the first
443
// failed one.
444
//
445
if (length > 0)
446                 {
447                     for (int index = 0; index < length; index++)
448                     {
449                         if (children[offset + index].uri != fFirstChild.uri ||
450                             children[offset + index].localpart != fFirstChild.localpart)
451                             if (!comparator.isEquivalentTo(children[offset+index], fFirstChild))
452                                 return index;
453                     }
454                 }
455                 break;
456
457             case XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE :
458                 //
459
// If the child count is zero, that's an error so report
460
// an error at index 0.
461
//
462
if (length == 0)
463                     return 0;
464
465                 //
466
// Otherwise we have to check them all to make sure that they
467
// are of the correct child type. If not, then report the index
468
// of the first one that is not.
469
//
470
for (int index = 0; index < length; index++)
471                 {
472                     if (children[offset + index].uri != fFirstChild.uri ||
473                         children[offset + index].localpart != fFirstChild.localpart)
474                         if (!comparator.isEquivalentTo(children[offset+index], fFirstChild))
475                             return index;
476                 }
477                 break;
478
479             case XMLContentSpec.CONTENTSPECNODE_CHOICE :
480                 //
481
// There must be one and only one child, so if the element count
482
// is zero, return an error at index 0.
483
//
484
if (length == 0)
485                     return 0;
486
487                 // If the zeroth element isn't one of our choices, error at 0
488
if ((children[offset].uri != fFirstChild.uri || children[offset].localpart != fFirstChild.localpart) &&
489                     (children[offset].uri != fSecondChild.uri || children[offset].localpart != fSecondChild.localpart))
490                     if ( !comparator.isEquivalentTo(children[offset], fFirstChild)
491                         && !comparator.isEquivalentTo(children[offset], fSecondChild) )
492                         return 0;
493
494                 // If there is more than one element, then an error at 1
495
if (length > 1)
496                     return 1;
497                 break;
498
499             case XMLContentSpec.CONTENTSPECNODE_SEQ :
500                 //
501
// There must be two children and they must be the two values
502
// we stored, in the stored order.
503
//
504
if (length == 2) {
505                     if (children[offset].uri != fFirstChild.uri || children[offset].localpart != fFirstChild.localpart)
506                         if (!comparator.isEquivalentTo(children[offset], fFirstChild))
507                             return 0;
508
509                     if (children[offset + 1].uri != fSecondChild.uri || children[offset + 1].localpart != fSecondChild.localpart)
510                         if (!comparator.isEquivalentTo(children[offset+1], fSecondChild))
511                             return 1;
512                 }
513                 else {
514                     if (length > 2) {
515                         return 2;
516                     }
517
518                     return length;
519                 }
520
521                 break;
522
523             default :
524                 throw new CMException(ImplementationMessages.VAL_CST);
525         }
526
527         // We survived, so return success status
528
return -1;
529     }
530
531     public void setSubstitutionGroupComparator(SubstitutionGroupComparator comparator) {
532         this.comparator = comparator;
533     }
534
535     /**
536      * Returns information about which elements can be placed at a particular point
537      * in the passed element's content model.
538      * <p>
539      * Note that the incoming content model to test must be valid at least up to
540      * the insertion point. If not, then -1 will be returned and the info object
541      * will not have been filled in.
542      * <p>
543      * If, on return, the info.isValidEOC flag is set, then the 'insert after'
544      * element is a valid end of content. In other words, nothing needs to be
545      * inserted after it to make the parent element's content model valid.
546      *
547      * @param fullyValid Only return elements that can be inserted and still
548      * maintain the validity of subsequent elements past the
549      * insertion point (if any). If the insertion point is at
550      * the end, and this is true, then only elements that can
551      * be legal final states will be returned.
552      * @param info An object that contains the required input data for the method,
553      * and which will contain the output information if successful.
554      *
555      * @return The value -1 if fully valid, else the 0 based index of the child
556      * that first failed before the insertion point. If the value
557      * returned is equal to the number of children, then the specified
558      * children are valid but additional content is required to reach a
559      * valid ending state.
560      *
561      * @see InsertableElementsInfo
562      */

563     public int whatCanGoHere(boolean fullyValid, InsertableElementsInfo info)
564         throws Exception JavaDoc {
565
566         //
567
// For this one, having the empty slot at the insertion point is
568
// a problem. So lets compress the array down. We know that it has
569
// to have at least the empty slot at the insertion point.
570
//
571
for (int index = info.insertAt; index < info.childCount-1; index++) {
572             info.curChildren[index].setValues(info.curChildren[index+1]);
573         }
574         info.childCount--;
575
576         //
577
// Check the validity of the existing contents. If this is less than
578
// the insert at point, then return failure index right now
579
//
580
final int failedIndex = validateContent(info.curChildren, 0, info.childCount);
581         if ((failedIndex != -1) && (failedIndex < info.insertAt))
582             return failedIndex;
583
584         // Set any stuff we can know right off the bat for all cases
585
info.canHoldPCData = false;
586
587         // See how many children we can possibly report
588
if ((fOp == XMLContentSpec.CONTENTSPECNODE_LEAF)
589         || (fOp == XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE)
590         || (fOp == XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE)
591         || (fOp == XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE))
592         {
593             info.resultsCount = 1;
594         }
595          else if ((fOp == XMLContentSpec.CONTENTSPECNODE_CHOICE)
596               || (fOp == XMLContentSpec.CONTENTSPECNODE_SEQ))
597         {
598             info.resultsCount = 2;
599         }
600          else
601         {
602             throw new CMException(ImplementationMessages.VAL_CST);
603         }
604
605         //
606
// If the outgoing arrays are too small or null, create new ones. These
607
// have to be at least the size of the results count.
608
//
609
if ((info.results == null) || (info.results.length < info.resultsCount))
610             info.results = new boolean[info.resultsCount];
611
612         if ((info.possibleChildren == null)
613         || (info.possibleChildren.length < info.resultsCount))
614         {
615             info.possibleChildren = new QName[info.resultsCount];
616             for (int i = 0; i < info.possibleChildren.length; i++) {
617                 info.possibleChildren[i] = new QName();
618             }
619         }
620
621         //
622
// Fill in the possible children array, and set all of the associated
623
// results entries to defaults of false.
624
//
625
info.possibleChildren[0].setValues(fFirstChild);
626         info.results[0] = false;
627         if (info.resultsCount == 2)
628         {
629             info.possibleChildren[1].setValues(fSecondChild);
630             info.results[1] = false;
631         }
632
633         //
634
// Set some defaults so that it does not have to be done redundantly
635
// below in each case.
636
//
637
info.isValidEOC = false;
638
639         //
640
// Now, for each spec type, lets do the grunt work required. Each of
641
// them is pretty simple, its just making sure of corner cases.
642
//
643
// We know its valid up to the insert point at least and we know that
644
// the insert point is never past the number of children, so this releaves
645
// a lot of checking below.
646
//
647
switch(fOp)
648         {
649             case XMLContentSpec.CONTENTSPECNODE_LEAF :
650             case XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE :
651                 //
652
// If there are no current children, then insert at has to be
653
// zero, so we can have the one leaf element inserted here.
654
//
655
if (info.childCount == 0)
656                 {
657                     info.results[0] = true;
658                 }
659                  else if (info.childCount > 0)
660                 {
661                     //
662
// If the child count is greater than zero, then inserting
663
// anything cannot be fully valid. But, if not fully valid
664
// checking, it is ok as long as inserting at zero.
665
//
666
if (!fullyValid && (info.insertAt == 0))
667                         info.results[0] = true;
668                 }
669
670                 if (fOp == XMLContentSpec.CONTENTSPECNODE_LEAF)
671                 {
672                     // If the insert point is 1, then EOC is valid there
673
if (info.insertAt == 0)
674                         info.isValidEOC = true;
675                 }
676                  else
677                 {
678                     // Its zero or one, so EOC is valid in either case
679
info.isValidEOC = true;
680                 }
681                 break;
682
683             case XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE :
684             case XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE :
685                 //
686
// The one child is always possible to insert, regardless of
687
// where. The fully valid flag never comes into play since it
688
// cannot become invalid by inserting any number of new
689
// instances of the one element.
690
//
691
info.results[0] = true;
692
693                 //
694
// Its zero/one or more, so EOC is valid in either case but only
695
// after the 0th index for one or more.
696
//
697
if ((fOp == XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE)
698                 || (info.insertAt > 0))
699                 {
700                     info.isValidEOC = true;
701                 }
702                 break;
703
704             case XMLContentSpec.CONTENTSPECNODE_CHOICE :
705                 //
706
// If the insert point is zero, then either of the two children
707
// can be inserted, unless fully valid is set and there are
708
// already any children.
709
//
710
if (info.insertAt == 0)
711                 {
712                     if (!fullyValid && (info.childCount == 0))
713                     {
714                         info.results[0] = true;
715                         info.results[1] = true;
716                     }
717                 }
718
719                 // EOC is only valid at the end
720
if (info.insertAt == 1)
721                     info.isValidEOC = true;
722                 break;
723
724             case XMLContentSpec.CONTENTSPECNODE_SEQ :
725                 //
726
// If the insert at is 0, then the first one valid. Else its
727
// the second one.
728
//
729
if (info.insertAt == 0)
730                 {
731                     //
732
// If fully valid check, then if there are two children,
733
// it cannot be valid. If there is one child, it must be
734
// equal to the second child of the pattern since it will
735
// get pushed up (which means it was a pattern like (x|x)
736
// which is kinda wierd.)
737
//
738
if (fullyValid)
739                     {
740                         if (info.childCount == 1)
741                             info.results[0] = info.curChildren[0].uri == fSecondChild.uri &&
742                                               info.curChildren[0].localpart == fSecondChild.localpart;
743                     }
744                      else
745                     {
746                         info.results[0] = true;
747                     }
748                 }
749                  else if (info.insertAt == 1)
750                 {
751                     // If fully valid, then there cannot be two existing children
752
if (!fullyValid || (info.childCount == 1))
753                         info.results[1] = true;
754                 }
755
756                 // EOC is only valid at the end
757
if (info.insertAt == 2)
758                     info.isValidEOC = true;
759                 break;
760
761             default :
762                 throw new CMException(ImplementationMessages.VAL_CST);
763         }
764
765         // We survived, so return success status
766
return -1;
767     }
768
769     public ContentLeafNameTypeVector getContentLeafNameTypeVector() {
770           return null;
771     }
772 } // class SimpleContentModel
773
Popular Tags