1 19 package org.netbeans.modules.xslt.model.impl; 20 21 import java.util.ArrayList ; 22 import java.util.Collection ; 23 import java.util.List ; 24 25 import org.netbeans.modules.xslt.model.Attribute; 26 import org.netbeans.modules.xslt.model.Choose; 27 import org.netbeans.modules.xslt.model.Otherwise; 28 import org.netbeans.modules.xslt.model.When; 29 import org.netbeans.modules.xslt.model.XslComponent; 30 import org.netbeans.modules.xslt.model.XslVisitor; 31 import org.w3c.dom.Element ; 32 33 34 38 class ChooseImpl extends SequenceElementImpl implements Choose { 39 40 ChooseImpl( XslModelImpl model, Element element ) { 41 super( model , element ); 42 } 43 44 ChooseImpl( XslModelImpl model ){ 45 super( model , XslElements.CHOOSE ); 46 } 47 48 49 52 @Override 53 public void accept( XslVisitor visitor ) 54 { 55 visitor.visit( this ); 56 } 57 58 61 @Override 62 public Class <? extends XslComponent> getComponentType() 63 { 64 return Choose.class; 65 } 66 67 70 public void addWhen( When when, int position ) { 71 insertAtIndex( WHEN_PROPERTY, when, position, 72 Attribute.class ); 73 } 74 75 78 public void appendWhen( When when ) { 79 addBefore( WHEN_PROPERTY, when, OTHERWISE_COLLECTION ); 80 } 81 82 85 public Otherwise getOtherwise() { 86 return getChild( Otherwise.class ); 87 } 88 89 92 public List <When> getWhens() { 93 return getChildren( When.class ); 94 } 95 96 99 public void removeWhen( When when ) { 100 removeChild( WHEN_PROPERTY , when); 101 } 102 103 106 public void setOtherwise( Otherwise otherwise ) { 107 setChildBefore( Otherwise.class , OTHERWISE_PROPERTY , otherwise , EMPTY ); 108 } 109 110 private static final Collection <Class <? extends XslComponent>> 111 OTHERWISE_COLLECTION = new ArrayList <Class <? extends XslComponent>>(1); 112 113 static { 114 OTHERWISE_COLLECTION.add( Otherwise.class ); 115 } 116 } 117 | Popular Tags |