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.upgrade.systemoptions;
043:
044: import java.util.HashMap;
045: import java.util.Iterator;
046: import java.util.Map;
047:
048: /**
049: *
050: * @author rmatous
051: */
052: public class JUnitContentProcessor extends ContentProcessor {
053: protected JUnitContentProcessor(String systemOptionInstanceName) {
054: super (systemOptionInstanceName);
055: }
056:
057: protected Result parseContent(final Iterator<Object> it,
058: boolean types) {
059: Map<String, String> properties = new HashMap<String, String>();
060: assert it.hasNext();
061: Object o = it.next();
062: assert o.getClass().equals(SerParser.ObjectWrapper.class);
063: SerParser.ObjectWrapper ow = (SerParser.ObjectWrapper) o;
064: assert Utils.getClassNameFromObject(ow).equals(
065: "java.lang.Integer") : Utils.getClassNameFromObject(ow);//NOI18N
066: properties.put("version", ((types) ? Utils
067: .getClassNameFromObject(ow) : Utils
068: .valueFromObjectWrapper(ow)));//NOI18N
069: assert it.hasNext();
070: o = it.next();
071: assert o.getClass().equals(String.class);
072: properties.put("fileSystem", ((types) ? "java.lang.String"
073: : (String) o));//NOI18N
074: o = it.next();
075: assert o.getClass().equals(SerParser.ObjectWrapper.class);
076: ow = (SerParser.ObjectWrapper) o;
077: assert Utils.getClassNameFromObject(ow).equals(
078: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N
079: properties.put("membersPublic", ((types) ? Utils
080: .getClassNameFromObject(ow) : Utils
081: .valueFromObjectWrapper(ow)));//NOI18N
082: o = it.next();
083: assert o.getClass().equals(SerParser.ObjectWrapper.class);
084: ow = (SerParser.ObjectWrapper) o;
085: assert Utils.getClassNameFromObject(ow).equals(
086: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);
087: properties.put("membersProtected", ((types) ? Utils
088: .getClassNameFromObject(ow) : Utils
089: .valueFromObjectWrapper(ow)));//NOI18N
090: o = it.next();
091: assert o.getClass().equals(SerParser.ObjectWrapper.class);
092: ow = (SerParser.ObjectWrapper) o;
093: assert Utils.getClassNameFromObject(ow).equals(
094: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N
095: properties.put("membersPackage", ((types) ? Utils
096: .getClassNameFromObject(ow) : Utils
097: .valueFromObjectWrapper(ow)));//NOI18N
098: o = it.next();
099: assert o.getClass().equals(SerParser.ObjectWrapper.class);
100: ow = (SerParser.ObjectWrapper) o;
101: assert Utils.getClassNameFromObject(ow).equals(
102: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N
103: properties.put("bodyComments", ((types) ? Utils
104: .getClassNameFromObject(ow) : Utils
105: .valueFromObjectWrapper(ow)));//NOI18N
106: o = it.next();
107: assert o.getClass().equals(SerParser.ObjectWrapper.class);
108: ow = (SerParser.ObjectWrapper) o;
109: assert Utils.getClassNameFromObject(ow).equals(
110: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N
111: properties.put("bodyContent", ((types) ? Utils
112: .getClassNameFromObject(ow) : Utils
113: .valueFromObjectWrapper(ow)));//NOI18N
114: o = it.next();
115: assert o.getClass().equals(SerParser.ObjectWrapper.class);
116: ow = (SerParser.ObjectWrapper) o;
117: assert Utils.getClassNameFromObject(ow).equals(
118: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N
119: properties.put("javaDoc", ((types) ? Utils
120: .getClassNameFromObject(ow) : Utils
121: .valueFromObjectWrapper(ow)));//NOI18N
122: o = it.next();
123: assert o.getClass().equals(SerParser.ObjectWrapper.class);
124: ow = (SerParser.ObjectWrapper) o;
125: assert Utils.getClassNameFromObject(ow).equals(
126: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N
127: properties.put("generateAbstractImpl", ((types) ? Utils
128: .getClassNameFromObject(ow) : Utils
129: .valueFromObjectWrapper(ow)));//NOI18N
130: o = it.next();
131: assert o.getClass().equals(SerParser.ObjectWrapper.class);
132: ow = (SerParser.ObjectWrapper) o;
133: assert Utils.getClassNameFromObject(ow).equals(
134: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N
135: properties.put("generateExceptionClasses", ((types) ? Utils
136: .getClassNameFromObject(ow) : Utils
137: .valueFromObjectWrapper(ow)));//NOI18N
138: o = it.next();
139: assert o.getClass().equals(SerParser.ObjectWrapper.class);
140: ow = (SerParser.ObjectWrapper) o;
141: assert Utils.getClassNameFromObject(ow).equals(
142: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N
143: properties.put("generateSuiteClasses", ((types) ? Utils
144: .getClassNameFromObject(ow) : Utils
145: .valueFromObjectWrapper(ow)));//NOI18N
146: o = it.next();
147: assert o.getClass().equals(SerParser.ObjectWrapper.class);
148: ow = (SerParser.ObjectWrapper) o;
149: assert Utils.getClassNameFromObject(ow).equals(
150: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N
151: properties.put("includePackagePrivateClasses", ((types) ? Utils
152: .getClassNameFromObject(ow) : Utils
153: .valueFromObjectWrapper(ow)));//NOI18N
154: o = it.next();
155: assert o.getClass().equals(SerParser.ObjectWrapper.class);
156: ow = (SerParser.ObjectWrapper) o;
157: assert Utils.getClassNameFromObject(ow).equals(
158: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N
159: properties.put("generateMainMethod", ((types) ? Utils
160: .getClassNameFromObject(ow) : Utils
161: .valueFromObjectWrapper(ow)));//NOI18N
162: o = it.next();
163: assert o.getClass().equals(String.class);
164: properties.put("generateMainMethodBody",
165: ((types) ? "java.lang.String" : (String) o));//NOI18N
166: o = it.next();
167: assert o.getClass().equals(String.class);
168: properties.put("rootSuiteClassName",
169: ((types) ? "java.lang.String" : (String) o));//NOI18N
170: o = it.next();
171: assert o.getClass().equals(SerParser.ObjectWrapper.class);
172: ow = (SerParser.ObjectWrapper) o;
173: assert Utils.getClassNameFromObject(ow).equals(
174: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N
175: properties.put("generateSetUp", ((types) ? Utils
176: .getClassNameFromObject(ow) : Utils
177: .valueFromObjectWrapper(ow)));//NOI18N
178: o = it.next();
179: assert o.getClass().equals(SerParser.ObjectWrapper.class);
180: ow = (SerParser.ObjectWrapper) o;
181: assert Utils.getClassNameFromObject(ow).equals(
182: "java.lang.Boolean") : Utils.getClassNameFromObject(ow);//NOI18N
183: properties.put("generateTearDown", ((types) ? Utils
184: .getClassNameFromObject(ow) : Utils
185: .valueFromObjectWrapper(ow)));//NOI18N
186:
187: return new DefaultResult(systemOptionInstanceName, properties);
188: }
189: }
|