View Javadoc
1 /* 2 * Copyright (C) 2002 Carsten Krebs (Team-Konzept GmbH & Co.KG) 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 package com.teamkonzept.dom4jb.schema; 19 20 import java.util.ArrayList; 21 import java.util.Iterator; 22 import java.util.List; 23 import java.util.ListIterator; 24 25 import com.teamkonzept.dom4jb.dom.Document; 26 27 28 public class Sequence extends GroupDescriptor { 29 30 private List group; 31 32 /*** Creates new Sequence */ 33 public Sequence() { 34 this.group = new ArrayList(); 35 } 36 37 /*** Creates new Sequence */ 38 public Sequence( final Groupable[] group ) { 39 final int size = group.length; 40 this.group = new ArrayList( size ); 41 for ( int i = 0; i < size; i++ ) { 42 group[i].addTo( this.group ); 43 } 44 } 45 46 /*** Creates new Sequence */ 47 public Sequence( final List group ) { 48 this.group = group; 49 } 50 51 public final ContentIterator getContentIterator( final Document doc, 52 final Object obj ) { 53 return new SequenceIterator( group, doc, obj ); 54 } 55 56 public boolean isEmpty() { 57 return group.isEmpty(); 58 } 59 60 public void addTo( final List list ) { 61 final ListIterator groupIter = group.listIterator(); 62 while ( groupIter.hasNext() ) { 63 final Groupable groupable = (Groupable)groupIter.next(); 64 groupable.addTo( list ); 65 } 66 } 67 68 public String toString() { 69 final StringBuffer buf = new StringBuffer( "Sequence[" ); 70 for ( Iterator itemIter = group.iterator(); itemIter.hasNext(); ) { 71 final Groupable item = (Groupable)itemIter.next(); 72 buf.append( item.toString() ); 73 if ( itemIter.hasNext() ) { 74 buf.append( ", " ); 75 } 76 } 77 buf.append( ']' ); 78 return buf.toString(); 79 } 80 }

This page was automatically generated by Maven