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:
042: package org.netbeans.modules.schema2beansdev;
043:
044: import java.io.*;
045: import java.util.*;
046:
047: import org.netbeans.modules.schema2beans.*;
048: import org.netbeans.modules.schema2beansdev.metadd.*;
049:
050: public interface CodeGeneratorClass {
051: /**
052: * This method is called by the BeanBuilder to register a new property
053: * on this bean class.
054: */
055: AbstractCodeGeneratorClass.Property addProperty(String name,
056: String dtdName, String namespace, GraphNode node,
057: GraphLink l, String classType, int nestedLevel,
058: int eltInstance, int groupInstance, int type, boolean ored,
059: AttrProp[] propAttributes, String constName,
060: String defaultValue, boolean directChild, List extraData,
061: boolean isUnion);
062:
063: List/*<AbstractCodeGeneratorClass.Property>*/getPropertyList();
064:
065: void setPackageName(String n);
066:
067: /**
068: * The string that is used for indentation.
069: */
070: void setIndent(String indent);
071:
072: /**
073: * Generate the java code in the out stream, using the optional
074: * metaDD bean graph.
075: */
076: void generate(String filename, MetaDD mdd) throws IOException;
077:
078: /**
079: * Generate the java code in the out stream, using the optional
080: * metaDD bean graph.
081: */
082: void generate(OutputStream out, MetaDD mdd) throws IOException;
083:
084: public void generateDelegator(OutputStream out, MetaDD mdd,
085: String delegatorClassName, String delegatorPackageName)
086: throws IOException;
087:
088: /**
089: * The generator should put in an entry for every name that is
090: * invalid to use as a property name.
091: *
092: * @param invalidNames is a
093: * Map<String, BeanElement> where they key is the invalid name and
094: * the value (BeanElement) is most likely null.
095: * For instance, anything that inherits from java.lang.Object will
096: * not be able to generate a getClass method, so the property
097: * named "Class" is invalid.
098: * Typically, the invalid method names are due to a parent class
099: * already having a method of that name with the same parameters
100: * (overloading is okay though). A property X is invalid if a
101: * parent class already has a getX(); and if X might
102: * ever be an array, then also getX(int) or sizeX().
103: */
104: public void setInvalidPropertyNames(Map invalidNames);
105:
106: public void setRootBeanElement(BeanBuilder.BeanElement element);
107:
108: /**
109: * Set the namespace that will be used by default in the documents.
110: */
111: public void setDefaultNamespace(String ns);
112:
113: public Collection getGeneratedMethods(); // Collection<JavaWriter.Method>
114:
115: /**
116: * Print out the bean graph.
117: */
118: public void dumpBeanTree(java.io.Writer out, String indent,
119: String indentBy) throws java.io.IOException;
120:
121: public void setPrefixGuesser(PrefixGuesser guesser);
122: }
|