001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.vmd.api.codegen;
042:
043: import org.netbeans.modules.vmd.api.model.DesignComponent;
044:
045: /**
046: * Represents a parameter of a setter.
047: *
048: * @author David Kaspar
049: */
050: public interface Parameter {
051:
052: public static final String PARAM_INDEX = "#INDEX#"; // NOI18N
053:
054: /**
055: * Returns a name of the parameter.
056: * @return the parameter name
057: */
058: String getParameterName();
059:
060: /**
061: * Returns a priority of the parameter while a duplicate parameters are found.
062: * The highest priority parameter overrides other parameters with the same name.
063: * @return the parameter priority; 0 is normal
064: */
065: int getParameterPriority();
066:
067: /**
068: * Generates a parameter code for the parameter.
069: * @param component the related component
070: * @param section where the code has to be generated
071: * @param index index of the array which is used in related setter; -1 when there is no array in related setter used
072: */
073: void generateParameterCode(DesignComponent component,
074: MultiGuardedSection section, int index);
075:
076: /**
077: * Returns whether the parameter is required to be set.
078: * @param component the related component
079: * @return true, if required to be set
080: */
081: boolean isRequiredToBeSet(DesignComponent component);
082:
083: /**
084: * Returns how many times the setter has to be used to set all values
085: * @param component the related component
086: * @return the usage count; -1 if non-array setter
087: */
088: int getCount(DesignComponent component);
089:
090: /**
091: * Returns whether the parameter required to be set for a particular index.
092: * @param component the related component
093: * @param index the setter index
094: * @return true, if required to be set
095: */
096: boolean isRequiredToBeSet(DesignComponent component, int index);
097:
098: static final Parameter INDEX = new Parameter() {
099:
100: public String getParameterName() {
101: return PARAM_INDEX;
102: }
103:
104: public int getParameterPriority() {
105: return 0;
106: }
107:
108: public void generateParameterCode(DesignComponent component,
109: MultiGuardedSection section, int index) {
110: section.getWriter().write(Integer.toString(index));
111: }
112:
113: public boolean isRequiredToBeSet(DesignComponent component) {
114: return false;
115: }
116:
117: public int getCount(DesignComponent component) {
118: return -1;
119: }
120:
121: public boolean isRequiredToBeSet(DesignComponent component,
122: int index) {
123: return false;
124: }
125:
126: };
127:
128: }
|