001package com.hfg.xml.xsd; 002 003import java.util.ArrayList; 004import java.util.List; 005 006import com.hfg.xml.XMLNamespace; 007import com.hfg.xml.XMLNode; 008 009//------------------------------------------------------------------------------ 010/** 011 Representation of a sequence in an XML Schema Definition (XSD) specification. 012 <div> 013 @author J. Alex Taylor, hairyfatguy.com 014 </div> 015 */ 016//------------------------------------------------------------------------------ 017// com.hfg XML/HTML Coding Library 018// 019// This library is free software; you can redistribute it and/or 020// modify it under the terms of the GNU Lesser General Public 021// License as published by the Free Software Foundation; either 022// version 2.1 of the License, or (at your option) any later version. 023// 024// This library is distributed in the hope that it will be useful, 025// but WITHOUT ANY WARRANTY; without even the implied warranty of 026// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 027// Lesser General Public License for more details. 028// 029// You should have received a copy of the GNU Lesser General Public 030// License along with this library; if not, write to the Free Software 031// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 032// 033// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 034// jataylor@hairyfatguy.com 035//------------------------------------------------------------------------------ 036 037public class XsdSequence extends XsdContent 038{ 039 private List<XsdContent> mContent; 040 041 //--------------------------------------------------------------------------- 042 public XsdSequence() 043 { 044 } 045 046 //--------------------------------------------------------------------------- 047 public XsdSequence(XMLNode inTag, XMLNamespace inNamespace) 048 { 049 super(inTag); 050 051 inTag.verifyTagName(XsdXML.SEQUENCE.getLocalName()); 052 053 for (XMLNode subtag : inTag.getXMLNodeSubtags()) 054 { 055 if (subtag.getTagName().equals(XsdXML.ELEMENT.getLocalName())) 056 { 057 addContent(new XsdElement(subtag).setNamespace(inNamespace)); 058 } 059 else if (subtag.getTagName().equals(XsdXML.GROUP.getLocalName())) 060 { 061 addContent(new XsdGroup(subtag, inNamespace)); 062 } 063 else if (subtag.getTagName().equals(XsdXML.CHOICE.getLocalName())) 064 { 065 addContent(new XsdChoice(subtag, inNamespace)); 066 } 067 } 068 } 069 070 071 //--------------------------------------------------------------------------- 072 @Override 073 public XsdSequence setMaxOccurs(int inValue) 074 { 075 super.setMaxOccurs(inValue); 076 return this; 077 } 078 079 //--------------------------------------------------------------------------- 080 @Override 081 public XsdSequence setMinOccurs(int inValue) 082 { 083 super.setMinOccurs(inValue); 084 return this; 085 } 086 087 //--------------------------------------------------------------------------- 088 public List<XsdContent> getContent() 089 { 090 return mContent; 091 } 092 093 //--------------------------------------------------------------------------- 094 public XsdSequence addContent(XsdContent inValue) 095 { 096 if (null == mContent) 097 { 098 mContent = new ArrayList<>(20); 099 } 100 101 mContent.add(inValue); 102 return this; 103 } 104}