Configuration bean for <description> element.
// Merge "top" into "old"
static void mergeFeatures(FeatureBean top, FeatureBean old) {
DescriptionBean db[] = top.getDescriptions();
for (int i = 0; i < db.length; i++) {
DescriptionBean dbo = old.getDescription(db[i].getLang());
if (dbo == null) {
old.addDescription(db[i]);
} else {
mergeDescription(db[i], dbo);
}
lang = attributes.getValue("xml:lang"); // If digester not ns-aware
}
if (lang == null) {
lang = ""; // Avoid NPE errors on sorted map comparisons
}
DescriptionBean db = fb.getDescription(lang);
if (db == null) {
if (digester.getLogger().isDebugEnabled()) {
digester.getLogger().debug("[DescriptionRule]{" +
digester.getMatch() +
"} New (" + lang + ")");
}
Class clazz =
digester.getClassLoader().loadClass(CLASS_NAME);
db = (DescriptionBean) clazz.newInstance();
db.setLang(lang);
fb.addDescription(db);
} else {
if (digester.getLogger().isDebugEnabled()) {
digester.getLogger().debug("[DescriptionRule]{" +
digester.getMatch() +
* @exception IllegalStateException if the popped object is not
* of the correct type
*/
public void end(String namespace, String name) throws Exception {
DescriptionBean top = null;
try {
top = (DescriptionBean) digester.pop();
} catch (Exception e) {
throw new IllegalStateException("Popped object is not a " +
CLASS_NAME + " instance");
}
if (digester.getLogger().isDebugEnabled()) {
digester.getLogger().debug("[DescriptionRule]{" +
digester.getMatch() +
"} Pop (" + top.getLang() + ")");
}
}
// NodeCreateRule that won't be fixed until version 1.6 of
// commons-digester is released)
Node root = (Node) digester.pop();
// Serialize the child nodes into a StringBuffer
DescriptionBean db = (DescriptionBean) digester.peek();
StringBuffer sb = new StringBuffer();
NodeList kids = root.getChildNodes();
int n = kids.getLength();
for (int i = 0; i < n; i++) {
serialize(sb, kids.item(i));
}
// Use the StringBuffer to set the value of the description property
db.setDescription(sb.toString());
}
public void setManagedBeanFactoryMap(Map<String,ManagedBeanFactory> newManagedBeanFactoryMap) {
managedBeanFactoryMap = newManagedBeanFactoryMap;
}
public String getBeanDescription(String lang) {
DescriptionBean db = managedBean.getDescription(lang);
if (db != null) {
return db.getDescription();
}
return null;
}
ManagedBeanBean managedBean = managedBeanFactory.getManagedBeanBean();
if ( managedBean != null) {
Locale curLocale = Util.getLocaleFromContextOrSystem(facesContext);
String locale = curLocale.toString();
DescriptionBean descBean = managedBean.getDescription(locale);
String desc = "";
descBean = (null != descBean) ? descBean :
managedBean.getDescription("");
if (null != descBean) {
// handle the case where the lang or xml:lang attributes
// are not specified on the description
desc = descBean.getDescription();
}
list.add(Util.getFeatureDescriptor(managedBeanName,
managedBeanName, desc, false, false, true,
managedBeanFactory.getManagedBeanClass(), Boolean.TRUE));
}
String var = entry.getKey();
ResourceBundleBean resourceBundleBean = entry.getValue();
if ( resourceBundleBean != null) {
Locale curLocale = Util.getLocaleFromContextOrSystem(facesContext);
String locale = curLocale.toString();
DescriptionBean descBean =
resourceBundleBean.getDescription(locale);
DisplayNameBean displayNameBean =
resourceBundleBean.getDisplayName(locale);
String desc = "",
displayName = "";
descBean = (null != descBean) ? descBean :
resourceBundleBean.getDescription("");
if (null != descBean) {
// handle the case where the lang or xml:lang attributes
// are not specified on the description
desc = descBean.getDescription();
}
displayNameBean = (null != displayNameBean) ? displayNameBean :
resourceBundleBean.getDisplayName("");
if (null != displayNameBean) {
displayName = displayNameBean.getDisplayName();
if (renderKit == null) {
throw new IllegalStateException("no RenderKits");
}
}
DescriptionBean descBean = renderKit.getDescription("");
String description = (null == descBean) ?
"" : descBean.getDescription();
sb.append("<P>" + description + "</P>\n");
sb.append("<P />");
sb.append(
"<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\" WIDTH=\"100%\">");
sb.append("<TR BGCOLOR=\"#CCCCFF\" CLASS=\"TableHeadingColor\">\n");
sb.append("<TD COLSPAN=\"3\"><FONT SIZE=\"+2\">\n");
sb.append("<B>Renderer Summary</B></FONT></TD>\n");
sb.append("\n");
sb.append("<TR>\n");
sb.append("<TH>component-family</TH>\n");
sb.append("<TH>renderer-type</TH>\n");
sb.append("<TH>description</TH>\n");
sb.append("</TR>\n");
Map<String,ArrayList<RendererBean>> renderersByComponentFamily =
GeneratorUtil.getComponentFamilyRendererMap(configBean, renderKitId);
for (Map.Entry entry : renderersByComponentFamily.entrySet()) {
String curFamily = (String)entry.getKey();
List<RendererBean> renderers = (List<RendererBean>) entry.getValue();
sb.append(" <TR>\n");
sb.append(" <TD rowspan=\"" + renderers.size() + "\">" +
curFamily + "</TD>\n");
for (Iterator<RendererBean> rendererIter = renderers.iterator();
rendererIter.hasNext(); ) {
RendererBean renderer = rendererIter.next();
String curType = renderer.getRendererType();
sb.append(" <TD><A HREF=\"" + curFamily + curType +
".html\" TARGET=\"rendererFrame\">" + curType +
"</A></TD>\n");
descBean = renderer.getDescription("");
description = (null == descBean) ?
"" : descBean.getDescription();
sb.append(" <TD>" + getFirstSentance(description) +
"</TD>");
if (rendererIter.hasNext()) {
sb.append(" </TR>\n");
sb.append(" <TR>\n");
private void generateRenderersDocs() throws Exception {
StringBuffer sb;
RenderKitBean renderKit;
DescriptionBean descBean;
String description;
String rendererType;
String componentFamily;
String defaultValue;
String title;
// generate the docus for each renderer
if (null == (renderKit = configBean.getRenderKit(renderKitId))) {
RenderKitBean[] kits = configBean.getRenderKits();
if (kits == null) {
throw new IllegalStateException("no RenderKits");
}
renderKit = kits[0];
if (renderKit == null) {
throw new IllegalStateException("no RenderKits");
}
}
RendererBean[] renderers = renderKit.getRenderers();
AttributeBean[] attributes;
sb = new StringBuffer(2048);
for (int i = 0, len = renderers.length; i < len; i++) {
if (null == renderers[i]) {
throw new IllegalStateException("null Renderer at index: " + i);
}
attributes = renderers[i].getAttributes();
sb.append(DOCTYPE + "\n");
sb.append("<html>\n");
sb.append("<head>\n");
// PENDING timestamp
sb.append("<title>\n");
title = "<font size=\"-1\">component-family:</font> " +
(componentFamily = renderers[i].getComponentFamily()) +
" <font size=\"-1\">renderer-type:</font> " +
(rendererType = renderers[i].getRendererType());
sb.append(title + "\n");
sb.append("</title>\n");
// PENDING META tag
sb.append(
"<link REL =\"stylesheet\" TYPE=\"text/css\" HREF=\"../stylesheet.css\" TITLE=\"Style\">\n");
sb.append("</head>\n");
sb.append("<script>\n");
sb.append("function asd()\n");
sb.append("{\n");
sb.append(" parent.document.title=" + title + "\n");
sb.append("}\n");
sb.append("</SCRIPT>\n");
sb.append("<body BGCOLOR=\"white\" onload=\"asd();\">\n");
sb.append("\n");
sb.append("<H2><font size=\"-1\">" + renderKitId +
" render-kit</font>\n");
sb.append("<br />\n");
sb.append(title + "\n");
sb.append("</H2>\n");
sb.append("<HR />\n");
descBean = renderers[i].getDescription("");
description = (null == descBean) ? "" : descBean.getDescription();
sb.append("<P>" + description + "</P>\n");
// render our renders children status
if (renderers[i].isRendersChildren()) {
sb.append(
"<P>This renderer is responsible for rendering its children.</P>");
} else {
sb.append(
"<P>This renderer is not responsible for rendering its children.</P>");
}
// if we have attributes
if ((null == attributes) || (0 < attributes.length)) {
sb.append("<HR />\n");
sb.append("<a NAME=\"attributes\"><!-- --></a>\n");
sb.append("\n");
sb.append("<h3>Note:</h3>\n");
sb.append("\n");
sb.append(
"<p>Attributes with a <code>pass-through</code> value of\n");
sb.append(
"<code>true</code> are not interpreted by the renderer and are passed\n");
sb.append(
"straight through to the rendered markup, without checking for validity. Attributes with a\n");
sb.append(
"<code>pass-through</code> value of <code>false</code> are interpreted\n");
sb.append(
"by the renderer, and may or may not be checked for validity by the renderer.</p>\n");
sb.append("\n");
sb.append(
"<table BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\" WIDTH=\"100%\">\n");
sb.append(
"<tr BGCOLOR=\"#CCCCFF\" CLASS=\"TableHeadingColor\">\n");
sb.append("<td COLSPAN=\"5\"><font SIZE=\"+2\">\n");
sb.append("<b>Attributes</b></font></td>\n");
sb.append("</tr>\n");
sb.append(
"<tr BGCOLOR=\"#CCCCFF\" CLASS=\"TableHeadingColor\">\n");
sb.append("<th><b>attribute-name</b></th>\n");
sb.append("<th><b>pass-through</b></th>\n");
sb.append("<th><b>attribute-class</b></th>\n");
sb.append("<th><b>description</b></th>\n");
sb.append("<th><b>default-value</b></th>\n");
sb.append("</tr>\n");
sb.append(" \n");
// output each attribute
if (attributes != null) {
for (int j = 0, attrLen = attributes.length; j < attrLen; j++) {
if (attributes[j].isAttributeIgnoredForRenderer()) {
continue;
}
sb.append(
"<tr BGCOLOR=\"white\" CLASS=\"TableRowColor\">\n");
sb.append(
"<td ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><code>\n");
sb.append(
" " + attributes[j].getAttributeName() + "\n");
sb.append("</td>\n");
sb.append("<td ALIGN=\"right\" VALIGN=\"top\">" +
attributes[j].isPassThrough() + "</td>\n");
sb.append("<td><code>" + attributes[j].getAttributeClass() +
"</code></td>\n");
descBean = attributes[j].getDescription("");
description = (null == descBean) ?
"" : descBean.getDescription();
sb.append("<td>" + description + "</td>\n");
if (null ==
(defaultValue = attributes[j].getDefaultValue())) {
defaultValue = "undefined";
}
writer.writeBlockComment("******* GENERATED CODE - DO NOT EDIT *******");
writer.write("\n\n");
// Generate the class JavaDocs (if any)
DescriptionBean db = cb.getDescription("");
String rendererType = cb.getRendererType();
String description = null;
if (db != null) {
description = db.getDescription().trim();
}
if (rendererType != null) {
if (description == null) {
description = "";
Related Classes of com.sun.faces.config.beans.DescriptionBean
Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.