001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019: package org.netbeans.modules.xslt.model.impl;
020:
021: import java.util.ArrayList;
022: import java.util.Collection;
023: import java.util.List;
024:
025: import org.netbeans.modules.xslt.model.Attribute;
026: import org.netbeans.modules.xslt.model.Choose;
027: import org.netbeans.modules.xslt.model.Otherwise;
028: import org.netbeans.modules.xslt.model.When;
029: import org.netbeans.modules.xslt.model.XslComponent;
030: import org.netbeans.modules.xslt.model.XslVisitor;
031: import org.w3c.dom.Element;
032:
033: /**
034: * @author ads
035: *
036: */
037: class ChooseImpl extends SequenceElementImpl implements Choose {
038:
039: ChooseImpl(XslModelImpl model, Element element) {
040: super (model, element);
041: }
042:
043: ChooseImpl(XslModelImpl model) {
044: super (model, XslElements.CHOOSE);
045: }
046:
047: /* (non-Javadoc)
048: * @see org.netbeans.modules.xslt.model.impl.XslComponentImpl#accept(org.netbeans.modules.xslt.model.XslVisitor)
049: */
050: @Override
051: public void accept(XslVisitor visitor) {
052: visitor.visit(this );
053: }
054:
055: /* (non-Javadoc)
056: * @see org.netbeans.modules.xslt.model.impl.XslComponentImpl#getComponentType()
057: */
058: @Override
059: public Class<? extends XslComponent> getComponentType() {
060: return Choose.class;
061: }
062:
063: /* (non-Javadoc)
064: * @see org.netbeans.modules.xslt.model.Choose#addWhen(org.netbeans.modules.xslt.model.When, int)
065: */
066: public void addWhen(When when, int position) {
067: insertAtIndex(WHEN_PROPERTY, when, position, Attribute.class);
068: }
069:
070: /* (non-Javadoc)
071: * @see org.netbeans.modules.xslt.model.Choose#appendWhen(org.netbeans.modules.xslt.model.When)
072: */
073: public void appendWhen(When when) {
074: addBefore(WHEN_PROPERTY, when, OTHERWISE_COLLECTION);
075: }
076:
077: /* (non-Javadoc)
078: * @see org.netbeans.modules.xslt.model.Choose#getOtherwise()
079: */
080: public Otherwise getOtherwise() {
081: return getChild(Otherwise.class);
082: }
083:
084: /* (non-Javadoc)
085: * @see org.netbeans.modules.xslt.model.Choose#getWhens()
086: */
087: public List<When> getWhens() {
088: return getChildren(When.class);
089: }
090:
091: /* (non-Javadoc)
092: * @see org.netbeans.modules.xslt.model.Choose#removeWhen(org.netbeans.modules.xslt.model.When)
093: */
094: public void removeWhen(When when) {
095: removeChild(WHEN_PROPERTY, when);
096: }
097:
098: /* (non-Javadoc)
099: * @see org.netbeans.modules.xslt.model.Choose#setOtherwise(org.netbeans.modules.xslt.model.Otherwise)
100: */
101: public void setOtherwise(Otherwise otherwise) {
102: setChildBefore(Otherwise.class, OTHERWISE_PROPERTY, otherwise,
103: EMPTY);
104: }
105:
106: private static final Collection<Class<? extends XslComponent>> OTHERWISE_COLLECTION = new ArrayList<Class<? extends XslComponent>>(
107: 1);
108:
109: static {
110: OTHERWISE_COLLECTION.add(Otherwise.class);
111: }
112: }
|