WebHelperMethodCreator.java revision 4a2f0f0be43dfd4c1b490cbf3cc48b6ba6084b1c
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: WebHelperMethodCreator.java,v 1.3 2008/06/25 05:49:54 qcheng Exp $
*
*/
/**
* This class is responsible for generating the method for each CLI sub
* command.
*/
public class WebHelperMethodCreator {
private String description;
private String methodName;
) {
this.description = description;
}
while (idx != -1) {
}
return name;
}
if (t.countTokens() == 2) {
}
}
if (idxWeb != -1) {
} else {
}
if (unary) {
} else if (single) {
}
}
}
}
}
.append("(\n");
}
.append("\n *\n");
" * @param webClient HTML Unit Web Client object.\n");
.append(" ")
.append("\n");
}
}
}
if (isTextareaUI(opt)) {
} else if (isCheckboxUI(opt)) {
} else {
}
}
}
}
scmdName + "\");\n");
" HtmlPage page = (HtmlPage)webClient.getPage(cmdUrl);\n");
" HtmlForm form = (HtmlForm)page.getForms().get(0);\n\n");
if (isTextareaUI(opt)) {
.append("\n");
} else if (isCheckboxUI(opt)) {
.append("\n");
.append("\n");
} else {
.append("\n");
}
}
}
}
}
}
}
}
private static final String TEXTAREA_TEMPLATE =
" if (@opt@ != null) {\n" +
" HtmlTextArea ta@opt@ = " +
"(HtmlTextArea)form.getTextAreasByName(\"@opt@\").get(0);\n" +
" ta@opt@.setText(@opt@);\n" +
" }\n";
private static final String STRING_TEMPLATE =
" if (@opt@ != null) {\n" +
" HtmlTextInput txt@opt@ = " +
"(HtmlTextInput)form.getInputByName(\"@opt@\");\n" +
" txt@opt@.setValueAttribute(@opt@);\n" +
" }\n";
private static final String BOOLEAN_TEMPLATE =
" HtmlCheckBoxInput cb@opt@ = " +
"(HtmlCheckBoxInput)form.getInputByName(\"@opt@\");\n" +
" cb@opt@.setChecked(@opt@);\n";
private static final String LIST_TEMPLATE =
" if (@opt@ != null) {\n" +
" HtmlSelect sl@opt@= " +
"(HtmlSelect)form.getSelectByName(\"@opt@\");\n" +
" String[] fakeOptions = new String[@opt@.size()];\n" +
" int cnt = 0;\n" +
" for (Iterator i = @opt@.iterator(); i.hasNext(); ) {\n" +
" fakeOptions[cnt++] = (String)i.next();\n" +
" }\n" +
" sl@opt@.fakeSelectedAttribute(fakeOptions);\n" +
" }\n";
}