JBoss Rich Faces SVN: r1595 - trunk/docs/ajaxguide/en/src/main/docbook.
by richfaces-svn-commits@lists.jboss.org
Author: vkorluzhenko
Date: 2007-07-11 08:00:11 -0400 (Wed, 11 Jul 2007)
New Revision: 1595
Modified:
trunk/docs/ajaxguide/en/src/main/docbook/master.xml
Log:
http://jira.jboss.com/jira/browse/AJSF-102
Modified: trunk/docs/ajaxguide/en/src/main/docbook/master.xml
===================================================================
--- trunk/docs/ajaxguide/en/src/main/docbook/master.xml 2007-07-11 00:20:34 UTC (rev 1594)
+++ trunk/docs/ajaxguide/en/src/main/docbook/master.xml 2007-07-11 12:00:11 UTC (rev 1595)
@@ -30,10 +30,10 @@
&envSettings;
&getttingStarted;
&usingAJAX;
- <chapter>
-
- <title>Ajax4jsf components</title>
- &componentDetails;
+ <chapter>
+ <?dbhtml filename="AjaxComponentsLibrary.html"?>
+ <title>Ajax4jsf components</title>
+ &componentDetails;
</chapter>
&skinnability;
&IDEintegration;
18 years, 2 months
JBoss Rich Faces SVN: r1594 - in trunk: cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder and 72 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-10 20:20:34 -0400 (Tue, 10 Jul 2007)
New Revision: 1594
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/PrototypeScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/SmartPositionScript.java
trunk/framework/impl/src/main/resources/org/ajax4jsf/cache/
trunk/framework/impl/src/main/resources/org/ajax4jsf/cache/oscache.properties
trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/
trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/jsshell.html
trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/
trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/command.js
trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/form.js
trunk/framework/impl/src/main/resources/org/ajax4jsf/messages.properties
trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/
trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/output.properties
trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/tidy/
trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/tidy/tidy.properties
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java
trunk/framework/impl/src/main/resources/org/ajax4jsf/framework/
trunk/framework/impl/src/main/resources/org/ajax4jsf/renderkit/
trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/tidy/tidy.properties
Modified:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/RendererBean.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/AbstractCompilationContext.java
trunk/cdk/generator/src/main/resources/META-INF/templates/renderer.vm
trunk/cdk/generator/src/main/resources/META-INF/templates/templatecompiler/ComponentTemplate.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/renderer.vm
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/renderkit/portlet/PortletAjaxViewRootRenderer.java
trunk/framework/api/src/main/java/org/ajax4jsf/Messages.java
trunk/framework/impl/generatescript.xml
trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/DnDScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/PrototypeBasedRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java
trunk/framework/impl/src/main/resources/META-INF/resources-config.xml
trunk/framework/impl/src/main/resources/META-INF/services/org.richfaces.skin.SkinFactory
trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoParserTest.java
trunk/sandbox/samples/scrollable-grid-demo/src/main/webapp/WEB-INF/lib/ajax4jsf-1.1.2-SNAPSHOT.jar
trunk/sandbox/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
trunk/sandbox/tooltip/src/main/templates/org/richfaces/htmltooltip.jspx
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
trunk/sandbox/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
trunk/sandbox/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
trunk/sandbox/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx
trunk/sandbox/ui/panelmenu/src/test/java/org/richfaces/component/PanelMenuComponentTest.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/utils/TemplateLoader.java
trunk/sandbox/ui/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
trunk/sandbox/ui/scrollable-grid/src/test/java/org/richfaces/renderkit/html/ScrollableGridRendererTest.java
trunk/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/component/UISimpleTogglePanel2.java
trunk/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanel2Renderer.java
trunk/sandbox/ui/simpleTogglePanel2/src/main/templates/simpleTogglePanel2.jspx
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
trunk/ui/dataFilterSlider/src/main/templates/dataFilterSlider.jspx
trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractDefinitionListRenderer.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractListRenderer.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
trunk/ui/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java
trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
trunk/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java
trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
trunk/ui/datascroller/src/test/java/org/richfaces/component/DatascrollerComponentTest.java
trunk/ui/drag-drop/src/main/java/org/richfaces/component/UIDragIndicator.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
trunk/ui/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx
trunk/ui/drag-drop/src/test/java/org/richfaces/component/DragDropTest.java
trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java
trunk/ui/gmap/src/main/templates/gmap.jspx
trunk/ui/gmap/src/test/java/org/richfaces/component/GmapComponentTest.java
trunk/ui/inputnumber-slider/src/main/templates/inputNumberSlider.jspx
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
trunk/ui/inputnumber-spinner/src/main/templates/inputNumberSpinner.jspx
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuSeparatorComponentTest.java
trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
trunk/ui/modal-panel/src/test/java/org/richfaces/component/ModalPanelComponentTest.java
trunk/ui/panelbar/src/main/java/org/richfaces/component/UIPanelBar.java
trunk/ui/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarItemRendererBase.java
trunk/ui/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarRendererBase.java
trunk/ui/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java
trunk/ui/simpleTogglePanel/src/main/templates/simpleTogglePanel.jspx
trunk/ui/simpleTogglePanel/src/test/java/org/richfaces/component/SimpleTogglePanelComponentTest.java
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
trunk/ui/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java
trunk/ui/tabPanel/src/main/templates/tabPanel.jspx
trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
trunk/ui/togglePanel/src/main/templates/toggleControl.jspx
trunk/ui/togglePanel/src/test/java/org/richfaces/component/TogglePanelComponentTest.java
trunk/ui/tree/src/main/templates/htmlTree.jspx
trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
Log:
Finished packages and classes refactor in the "impl" project
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/RendererBean.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/RendererBean.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/RendererBean.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -64,7 +64,7 @@
*/
public RendererBean() {
super();
- setSuperclass("org.ajax4jsf.framework.renderer.RendererBase");
+ setSuperclass("org.ajax4jsf.renderkit.RendererBase");
}
/**
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/AbstractCompilationContext.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/AbstractCompilationContext.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/AbstractCompilationContext.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -57,7 +57,7 @@
final private static Pattern patternComponent = Pattern.compile(
regexComponent, Pattern.UNIX_LINES + Pattern.DOTALL);
- private final static String DEFAULT_BASE_CLASS = "org.ajax4jsf.framework.renderer.RendererBase";
+ private final static String DEFAULT_BASE_CLASS = "org.ajax4jsf.renderkit.ase";
private String packageName;
@@ -82,8 +82,8 @@
"java.io.IOException", "javax.faces.component.UIComponent",
"javax.faces.context.FacesContext",
"javax.faces.context.ResponseWriter",
- "org.ajax4jsf.framework.renderer.ComponentsVariableResolver",
- "org.ajax4jsf.framework.renderer.ComponentVariables" };
+ "org.ajax4jsf.renderkit.ComponentsVariableResolver",
+ "org.ajax4jsf.renderkit.ComponentVariables" };
private TemplateElement tree;
@@ -354,7 +354,7 @@
addVariable("writer", "javax.faces.context.ResponseWriter");
// addLocalVariable("component", "javax.faces.component.UIComponent" );
addVariable("variables",
- "org.ajax4jsf.framework.renderer.ComponentVariables");
+ "org.ajax4jsf.renderkit.ComponentVariables");
}
public Class getMethodReturnedClass(Class clazz, String methodName,
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates/renderer.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/renderer.vm 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/renderer.vm 2007-07-11 00:20:34 UTC (rev 1594)
@@ -15,7 +15,7 @@
public class ${renderer.simpleClassName} extends ${renderer.superclass} {
/**
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
*/
protected Class getComponentClass() {
// Expected component class for rendering
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates/templatecompiler/ComponentTemplate.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/templatecompiler/ComponentTemplate.vm 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/templatecompiler/ComponentTemplate.vm 2007-07-11 00:20:34 UTC (rev 1594)
@@ -44,14 +44,14 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
-import org.ajax4jsf.framework.renderer.ComponentVariables;
+import org.ajax4jsf.renderkit.ComponentsVariableResolver;
+import org.ajax4jsf.renderkit.ComponentVariables;
#end
#if($component.fullBaseclass)
import $component.fullBaseclass;
#else
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
#end
#if($component.baseclassName)
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/renderer.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/renderer.vm 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/renderer.vm 2007-07-11 00:20:34 UTC (rev 1594)
@@ -15,7 +15,7 @@
public class ${renderer.simpleClassName} extends ${renderer.superclass} {
/**
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
*/
protected Class getComponentClass() {
// Expected component class for rendering
Modified: trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/renderkit/portlet/PortletAjaxViewRootRenderer.java
===================================================================
--- trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/renderkit/portlet/PortletAjaxViewRootRenderer.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/renderkit/portlet/PortletAjaxViewRootRenderer.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -8,10 +8,10 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.AjaxViewRootRenderer;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxViewRootRenderer;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.portlet.context.AbstractExternalContext;
/**
Modified: trunk/framework/api/src/main/java/org/ajax4jsf/Messages.java
===================================================================
--- trunk/framework/api/src/main/java/org/ajax4jsf/Messages.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/framework/api/src/main/java/org/ajax4jsf/Messages.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -25,7 +25,7 @@
import java.util.ResourceBundle;
public class Messages {
- private static final String BUNDLE_NAME = "org.ajax4jsf.framework.util.message.messages";
+ private static final String BUNDLE_NAME = "org.ajax4jsf.messages";
static ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME);
public static final String getMessage(String name) {
Modified: trunk/framework/impl/generatescript.xml
===================================================================
--- trunk/framework/impl/generatescript.xml 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/framework/impl/generatescript.xml 2007-07-11 00:20:34 UTC (rev 1594)
@@ -12,8 +12,8 @@
Assemble all javaScript library files to one AJAXJSF.js
</description>
- <property name="scripts-path" value="org/ajax4jsf/framework/ajax/scripts"></property>
- <property name="prototype-scripts-path" value="org/ajax4jsf/framework/resource/scripts"></property>
+ <property name="scripts-path" value="org/ajax4jsf/javascript/scripts"></property>
+ <property name="prototype-scripts-path" value="org/ajax4jsf/javascript/scripts"></property>
<property name="target-dir" value="${project.build.directory}/javascript"></property>
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/DnDScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/DnDScript.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/DnDScript.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -33,7 +33,7 @@
* @see org.ajax4jsf.resource.ClientScript#getJavaScript()
*/
public String getJavaScript() {
- return "/org/ajax4jsf/framework/ajax/scripts/dnd.js";
+ return "scripts/dnd.js";
}
/* (non-Javadoc)
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/PrototypeScript.java (from rev 1590, trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/PrototypeScript.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/PrototypeScript.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -0,0 +1,38 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.javascript;
+
+import org.ajax4jsf.resource.ClientScript;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:59 $
+ *
+ */
+public class PrototypeScript extends ClientScript {
+
+ public String getJavaScript() {
+ return "scripts/prototype.js";
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/SmartPositionScript.java (from rev 1590, trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/SmartPositionScript.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/SmartPositionScript.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -0,0 +1,45 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.javascript;
+
+import org.ajax4jsf.resource.ClientScript;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SmartPositionScript extends ClientScript {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ClientScript#getJavaScript()
+ */
+ public String getJavaScript() {
+ // TODO Auto-generated method stub
+ return "scripts/smartposition.js";
+ }
+
+ protected boolean isUsePrototype() {
+
+ return true;
+ }
+
+}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/PrototypeBasedRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/PrototypeBasedRendererBase.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/PrototypeBasedRendererBase.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -26,9 +26,9 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.javascript.PrototypeScript;
import org.ajax4jsf.renderkit.HeaderResourceProducer;
import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.PrototypeScript;
/**
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -28,6 +28,7 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.Messages;
+import org.ajax4jsf.javascript.PrototypeScript;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceContext;
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -1,36 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.resource;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:59 $
- *
- */
-public class PrototypeScript extends ClientScript {
-
- public String getJavaScript() {
- return "scripts/prototype.js";
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -1,43 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.resource;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class SmartPositionScript extends ClientScript {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ClientScript#getJavaScript()
- */
- public String getJavaScript() {
- // TODO Auto-generated method stub
- return "scripts/smartposition.js";
- }
-
- protected boolean isUsePrototype() {
-
- return true;
- }
-
-}
Modified: trunk/framework/impl/src/main/resources/META-INF/resources-config.xml
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/resources-config.xml 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/framework/impl/src/main/resources/META-INF/resources-config.xml 2007-07-11 00:20:34 UTC (rev 1594)
@@ -6,7 +6,7 @@
<resource class="org.ajax4jsf.javascript.AjaxScript">
<name>ajax.js</name>
</resource>
- <resource class="org.ajax4jsf.resource.PrototypeScript">
+ <resource class="org.ajax4jsf.javascript.PrototypeScript">
<name>prototype.js</name>
</resource>
<resource class="org.ajax4jsf.javascript.DnDScript">
@@ -14,12 +14,12 @@
</resource>
<resource >
<name>form.js</name>
- <path>/org/ajax4jsf/renderkit/html/scripts/form.js</path>
+ <path>/org/ajax4jsf/javascript/scripts/form.js</path>
<renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
</resource>
<resource >
<name>org/ajax4jsf/renderers/ajax/scripts/form.js</name>
- <path>/org/ajax4jsf/renderkit/html/scripts/form.js</path>
+ <path>/org/ajax4jsf/javascript/scripts/form.js</path>
<renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
</resource>
</resource-config>
Modified: trunk/framework/impl/src/main/resources/META-INF/services/org.richfaces.skin.SkinFactory
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/services/org.richfaces.skin.SkinFactory 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/framework/impl/src/main/resources/META-INF/services/org.richfaces.skin.SkinFactory 2007-07-11 00:20:34 UTC (rev 1594)
@@ -1 +1 @@
-org.ajax4jsf.framework.skin.SkinFactoryImpl
+org.richfaces.skin.SkinFactoryImpl
Copied: trunk/framework/impl/src/main/resources/org/ajax4jsf/cache/oscache.properties (from rev 1590, trunk/framework/impl/src/main/resources/org/ajax4jsf/framework/ajax/xmlfilter/oscache.properties)
===================================================================
--- trunk/framework/impl/src/main/resources/org/ajax4jsf/cache/oscache.properties (rev 0)
+++ trunk/framework/impl/src/main/resources/org/ajax4jsf/cache/oscache.properties 2007-07-11 00:20:34 UTC (rev 1594)
@@ -0,0 +1,144 @@
+cache.memory = true
+cache.capacity = 10000
+cache.use.host.domain.in.key = true
+
+# CACHE IN MEMORY
+#
+# If you want to disable memory caching, just uncomment this line.
+#
+# cache.memory=false
+
+
+# CACHE KEY
+#
+# This is the key that will be used to store the cache in the application
+# and session scope.
+#
+# If you want to set the cache key to anything other than the default
+# uncomment this line and change the cache.key
+#
+# cache.key=__oscache_cache
+
+
+# USE HOST DOMAIN NAME IN KEY
+#
+# Servers for multiple host domains may wish to add host name info to
+# the generation of the key. If this is true, then uncomment the
+# following line.
+#
+# cache.use.host.domain.in.key=true
+
+
+# CACHE LISTENERS
+#
+# These hook OSCache events and perform various actions such as logging
+# cache hits and misses, or broadcasting to other cache instances across a cluster.
+# See the documentation for further information.
+#
+# cache.event.listeners=com.opensymphony.oscache.plugins.clustersupport.JMSBroadcastingListener, \
+# com.opensymphony.oscache.extra.CacheEntryEventListenerImpl, \
+# com.opensymphony.oscache.extra.CacheMapAccessEventListenerImpl, \
+# com.opensymphony.oscache.extra.ScopeEventListenerImpl
+
+
+# CACHE PERSISTENCE CLASS
+#
+# Specify the class to use for persistence. If you use the supplied DiskPersistenceListener,
+# don't forget to supply the cache.path property to specify the location of the cache
+# directory.
+#
+# If a persistence class is not specified, OSCache will use memory caching only.
+#
+# cache.persistence.class=com.opensymphony.oscache.plugins.diskpersistence.DiskPersistenceListener
+
+# CACHE OVERFLOW PERSISTENCE
+# Use persistent cache in overflow or not. The default value is false, which means
+# the persistent cache will be used at all times for every entry. true is the recommended setting.
+#
+# cache.persistence.overflow.only=true
+
+
+# CACHE DIRECTORY
+#
+# This is the directory on disk where caches will be stored by the DiskPersistenceListener.
+# it will be created if it doesn't already exist. Remember that OSCache must have
+# write permission to this directory.
+#
+# Note: for Windows machines, this needs \ to be escaped
+# ie Windows:
+# cache.path=c:\\myapp\\cache
+# or *ix:
+# cache.path=/opt/myapp/cache
+#
+# cache.path=c:\\app\\cache
+
+
+# CACHE ALGORITHM
+#
+# Default cache algorithm to use. Note that in order to use an algorithm
+# the cache size must also be specified. If the cache size is not specified,
+# the cache algorithm will be Unlimited cache.
+#
+# cache.algorithm=com.opensymphony.oscache.base.algorithm.LRUCache
+# cache.algorithm=com.opensymphony.oscache.base.algorithm.FIFOCache
+# cache.algorithm=com.opensymphony.oscache.base.algorithm.UnlimitedCache
+
+# THREAD BLOCKING BEHAVIOR
+#
+# When a request is made for a stale cache entry, it is possible that another thread is already
+# in the process of rebuilding that entry. This setting specifies how OSCache handles the
+# subsequent 'non-building' threads. The default behaviour (cache.blocking=false) is to serve
+# the old content to subsequent threads until the cache entry has been updated. This provides
+# the best performance (at the cost of serving slightly stale data). When blocking is enabled,
+# threads will instead block until the new cache entry is ready to be served. Once the new entry
+# is put in the cache the blocked threads will be restarted and given the new entry.
+# Note that even if blocking is disabled, when there is no stale data available to be served
+# threads will block until the data is added to the cache by the thread that is responsible
+# for building the data.
+#
+# cache.blocking=false
+
+
+# CACHE SIZE
+#
+# Default cache size in number of items. If a size is specified but not
+# an algorithm, the cache algorithm used will be LRUCache.
+#
+cache.capacity=1000
+
+
+# CACHE UNLIMITED DISK
+# Use unlimited disk cache or not. The default value is false, which means
+# the disk cache will be limited in size to the value specified by cache.capacity.
+#
+# cache.unlimited.disk=false
+
+
+# JMS CLUSTER PROPERTIES
+#
+# Configuration properties for JMS clustering. See the clustering documentation
+# for more information on these settings.
+#
+#cache.cluster.jms.topic.factory=java:comp/env/jms/TopicConnectionFactory
+#cache.cluster.jms.topic.name=java:comp/env/jms/OSCacheTopic
+#cache.cluster.jms.node.name=node1
+
+
+# JAVAGROUPS CLUSTER PROPERTIES
+#
+# Configuration properites for the JavaGroups clustering. Only one of these
+# should be specified. Default values (as shown below) will be used if niether
+# property is set. See the clustering documentation and the JavaGroups project
+# (www.javagroups.com) for more information on these settings.
+#
+#cache.cluster.properties=UDP(mcast_addr=231.12.21.132;mcast_port=45566;ip_ttl=32;\
+#mcast_send_buf_size=150000;mcast_recv_buf_size=80000):\
+#PING(timeout=2000;num_initial_members=3):\
+#MERGE2(min_interval=5000;max_interval=10000):\
+#FD_SOCK:VERIFY_SUSPECT(timeout=1500):\
+#pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800;max_xmit_size=8192):\
+#UNICAST(timeout=300,600,1200,2400):\
+#pbcast.STABLE(desired_avg_gossip=20000):\
+#FRAG(frag_size=8096;down_thread=false;up_thread=false):\
+#pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true)
+#cache.cluster.multicast.ip=231.12.21.132
Copied: trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/jsshell.html (from rev 1590, trunk/framework/impl/src/main/resources/org/ajax4jsf/framework/ajax/jsshell.html)
===================================================================
--- trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/jsshell.html (rev 0)
+++ trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/jsshell.html 2007-07-11 00:20:34 UTC (rev 1594)
@@ -0,0 +1,740 @@
+<!-- short bookmarklet
+// javascript:function loadScript(scriptURL) { var scriptElem = document.createElement('SCRIPT'); scriptElem.setAttribute('language', 'JavaScript'); scriptElem.setAttribute('src', scriptURL); document.body.appendChild(scriptElem);} loadScript('http://blog.monstuff.com/archives/images/jsshell.js');
+
+
+with(window.open("","_blank","width="+screen.width*.6+",left="+screen.width*.35+",height="+screen.height*.9+",resizable,scrollbars=yes")){document.write("" +
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+
+<html >
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>JavaScript Shell 1.4 modified to support IE</title>
+
+<script type="text/javascript">
+var
+histList = [""],
+histPos = 0,
+_scope = {},
+_win, // a top-level context
+question,
+_in,
+_out,
+tooManyMatches = null,
+lastError = null;
+
+function refocus()
+{
+ _in.blur(); // Needed for Mozilla to scroll correctly.
+ _in.focus();
+}
+
+function init()
+{
+ _in = document.getElementById("input");
+ _out = document.getElementById("output");
+
+ _win = window;
+
+ if (opener && !opener.closed)
+ {
+ println("Using bookmarklet version of shell: commands will run in opener's context.", "message");
+ _win = opener;
+ }
+
+ initTarget();
+
+ recalculateInputHeight();
+ refocus();
+}
+
+function initTarget()
+{
+ _win.Shell = window;
+ _win.print = shellCommands.print;
+}
+
+
+// Unless the user is selected something, refocus the textbox.
+// (requested by caillon, brendan, asa)
+function keepFocusInTextbox(e)
+{
+ var g = e.srcElement ? e.srcElement : e.target; // IE vs. standard
+
+ while (!g.tagName)
+ g = g.parentNode;
+ var t = g.tagName.toUpperCase();
+ if (t=="A" || t=="INPUT")
+ return;
+
+ if (window.getSelection) {
+ // Mozilla
+ if (String(window.getSelection()))
+ return;
+ }
+ else if (document.getSelection) {
+ // Opera? Netscape 4?
+ if (document.getSelection())
+ return;
+ }
+ else {
+ // IE
+ if ( document.selection.createRange().text )
+ return;
+ }
+
+ refocus();
+}
+
+function inputKeydown(e) {
+ // Use onkeydown because IE doesn't support onkeypress for arrow keys
+
+ //alert(e.keyCode + " ^ " + e.keycode);
+
+ if (e.shiftKey && e.keyCode == 13) { // shift-enter
+ // don't do anything; allow the shift-enter to insert a line break as normal
+ } else if (e.keyCode == 13) { // enter
+ // execute the input on enter
+ try { go(); } catch(er) { alert(er); };
+ setTimeout(function() { _in.value = ""; }, 0); // can't preventDefault on input, so clear it later
+ } else if (e.keyCode == 38) { // up
+ // go up in history if at top or ctrl-up
+ if (e.ctrlKey || caretInFirstLine(_in))
+ hist(true);
+ } else if (e.keyCode == 40) { // down
+ // go down in history if at end or ctrl-down
+ if (e.ctrlKey || caretInLastLine(_in))
+ hist(false);
+ } else if(e.ctrlKey && e.keyCode == 32) { // ctrl-space
+ tabcomplete();
+ e.cancelBubble = false;
+ e.returnValue = false;
+ return false;
+ } else if (e.keyCode == 9) { // tab
+ tabcomplete();
+ setTimeout(function() { refocus(); }, 0); // refocus because tab was hit
+ } else { }
+
+ setTimeout(recalculateInputHeight, 0);
+
+ //return true;
+};
+
+function caretInFirstLine(textbox)
+{
+ // IE doesn't support selectionStart/selectionEnd
+ if (textbox.selectionStart == undefined)
+ return true;
+
+ var firstLineBreak = textbox.value.indexOf("\n");
+
+ return ((firstLineBreak == -1) || (textbox.selectionStart <= firstLineBreak));
+}
+
+function caretInLastLine(textbox)
+{
+ // IE doesn't support selectionStart/selectionEnd
+ if (textbox.selectionEnd == undefined)
+ return true;
+
+ var lastLineBreak = textbox.value.lastIndexOf("\n");
+
+ return (textbox.selectionEnd > lastLineBreak);
+}
+
+function recalculateInputHeight()
+{
+ var rows = _in.value.split(/\n/).length
+ + 1 // prevent scrollbar flickering in Mozilla
+ + (window.opera ? 1 : 0); // leave room for scrollbar in Opera
+
+ if (_in.rows != rows) // without this check, it is impossible to select text in Opera 7.60 or Opera 8.0.
+ _in.rows = rows;
+}
+
+function println(s, type)
+{
+ if((s=String(s)))
+ {
+ var newdiv = document.createElement("div");
+ newdiv.appendChild(document.createTextNode(s));
+ newdiv.className = type;
+ _out.appendChild(newdiv);
+ return newdiv;
+ }
+}
+
+function printWithRunin(h, s, type)
+{
+ var div = println(s, type);
+ var head = document.createElement("strong");
+ head.appendChild(document.createTextNode(h + ": "));
+ div.insertBefore(head, div.firstChild);
+}
+
+
+var shellCommands =
+{
+load : function load(url)
+{
+ var s = _win.document.createElement("script");
+ s.type = "text/javascript";
+ s.src = url;
+ _win.document.getElementsByTagName("head")[0].appendChild(s);
+ println("Loading " + url + "...", "message");
+},
+
+clear : function clear()
+{
+ var CHILDREN_TO_PRESERVE = 3;
+ while (_out.childNodes[CHILDREN_TO_PRESERVE])
+ _out.removeChild(_out.childNodes[CHILDREN_TO_PRESERVE]);
+},
+
+print : function print(s) { println(s, "print"); },
+
+// the normal function, "print", shouldn't return a value
+// (suggested by brendan; later noticed it was a problem when showing others)
+pr : function pr(s)
+{
+ shellCommands.print(s); // need to specify shellCommands so it doesn't try window.print()!
+ return s;
+},
+
+props : function props(e, onePerLine)
+{
+ if (e === null) {
+ println("props called with null argument", "error");
+ return;
+ }
+
+ if (e === undefined) {
+ println("props called with undefined argument", "error");
+ return;
+ }
+
+ var ns = ["Methods", "Fields", "Unreachables"];
+ var as = [[], [], []]; // array of (empty) arrays of arrays!
+ var p, j, i; // loop variables, several used multiple times
+
+ var protoLevels = 0;
+
+ for (p = e; p; p = p.__proto__)
+ {
+ for (i=0; i<ns.length; ++i)
+ as[i][protoLevels] = [];
+ ++protoLevels;
+ }
+
+ for(var a in e)
+ {
+ // Shortcoming: doesn't check that VALUES are the same in object and prototype.
+
+ var protoLevel = -1;
+ try
+ {
+ for (p = e; p && (a in p); p = p.__proto__)
+ ++protoLevel;
+ }
+ catch(er) { protoLevel = 0; } // "in" operator throws when param to props() is a string
+
+ var type = 1;
+ try
+ {
+ if ((typeof e[a]) == "function")
+ type = 0;
+ }
+ catch (er) { type = 2; }
+
+ as[type][protoLevel].push(a);
+ }
+
+ function times(s, n) { return n ? s + times(s, n-1) : ""; }
+
+ for (j=0; j<protoLevels; ++j)
+ for (i=0;i<ns.length;++i)
+ if (as[i][j].length)
+ printWithRunin(
+ ns[i] + times(" of prototype", j),
+ (onePerLine ? "\n\n" : "") + as[i][j].sort().join(onePerLine ? "\n" : ", ") + (onePerLine ? "\n\n" : ""),
+ "propList"
+ );
+},
+
+blink : function blink(node)
+{
+ if (!node) throw("blink: argument is null or undefined.");
+ if (node.nodeType == null) throw("blink: argument must be a node.");
+ if (node.nodeType == 3) throw("blink: argument must not be a text node");
+ if (node.documentElement) throw("blink: argument must not be the document object");
+
+ function setOutline(o) {
+ return function() {
+ if (node.style.outline != node.style.bogusProperty) {
+ // browser supports outline (Firefox 1.1 and newer, CSS3, Opera 8).
+ node.style.outline = o;
+ }
+ else if (node.style.MozOutline != node.style.bogusProperty) {
+ // browser supports MozOutline (Firefox 1.0.x and older)
+ node.style.MozOutline = o;
+ }
+ else {
+ // browser only supports border (IE). border is a fallback because it moves things around.
+ node.style.border = o;
+ }
+ }
+ }
+
+ function focusIt(a) {
+ return function() {
+ a.focus();
+ }
+ }
+
+ if (node.ownerDocument) {
+ var windowToFocusNow = (node.ownerDocument.defaultView || node.ownerDocument.parentWindow); // Moz vs. IE
+ if (windowToFocusNow)
+ setTimeout(focusIt(windowToFocusNow.top), 0);
+ }
+
+ for(var i=1;i<7;++i)
+ setTimeout(setOutline((i%252)?'3px solid red':'none'), i*100);
+
+ setTimeout(focusIt(window), 800);
+ setTimeout(focusIt(_in), 810);
+},
+
+scope : function scope(sc)
+{
+ if (!sc) sc = {};
+ _scope = sc;
+ println("Scope is now " + sc + ". If a variable is not found in this scope, window will also be searched. New variables will still go on window.", "message");
+},
+
+mathHelp : function mathHelp()
+{
+ printWithRunin("Math constants", "E, LN2, LN10, LOG2E, LOG10E, PI, SQRT1_2, SQRT2", "propList");
+ printWithRunin("Math methods", "abs, acos, asin, atan, atan2, ceil, cos, exp, floor, log, max, min, pow, random, round, sin, sqrt, tan", "propList");
+},
+
+ans : undefined
+};
+
+
+function hist(up)
+{
+ // histList[0] = first command entered, [1] = second, etc.
+ // type something, press up --> thing typed is now in "limbo"
+ // (last item in histList) and should be reachable by pressing
+ // down again.
+
+ var L = histList.length;
+
+ if (L == 1)
+ return;
+
+ if (up)
+ {
+ if (histPos == L-1)
+ {
+ // Save this entry in case the user hits the down key.
+ histList[histPos] = _in.value;
+ }
+
+ if (histPos > 0)
+ {
+ histPos--;
+ // Use a timeout to prevent up from moving cursor within new text
+ // Set to nothing first for the same reason
+ setTimeout(
+ function() {
+ _in.value = '';
+ _in.value = histList[histPos];
+ var caretPos = _in.value.length;
+ if (_in.setSelectionRange)
+ _in.setSelectionRange(caretPos, caretPos);
+ },
+ 0
+ );
+ }
+ }
+ else // down
+ {
+ if (histPos < L-1)
+ {
+ histPos++;
+ _in.value = histList[histPos];
+ }
+ else if (histPos == L-1)
+ {
+ // Already on the current entry: clear but save
+ if (_in.value)
+ {
+ histList[histPos] = _in.value;
+ ++histPos;
+ _in.value = "";
+ }
+ }
+ }
+}
+
+function tabcomplete()
+{
+ /*
+ * Working backwards from s[from], find the spot
+ * where this expression starts. It will scan
+ * until it hits a mismatched ( or a space,
+ * but it skips over quoted strings.
+ * If stopAtDot is true, stop at a '.'
+ */
+ function findbeginning(s, from, stopAtDot)
+ {
+ /*
+ * Complicated function.
+ *
+ * Return true if s[i] == q BUT ONLY IF
+ * s[i-1] is not a backslash.
+ */
+ function equalButNotEscaped(s,i,q)
+ {
+ if(s.charAt(i) != q) // not equal go no further
+ return false;
+
+ if(i==0) // beginning of string
+ return true;
+
+ if(s.charAt(i-1) == '') // escaped?
+ return false;
+
+ return true;
+ }
+
+ var nparens = 0;
+ var i;
+ for(i=from; i>=0; i--)
+ {
+ if(s.charAt(i) == ' ')
+ break;
+
+ if(stopAtDot && s.charAt(i) == '.')
+ break;
+
+ if(s.charAt(i) == ')')
+ nparens++;
+ else if(s.charAt(i) == '(')
+ nparens--;
+
+ if(nparens < 0)
+ break;
+
+ // skip quoted strings
+ if(s.charAt(i) == '\'' || s.charAt(i) == '"')
+ {
+ //dump("skipping quoted chars: ");
+ var quot = s.charAt(i);
+ i--;
+ while(i >= 0 && !equalButNotEscaped(s,i,quot)) {
+ //dump(s.charAt(i));
+ i--;
+ }
+ //dump("\n");
+ }
+ }
+ return i;
+ }
+
+ // XXX should be used more consistently (instead of using selectionStart/selectionEnd throughout code)
+ // XXX doesn't work in IE, even though it contains IE-specific code
+ function getcaretpos(inp)
+ {
+ if(inp.selectionEnd != null)
+ return inp.selectionEnd;
+
+ var range = document.selection.createRange();
+ var isCollapsed = range.compareEndPoints("StartToEnd", range) == 0;
+ if (!isCollapsed)
+ range.collapse(false);
+ var b = range.getBookmark();
+ return b.charCodeAt(2) - 2;
+ }
+
+ function setselectionto(inp,pos)
+ {
+ if(inp.selectionStart) {
+ inp.selectionStart = inp.selectionEnd = pos;
+ }
+ else if(inp.createTextRange) {
+ var docrange = _win.Shell.document.selection.createRange();
+ var inprange = inp.createTextRange();
+ inprange.move('character',pos);
+ inprange.select();
+ }
+ else { // err...
+ /*
+ inp.select();
+ if(_win.Shell.document.getSelection())
+ _win.Shell.document.getSelection() = "";
+ */
+ }
+ }
+ // get position of cursor within the input box
+ var caret = getcaretpos(_in);
+
+ if(caret) {
+ //dump("----\n");
+ var dotpos, spacepos, complete, obj;
+ //dump("caret pos: " + caret + "\n");
+ // see if there's a dot before here
+ dotpos = findbeginning(_in.value, caret-1, true);
+ //dump("dot pos: " + dotpos + "\n");
+ if(dotpos == -1 || _in.value.charAt(dotpos) != '.') {
+ dotpos = caret;
+ //dump("changed dot pos: " + dotpos + "\n");
+ }
+
+ // look backwards for a non-variable-name character
+ spacepos = findbeginning(_in.value, dotpos-1, false);
+ //dump("space pos: " + spacepos + "\n");
+ // get the object we're trying to complete on
+ if(spacepos == dotpos || spacepos+1 == dotpos || dotpos == caret)
+ {
+ // try completing function args
+ if(_in.value.charAt(dotpos) == '(' ||
+ (_in.value.charAt(spacepos) == '(' && (spacepos+1) == dotpos))
+ {
+ var fn,fname;
+ var from = (_in.value.charAt(dotpos) == '(') ? dotpos : spacepos;
+ spacepos = findbeginning(_in.value, from-1, false);
+
+ fname = _in.value.substr(spacepos+1,from-(spacepos+1));
+ //dump("fname: " + fname + "\n");
+ try {
+ with(_win.Shell._scope)
+ with(_win)
+ with(Shell.shellCommands)
+ fn = eval(fname);
+ }
+ catch(er) {
+ //dump('fn is not a valid object\n');
+ return;
+ }
+ if(fn == undefined) {
+ //dump('fn is undefined');
+ return;
+ }
+ if(fn instanceof Function)
+ {
+ // Print function definition, including argument names, but not function body
+ if(!fn.toString().match(/function .+?\(\) +\{\n +\[native code\]\n\}/))
+ println(fn.toString().match(/function .+?\(.*?\)/), "tabcomplete");
+ }
+
+ return;
+ }
+ else
+ obj = _win;
+ }
+ else
+ {
+ var objname = _in.value.substr(spacepos+1,dotpos-(spacepos+1));
+ //dump("objname: |" + objname + "|\n");
+ try {
+ with(_win.Shell._scope)
+ with(_win)
+ obj = eval(objname);
+ }
+ catch(er) {
+ printError(er);
+ return;
+ }
+ if(obj == undefined) {
+ // sometimes this is tabcomplete's fault, so don't print it :(
+ // e.g. completing from "print(document.getElements"
+ // println("Can't complete from null or undefined expression " + objname, "error");
+ return;
+ }
+ }
+ //dump("obj: " + obj + "\n");
+ // get the thing we're trying to complete
+ if(dotpos == caret)
+ {
+ if(spacepos+1 == dotpos || spacepos == dotpos)
+ {
+ // nothing to complete
+ //dump("nothing to complete\n");
+ return;
+ }
+
+ complete = _in.value.substr(spacepos+1,dotpos-(spacepos+1));
+ }
+ else {
+ complete = _in.value.substr(dotpos+1,caret-(dotpos+1));
+ }
+ //dump("complete: " + complete + "\n");
+ // ok, now look at all the props/methods of this obj
+ // and find ones starting with 'complete'
+ var matches = [];
+ var bestmatch = null;
+ for(var a in obj)
+ {
+ //a = a.toString();
+ //XXX: making it lowercase could help some cases,
+ // but screws up my general logic.
+ if(a.substr(0,complete.length) == complete) {
+ matches.push(a);
+ ////dump("match: " + a + "\n");
+ // if no best match, this is the best match
+ if(bestmatch == null)
+ {
+ bestmatch = a;
+ }
+ else {
+ // the best match is the longest common string
+ function min(a,b){ return ((a<b)?a:b); }
+ var i;
+ for(i=0; i< min(bestmatch.length, a.length); i++)
+ {
+ if(bestmatch.charAt(i) != a.charAt(i))
+ break;
+ }
+ bestmatch = bestmatch.substr(0,i);
+ ////dump("bestmatch len: " + i + "\n");
+ }
+ ////dump("bestmatch: " + bestmatch + "\n");
+ }
+ }
+ bestmatch = (bestmatch || "");
+ ////dump("matches: " + matches + "\n");
+ var objAndComplete = (objname || obj) + "." + bestmatch;
+ //dump("matches.length: " + matches.length + ", tooManyMatches: " + tooManyMatches + ", objAndComplete: " + objAndComplete + "\n");
+ if(matches.length > 1 && (tooManyMatches == objAndComplete || matches.length <= 10)) {
+
+ printWithRunin("Matches: ", matches.join(', '), "tabcomplete");
+ tooManyMatches = null;
+ }
+ else if(matches.length > 10)
+ {
+ println(matches.length + " matches. Press tab or ctrl-space again to see them all", "tabcomplete");
+ tooManyMatches = objAndComplete;
+ }
+ else {
+ tooManyMatches = null;
+ }
+ if(bestmatch != "")
+ {
+ var sstart;
+ if(dotpos == caret) {
+ sstart = spacepos+1;
+ }
+ else {
+ sstart = dotpos+1;
+ }
+ _in.value = _in.value.substr(0, sstart)
+ + bestmatch
+ + _in.value.substr(caret);
+ setselectionto(_in,caret + (bestmatch.length - complete.length));
+ }
+ }
+}
+
+function printQuestion(q)
+{
+ println(q, "input");
+}
+
+function printAnswer(a)
+{
+ if (a !== undefined) {
+ println(a, "normalOutput");
+ shellCommands.ans = a;
+ }
+}
+
+function printError(er)
+{
+ var lineNumberString;
+
+ lastError = er; // for debugging the shell
+ if (er.name)
+ {
+ // lineNumberString should not be "", to avoid a very wacky bug in IE 6.
+ lineNumberString = (er.lineNumber != undefined) ? (" on line " + er.lineNumber + ": ") : ": ";
+ println(er.name + lineNumberString + er.message, "error"); // Because IE doesn't have error.toString.
+ }
+ else
+ println(er, "error"); // Because security errors in Moz /only/ have toString.
+}
+
+function go(s)
+{
+ _in.value = question = s ? s : _in.value;
+
+ if (question == "")
+ return;
+
+ histList[histList.length-1] = question;
+ histList[histList.length] = "";
+ histPos = histList.length - 1;
+
+ // Unfortunately, this has to happen *before* the JavaScript is run, so that
+ // print() output will go in the right place.
+ _in.value='';
+ recalculateInputHeight();
+ printQuestion(question);
+
+ if (_win.closed) {
+ printError("Target window has been closed.");
+ return;
+ }
+
+ try { ("Shell" in _win) }
+ catch(er) {
+ printError("The JavaScript Shell cannot access variables in the target window. The most likely reason is that the target window now has a different page loaded and that page has a different hostname than the original page.");
+ return;
+ }
+
+ if (!("Shell" in _win))
+ initTarget(); // silent
+
+ // Evaluate Shell.question using _win's eval (this is why eval isn't in the |with|, IIRC).
+ _win.location.href = "javascript:try{ Shell.printAnswer(eval('with(Shell._scope) with(Shell.shellCommands) {' + Shell.question + String.fromCharCode(10) + '}')); } catch(er) { Shell.printError(er); }; setTimeout(Shell.refocus, 0); void 0";
+}
+
+</script>
+
+<!-- for http://ted.mielczarek.org/code/mozilla/extensiondev/ -->
+<script type="text/javascript" src="chrome://extensiondev/content/rdfhistory.js"></script>
+<script type="text/javascript" src="chrome://extensiondev/content/chromeShellExtras.js"></script>
+
+<style type="text/css">
+body { background: white; color: black; }
+
+#output { white-space: pre; white-space: -moz-pre-wrap; } /* Preserve line breaks, but wrap too if browser supports it */
+h3 { margin-top: 0; margin-bottom: 0em; }
+h3 + div { margin: 0; }
+
+form { margin: 0; padding: 0; }
+#input { width: 100%; border: none; padding: 0; overflow: auto; }
+
+.input { color: blue; background: white; font: inherit; font-weight: bold; margin-top: .5em; /* background: #E6E6FF; */ }
+.normalOutput { color: black; background: white; }
+.print { color: brown; background: white; }
+.error { color: red; background: white; }
+.propList { color: green; background: white; }
+.message { color: green; background: white; }
+.tabcomplete { color: purple; background: white; }
+</style>
+</head>
+
+<body onload="init()" onclick="keepFocusInTextbox(event)">
+
+<div id="output"><h3>JavaScript Shell 1.4</h3><h4>Modified by <a href="http://blog.monstuff.com">Julien Couvreur</a> to work in IE.</h4><div>Features: autocompletion of property names with Tab and Ctrl-Space, multiline input with Shift+Enter, input history with (Ctrl+) Up/Down, <a accesskey="M" href="javascript:go('scope(Math); mathHelp();');" title="Accesskey: M">Math</a>, <a accesskey="H" href="http://www.squarefree.com/shell/?ignoreReferrerFrom=shell1.4" title="Accesskey: H">help</a></div><div>Values and functions: ans, print(string), <a accesskey="P" href="javascript:go('props(ans)')" title="Accesskey: P">props(object)</a>, <a accesskey="B" href="javascript:go('blink(ans)')" title="Accesskey: B">blink(node)</a>, <a accesskey="C" href="javascript:go('clear()')" title="Accesskey: C">clear()</a>, load(scriptURL), scope(object)</div></div>
+
+<div><textarea id="input" class="input" wrap="off" onkeydown="inputKeydown(event)" rows="1"></textarea></div>
+
+</body>
+
+</html>
+<!--
+");document.close();}
+-->
\ No newline at end of file
Copied: trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/command.js (from rev 1593, trunk/framework/impl/src/main/resources/org/ajax4jsf/framework/util/command/command.js)
===================================================================
--- trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/command.js (rev 0)
+++ trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/command.js 2007-07-11 00:20:34 UTC (rev 1594)
@@ -0,0 +1,196 @@
+/**
+
+* Client-side implementation of command script for commadd links, buttons etc.
+
+*
+
+*/
+
+A4J_Command = Class.create();
+
+A4J_Command.prototype = {
+
+ /**
+
+ * Object is usually created on click event.
+
+ */
+
+ initialize: function(e, params, target) {
+
+ this.form = Event.findElement(e, 'form');
+
+ this.target = target;
+
+ this.objectsCreated = new Array();
+
+ this.oldValuesOfExistingInputs = {};
+
+
+
+ this.appendParameters(params);
+
+
+
+ this.processClick();
+
+
+
+ this.cleanUp();
+
+
+
+ },
+
+ /**
+
+ * store form;'s target
+
+ * append temporary parameter nodes
+
+ * submit form
+
+ */
+
+ processClick: function() {
+
+ var form = this.form;
+
+ var targ = form.target;
+
+
+
+ $A(this.objectsCreated).each(
+
+ function(node) {
+
+ form.appendChild(node);
+
+ }
+
+ );
+
+
+
+ if (this.target){
+
+ form.target = this.target;
+
+ }
+
+
+
+ form.submit();
+
+
+
+ form.target = targ;
+
+
+
+ },
+
+ /**
+
+ iterate over set of parameters, setting values of hidden inputs
+
+ */
+
+ appendParameters: function(params) {
+
+ var dis = this;
+
+ $H(params).each(
+
+ function(parameter) {
+
+ dis.createOrInitHiddenInput(parameter.key, parameter.value);
+
+ }
+
+ );
+
+ },
+
+ /**
+
+ * remove created hidden inputs, and restore values of previously existed
+
+ */
+
+ cleanUp: function(){
+
+ var form = this.form;
+
+
+
+ $H(this.oldValuesOfExistingInputs).each(
+
+ function(input){
+
+ ($(input.key) || form[input.key]).value = input.value;
+
+ }
+
+
+
+ );
+
+
+
+ $A(this.objectsCreated).each(
+
+ function(node) {
+
+ form.removeChild(node);
+
+ }
+
+ );
+
+
+
+ delete (this.objectsCreated);
+
+
+
+ },
+
+
+
+ /**
+
+ * init hidden inputs with parameter values, creating inputs if necessary
+
+ */
+
+ createOrInitHiddenInput : function(name, value) {
+
+ var hiddenObj = $(name) || this.form[name];
+
+
+
+ if (!hiddenObj) {
+
+ hiddenObj = document.createElement('input');
+
+ hiddenObj.setAttribute('type', 'hidden');
+
+ hiddenObj.setAttribute('name', name);
+
+ hiddenObj.setAttribute('id', name);
+
+ this.objectsCreated.push(hiddenObj);
+
+ } else {
+
+ this.oldValuesOfExistingInputs[name] = hiddenObj.value;
+
+ }
+
+ hiddenObj.value = value;
+
+ }
+
+};
+
Copied: trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/form.js (from rev 1590, trunk/framework/impl/src/main/resources/org/ajax4jsf/renderkit/html/scripts/form.js)
===================================================================
--- trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/form.js (rev 0)
+++ trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/form.js 2007-07-11 00:20:34 UTC (rev 1594)
@@ -0,0 +1,101 @@
+
+if (!window.A4J) { window.A4J= {};}
+
+if(!A4J.findForm){
+
+function _JSFFormSubmit(linkId,formName,target,parameters){
+ var form = document.getElementById(formName);
+ if(form){
+ var hiddenField = form.elements[formName+":_idcl"];
+ if(hiddenField){
+ hiddenField.value=linkId;
+ } else {
+ var input = document.createElement("input");
+ input.type="hidden";
+ input.name=formName+":_idcl";
+ input.value=linkId;
+ form.appendChild(input);
+ }
+ if(target){
+ form.target=target;
+ }
+ if(parameters){
+ for(var param in parameters){
+ if(form.elements[param]){
+ form.elements[param].value = parameters[param];
+ } else {
+ var input = document.createElement("input");
+ input.type="hidden";
+ input.name=param;
+ input.value=parameters[param];
+ form.appendChild(input);
+ }
+ }
+ }
+ form.submit();
+ } else {
+ alert("Form "+formName+" not found in document");
+ }
+ return false;
+};
+
+function _clearJSFFormParameters(formName,target,fields){
+ var form = document.getElementById(formName);
+ if(form){
+ if(target){
+ form.target = target;
+ } else {
+ form.target = '';
+ }
+ if(fields){
+ for(var i=0;i<fields.length;i++){
+ var field = form.elements[fields[i]];
+ if(field){
+ field.value='';
+ }
+ }
+ }
+ }
+}
+
+function clearFormHiddenParams(formName,target,fields){
+ _clearJSFFormParameters(formName,target,fields);
+}
+
+
+ A4J.findForm = function(element){
+ var parent = element;
+ do{
+ parent = parent.parentNode;
+ } while (parent && parent.nodeName.toLowerCase() != 'form');
+ if(!parent){
+ parent = {reset:function(){}, submit:function(){}};
+ }
+ return parent;
+ }
+
+ A4J._formInput = null;
+
+// setup form to handle 'onclick' events, to detect input element.
+ A4J.setupForm = function(id){
+ var element = window.document.getElementById(id);
+ var name = "click";
+ if (element.addEventListener) {
+ element.addEventListener(name, A4J._observer, false);
+ } else if (element.attachEvent) {
+ element.attachEvent('on' + name, A4J._observer);
+ }
+ // TODO - handle array of all attached forms and remove listeners
+ // on ajax updates, to avoid memory leaks.
+ }
+
+ A4J._observer = function(evt){
+ var src = evt.target||evt.srcElement;
+ if( src && src.nodeName.toUpperCase() == 'INPUT' && src.type.toUpperCase() == 'SUBMIT'){
+ A4J._formInput = src;
+ } else {
+ A4J._formInput = null;
+ }
+ }
+}
+//
\ No newline at end of file
Copied: trunk/framework/impl/src/main/resources/org/ajax4jsf/messages.properties (from rev 1593, trunk/framework/impl/src/main/resources/org/ajax4jsf/framework/util/message/messages.properties)
===================================================================
--- trunk/framework/impl/src/main/resources/org/ajax4jsf/messages.properties (rev 0)
+++ trunk/framework/impl/src/main/resources/org/ajax4jsf/messages.properties 2007-07-11 00:20:34 UTC (rev 1594)
@@ -0,0 +1,252 @@
+BUNDLE_MAP_NO_PUT_VALUE=Bundle map not allow to put values
+BUNDLE_MAP_NO_REMOVE_VALUE=Bundle map not allow to remove values
+NO_CONVERTER_REGISTERED=No Converter registered with UpdateActionListener and no appropriate standard converter found. Needed to convert String to {0}
+FOR_TARGETS_NO_AJAX_CONTAINER=Target pointed Attribute 'for' of AjaxStatus component with id {0} not is AjaxContainer
+VAR_MUST_BE_LITERAL=Attribute 'var' for ajax support component {0} must be literal
+NAME_MUST_BE_LITERAL=Attribute 'name' for view scope bean must be literal
+EVENT_MUST_BE_LITERAL=Attribute 'event' for ajax support component {0} must be literal
+CREATE_JAVASCRIPT_EVENT=Create JavaScript event string for component {0}
+CALLED_SET_PARENT=Called setParent for AjaxSupport component with parent \: {0}
+DETECT_NEW_COMPONENT=Detect newly created component
+SET_VALUE_BINDING_FOR_EVENT=Set ValueBinding for {0} event property
+COULD_NOT_LOAD_RESOURCE_BUNDLE=Could not load ResourceBundle "{0}"
+FACES_CONTEXT_NOT_CREATED=Faces context not created then occurs exception
+FACES_CONTEXT_HAS_NOT_EXTERNAL=Faces context not have external then occurs exception
+FACES_CONTEXT_HAS_NOT_RESPONSE=Faces context not have http response object then occurs exception
+CREATE_ALTERNATE_HANDLER=Create new instance of alternate handler class {0}
+ALTERNATE_HANDLER_CONSTRUCTOR_WARNING=Alternate view handler not use parent in constructor!
+VIEW_HANDLER_INSTANTIATION_ERROR=Error instantiation parent Faces ViewHandler
+ERROR_ON_PAGE=Error on page {0}
+LIFECYCLE_ERROR=Error on JSF lifecycle in view {0} in {1} lyfecycle method
+LIFECYCLE_ERROR_AT_PHASE=Error on JSF lifecycle in view {0} in {1} lyfecycle method,\n at phase {2}
+COMPONENT_TREE_NOT_CREATED=Component tree not created
+SET_AJAX_LISTENER=Set AjaxListener to {0}
+ADD_AJAX_AREA=Append single ID of area to render\: {0}
+ADD_AJAX_AREAS=Append collection of ID's to render as AjaxAreas
+SET_AJAX_REQUEST=Set request as ajax powered to {0}
+SUBMITTED_AJAX_REQUEST=Submitted AJAX request - Queue Event to AjaxListeners
+SEND_EVENT_TO_AJAX_LISTENER=Send Event to AjaxListeners from AjaxContainer with Id {0}
+RENDER_AJAX_REQUEST=Render ajax request by container with Id {0}
+RENDERING_AJAX_REGION_ERROR=Error rendering Ajax Region with id {0}
+RESTORE_AJAX_COMPONENT_STATE=Restore State of UIAjaxComponent with Id {0}
+SAVE_AJAX_COMPONENT_STATE=Save State of UIAjaxComponent with Id {0}
+CREATE_AJAX_AREAS_SET_TO_RENDER=Create new set of Ajax Areas to render
+ARGUMENT_IS_NOT_AJAX_REGION_ERROR=Argument for append AJAX region not instance of AjaxContainer , region is {0}
+NULL_EVENT_SUBMITTED_ERROR=New event submitted to ViewRoot events queue is null
+CONTENT_TYPE_ENCODING=Incoming request has Content-Type header with character encoding {0}
+CONTENT_TYPE_NO_ENCODING=Incoming request has Content-Type header without character encoding: {0}
+FILTER_START_INFO=Filter start request processing at {0} for uri\: {1}
+FILTER_XML_OUTPUT=Filter request output to XML
+FILTER_NO_XML_CHAIN=Filter perform not-xml parsing chain
+FILTER_NO_XML_CHAIN_2=Not is faces request, Filter perform not-xml parsing chain
+FILTER_STOP_INFO=Finished request processing total time {0}ms for uri: {1}
+PARSER_NOT_INSTANTIATED_ERROR=Parser for content type {0} not instantiated !
+PARSING_TIME_INFO=Parsing html total time {0}ms
+JTIDY_PARSING_ERROR=Error on parsing response by Jtidy
+COMPONENT_NOT_FOUND=AjaxUpdate component not found for id: {0}
+EVENT_IS_READ_ONLY=Event string is read-only
+FLUSH_BUFFERED_STREAM_ERROR=Error on flush buffered stream in response wrapper
+UNSUPPORTED_ENCODING_WARNING=Unsupported encoding for convert writer content to bytes
+UNSUPPORTED_ENCODING_WARNING_2=Unsupported encoding for convert bytes content to string
+NO_WRITER_CALLED_INFO=Filtered resource did not call getWriter() or getOutputStream().
+PARSE_XML_DOCUMENT_INFO=XML document to parse in filter, return as stream \:
+NO_WRITER_POSSIBLE_ERROR=Servlet response already use stream, Writer not possible
+CREATE_WRITER_INFO=Create StringWriter for buffer servlet output
+NO_STREAM_POSSIBLE_ERROR=Servlet response already use Writer, OutputStream not possible
+CREATE_STREAM_INFO=Create ByteArrayServletOutputStream for buffer servlet output
+OPEN_CLOSE_TAGS_DO_NOT_MATCH_ERROR=Open-close tags don't match in JSSerialisation
+VARIABLE_SUBSTITUTION_WARNING=Could not perform variable substitution.
+START_DOCUMENT_SAX_EXCEPTION=StartDocument SAX exception: {0}
+COMMENT_SAX_EXCEPTION=Comment SAX exception: {0}
+END_ELEMENT_SAX_EXCEPTION=Sax exceptions in endElement: {0}
+END_DOCUMENT_SAX_EXCEPTION=Sax exceptions in endDocument: {0}
+START_ELEMENT_SAX_EXCEPTION=Sax exceptions in startElement: {0}
+TEXT_SAX_EXCEPTION=Sax exceptions in writeText: {0}
+MESSAGE_PARSING_INFO=Message for HTML parsing : {0}
+CREATE_JTIDY_INFO=Parsers pool empty - create new JTidy parser
+READING_TIDY_PROPERTIES_ERROR=Error reading properties from tidy.properties
+ILLEGAL_METHOD_STATE=Illegal state for this method
+WRAPPED_RULES_NULL_ERROR=Wrapped rules must not be null
+NO_NAME_ATTRIBUTE_ERROR=Tag {0} must have mantadory attribute "name"
+ENCODE_COMPILED_TEMPLATE_INFO=Encode compiled template "{0}" from breakpoint {1}
+ENCODING_TEMPLATE_TERMINATED_INFO=Encoding template "{0}" terminated by breakpoint\: {1}
+ENCODE_COMPILED_TEMPLATE_INFO2=Encode compiled template "{0}"
+CONVERTING_NON_VALUE_HOLDER_COMPONENT_ERROR=Attempt for get converted value for non ValueHolder component {0}
+COMPONENT_CLASS_ERROR=Component {0} not instance of {1}
+CONTEXT_NULL_ERROR=Context in renderer {0} method is null
+COMPONENT_NULL_ERROR=Component in renderer {0} method is null
+START_DECODING_COMPONENT_INFO=Start decoding of component {0} with class {1}
+START_ENCODING_COMPONENT_INFO=Start encoding of component {0} with class {1}
+CHILDREN_ENCODING_COMPONENT_INFO=Encoding children of component {0} with class {1}
+FINISH_ENCODING_COMPONENT_INFO=Finish encoding of component {0} with class {1}
+NAMESPACE_NOT_RECOGNIZED_ERROR=Template namespace element <{0}> not recognized
+RENDERER_METHOD_NOT_SET_ERROR=Renderer method not set in template
+METHOD_CALL_ERROR_1=Error call renderer utils method {0} for component {1}
+METHOD_CALL_ERROR_2=Error invoke renderer utils method {0} for component {1}, caused\: {2}
+METHOD_CALL_ERROR_3=Illegal Access Error call renderer utils method {0} for component {1}
+METHOD_CALL_ERROR_4=Illegal Access Error invoke renderer utils method {0} for component {1}, caused\: {2}
+METHOD_CALL_ERROR_5=Method {0} not found in renderer utils for component {1}
+METHOD_CALL_ERROR_6=Method {0} not found for RendererUtils
+METHOD_CALL_ERROR_1a=Error call renderer method {0} for component {1}
+METHOD_CALL_ERROR_2a=Error invoke renderer method {0} for component {1}, caused\: {2}
+METHOD_CALL_ERROR_3a=Illegal Access Error call renderer method {0} for component {1}
+METHOD_CALL_ERROR_4a=Illegal Access Error invoke renderer method {0} for component {1}, caused\: {2}
+METHOD_CALL_ERROR_5a=Method {0} not found in renderer for component {1}
+METHOD_CALL_ERROR_6a=Method {0} not found for Renderer
+PARSING_TEMPLATE_ERROR=Parsing Error when compile template from Reader at line\: {0} column\: {1} \: {2}
+TEMPLATE_IO_ERROR=I/O Error when compile template from Reader \: {0}
+PARSING_TEMPLATE_ERROR_2=SAX Error then compile template from Reader \: {0}
+START_COMPILE_TEMPLATE_INFO=Start compile template from {0}
+PARSING_TEMPLATE_ERROR_a=Parsing Error when compile template {0} at line\: {1} column\: {2} \: {3}
+TEMPLATE_IO_ERROR_a=I/O Error when compile template {0} \: {1}
+PARSING_TEMPLATE_ERROR_2a=SAX Error then compile template {0} \: {1}
+FINISH_COMPILE_TEMPLATE_INFO=Finish compilation template from {0}
+TEMPLATE_NOT_COMPILED_ERROR=XML template not compiled
+NO_CHILD_ALLOWED=Childs not allowed for Error element
+NO_FACET_NAME_ATTRIBUTE=Tag {0} must have not null facet name attribute( name,skin,property etc. attributes )
+BREAKPOINTS_UNSUPPORTED_ERROR=Breakpoints in rendering facet <u:insertFacet> unsupported, for facet {0}
+BREAKPOINT_NOT_REGISTERED_ERROR=Breakpoint ["{0}"] not registered in template
+CHILD_NOT_ALLOWED_ERROR=Element {0} not allowed as child for {1}
+INVOKE_RENDERER_METHOD_ERROR=Error invoke renderer method for value of template element {0}
+METHOD_CALL_ERROR_2b=Error invoke renderer utils method {0}, caused\: {1}
+METHOD_CALL_ERROR_4b=Illegal Access Error invoke renderer utils method {0}, caused\: {1}
+METHOD_CALL_ERROR_6b=Method {0} not found in object {1}
+STYLE_ATTRIBUTE_ERROR=Name for style attribute not set
+BREAKPOINTS_UNSUPPORTED_ERROR_2=Breakpoints in rendering children <u:insertChildren> unsupported
+BREAKPOINTS_UNSUPPORTED_ERROR_3=Breakpoints in rendering child <u:insertChild> unsupported
+REQUEST_CHAMELEON_RENDER_KIT_INFO=Request to get Chameleon renderKit with id: {0}
+GET_DEFAULT_RENDER_KIT_ERROR=Error for get default render kit
+DEFAULT_RENDER_KIT_INFO=Default render kit id for chameleon will: {0}
+AJAX_RESPONSE_NOT_RENDERED_INFO=AJAX response not rendered - possible MyFaces <f:view tag behavior.
+ENTER_BEFORE_RENDER_VIEW_PHASE=PhaseListener enter Before RenderView Phase with ViewId {0} and RenderKitId {1}
+SET_RENDER_KIT_ID_INFO=PhaseListener Set new RenderKitId to {0}
+PROCESS_AJAX_EVENTS_INFO=Process AJAX events to calculate areas.
+DELEGATE_AJAX_PROCESSING_INFO=Delegate AJAX processing to container.
+BREAKPOINTS_UNSUPPORTED_INSIDE_ATTRIBUTE_ERROR=Breakpoints inside attribute element not allowed, attribute name: {0} of component: {1}
+BUILD_ONCLICK_INFO=Build onclick string for component {0} as {1}
+UNNAMED_PARAMETER_ERROR=Unnamed parameter not allowed for AJAX components, parameter for {0}
+AJAX_STATUS_COMPONENT_NOT_FOWND_WARNING=AJAX Status component not found for AjaxComponent with id {0}
+COMPONENT_NULL_ERROR_2=Component argument is null
+CALCULATE_COMPONENT_ID_INFO=Calculate absolute ID for component {0} as {1}
+DETECTING_ENCODING_DISABLED_ERROR=Detecting request character encoding is disable.
+OBTAIN_RESPONSE_SET_HEADER_ERROR=Failed to obtain Response\#setHeader() method\: {0}
+INVOKE_AJAX_REGION_LISTENER=Invoke AjaxRegion Listener for component with Id\={0}
+APPENDING_AJAX_REGION_TO_NON_AJAX_CONTAINER_WARNING=Attempt to append AJAX regions to render in non-ajax container
+RENDER_CHILDREN_NON_AJAX_INFO=AjaxView RenderChildren() components for normal faces request
+RENDER_CHILDREN_AJAX_INFO=AjaxView RenderChildren() components for AJAX request
+ENCODE_CHILD_AJAX_INFO=AjaxView encodeChild component for AJAX request with at path {0} ID {1}
+RENDER_AJAX_AREA_INFO=Render Ajax Area component with ID {0}
+DECODE_AJAX_REQUEST_STATUS_INFO=Decode ajax request status for {0}
+REQUEST_PARAMETERS_MAP=Request parameters map {0}
+SET_MYFACES_SEQUENCE_INFO=Set MyFaces sequence to {0}
+SKIP_ENCODING_HTML_INFO=Skip encoding HTML for Script Resource with key [{0}] due to AJAX request
+SKIP_ENCODE_BEGIN_HTML_INFO=Skip encodeBegin HTML for Script Resource with key [{0}] due to AJAX request
+SKIP_ENCODE_END_HTML_INFO=Skip encodeEnd HTML for Script Resource with key [{0}] due to AJAX request
+QUERY_STRING_BUILDING_ERROR=Error building query string for store data
+BUILD_RESOURCE_URI_INFO=Build URI for Resource with key [{0}] as \: {1}
+RESTORE_DATA_FROM_RESOURCE_URI_INFO=Restore data object for Resource with key [{0}] from uri string \: {1}
+DESERIALIZE_DATA_INPUT_ERROR=Input error for deserialize data
+DATA_CLASS_NOT_FOUND_ERROR=Data class for restore not found
+METHOD_NOT_IMPLEMENTED=Method {0} not implemented
+ENCODE_HTML_INFO=Encode HTML for Resource with key [{0}]
+ENCODE_HTML_INFO_2=Encode HTML for Resource with key [{0}] and attributes\: {1}
+ENCODE_BEGIN_HTML_INFO=EncodeBegin HTML for Resource with key [{0}] and attributes: {1}
+ENCODE_END_HTML_INFO=EncodeEnd HTML for Resource with key [{0}]
+SEND_CONTENT_INFO=Send content data for Resource with key [{0}]
+NO_INPUT_STREAM_ERROR=Could not get Input stream for resource\: {0}
+SET_RESPONSE_HEADERS_INFO=Set response http headers for Resource with key [{0}]
+BUILD_RESOURCE_INFO=build new resource for path {0}
+NO_RESOURCE_REGISTERED_ERROR=Resource not registered\: {0}
+NO_RESOURCE_REGISTERED_ERROR_2=Not registered type of resource {0} allowed extentions is {1}
+NO_RESOURCE_EXISTS_ERROR=Resource not exist in classpath\: {0}
+INSTANTIATE_RESOURCE_ERROR=Error for instatiate resource from {0}
+INSTANTIATE_CLASS_ERROR=Instatiate class not InternetResource
+STATIC_RESOURCE_NOT_FOUND_ERROR=Static resource not found for path {0}
+PARSING_IF_MODIFIED_SINCE_WARNING=Error in parsing request If-Modified-Since header
+GET_CONTENT_FROM_CACHE_INFO=Get content from cache for resource {0}
+CONTENT_NOT_FOUND_ERROR=Content not found in cache for resource {0}
+SEND_RESOURCE_ERROR=Error on send resource
+SEND_RESOURCE_ERROR_2=Error on send new resource for cache by {0}
+READING_PROPERTIES_ERROR=Error reading properties from {0}
+SEND_IMAGE_ERROR=Error send image from resource {0}
+SEND_IMAGE_ERROR_2=Error send image
+SKIP_ENCODE_BEGIN_HTML_INFO_2=Skip begin encoding HTML for Resource with key [{0}] due to previsius rendering
+MARK_AS_RENDERED_INFO=Mark in context Resource with key [{0}] as rendered
+SKIP_ENCODE_END_HTML_INFO_2=Skip end encoding HTML for Resource with key [{0}] due to previsius rendering
+VARIABLE_SUBSTITUTION_ERROR=Could not perform variable substitution.
+SET_SKIN_FACTORY_INFO=Class name for SkinFactory set to {0} by META-INF/services
+CREATING_SKIN_FACTORY_ERROR=Unhandled exception then creating instance
+NULL_SKIN_NAME_ERROR=Name for current Skin calculated as null
+CREATE_SKIN_INFO=Create new Skin instance for name {0}
+DEFAULT_PROPERTIES_NOT_FOUND_ERROR=Default properties for skin not found in {0}
+SKIN_PROPERTIES_IO_ERROR=Attempt to load Skin property file caused IOError
+SKIN_NOT_FOUND_ERROR=Skin with name {0} not found
+ACESSING_SKIN_PROPERTY_AS_ARRAY_ERROR=Attempt to access to skin property as array
+ACESSING_SKIN_PROPERTY_ERROR=Attempt to access to skin property not as string parameter
+SKIN_PROPERTIES_READ_ONLY_ERROR=Skin properties is read-only
+NO_VALUE_HOLDER_ERROR=Component {0} is no ValueHolder, cannot set value.
+NO_EDITABLE_VALUE_HOLDER_ERROR=Component {0} is no EditableValueHolder
+INVALID_VALIDATION_EXPRESSION=Component {0} has invalid validation expression {1}
+NO_ACTION_SOURCE_ERROR=Component {0} is no ActionSource
+INVALID_ACTION_LISTENER=Component {0} has invalid actionListener value\: {1}
+INVALID_VALUE_CHANGE_LISTENER=Component {0} has invalid valueChangedListener expression {1}
+NO_VALUE_REFERENCE_ERROR=Component {0} attribute {1} must be a value reference, was {2}
+NO_BYTE_ARRAY_ERROR=Parameter supplied to Base64 decode is not a byte[]
+BUFFER_TYPE_ERROR=Wrong Destination Buffer type
+IMAGE_ERROR=Image must be 8-bit
+CANNOT_WRITE_RASTERS=Cannot write rasters
+NULL_OUTPUT_ERROR=output was not set
+IMAGE_NOT_BUFFERED_ERROR=RenderedImage is not a BufferedImage
+NOT_DATA_OUTPUT_ERROR=output is not a DataOutput
+NULL_COLOR_PARAMETER_ERROR=Parameter "color" for convert from HTML to java is null
+DECODE_COLOR_PARAMETER_ERROR=Parameter "color" for convert from HTML to java can not be decoded\: [{0}], reason\: {1}
+NULL_COLOR_PARAMETER_ERROR_2=Parameter "color" for convert from java.awt.Color to HTML is null
+DECODE_PARAMETER_ERROR=Parameter "{0}" for convert from HTML to java can not be decoded\: [{1}], reason\: {2}
+IMAGE_GENERATOR_CLASS_NOT_FOUND=The imageGenerator class cannot be found\: {0}
+CREATING_IMAGE_GENERATOR_ERROR=The ImageGenerator instance could not be created\: {0}
+INVALID_COMMENT_INDEX=Not a valid comment index\: {0}
+LOADING_IMAGE_ERROR=Error loading image
+NOT_INDEXED_IMAGE_ERROR=Image is not indexed!
+INVALID_RADIUS=Radius must be greater than 0.
+INVALID_ATTRIBUTE_VALUE=Value {0} of tag {1} attribute is incorrect.
+VALUE_BINDING_TYPE_ERROR=ValueBinding for UISelectMany must be of type List or Array
+NO_CONVERTER_FOUND_ERROR=No Converter for type {0} found
+GRABBER_ERROR=Grabber returned false\: {0}
+TOOMANY_COLORS_ERROR=Too many colors.
+GET_RESOURCE_AS_STREAM_ERROR=ServletContext not allow to getResourceAsStream for {0}
+PARSING_WEB_XML_IO_ERROR=Error parsing web.xml due to IOexception
+PARSING_WEB_XML_SAX_ERROR=Error parsing web.xml due to SAX exception
+NULL_FILTER_NAME_WARNING=Filter name for definition is null
+FILTER_NOT_FOUND_ERROR=Filter definition not found for name {0}
+FILTER_NOT_CONFIGURED_ERROR=Filter for name {0} not configured in web.xml
+NO_PREFIX_OR_SUFFIX_IN_FILTER_MAPPING_ERROR=Filter mapping for chameleon filter {0} do not contain wilcard prefix or suffix
+CONFIG_INITIALIZATION_ERROR={0} during config initialization for field {1} with value [{2}]: {3}
+FIELD_READING_ERROR={0} when reading field {1}
+CONFIG_INITIALIZATION_ERROR_2={0} during config initialization for field {1}
+DOM_METHOD_NOT_SUPPORTED=DOM method not supported
+METHOD_NOT_SUPPORTED=Method {0} not supported
+NAMED_ITEM_NOT_FOUND_ERROR=Named item {0} not found
+AJAX_SUPPORT_REQUEST_PARAMETER_INFO=Have request parameter for AjaxSupport component {0}
+COMMAND_LINK_SUBMIT_INFO=CommandLink component {0} submit request
+COMMAND_LINK_NOT_IN_FORM_WARNING=CommandLink {0} not enclosed in form
+MUST_BE_EXPRESSION_ERROR=Must be expression to modifyable property
+NOT_PARENT_AJAX_CONTAINER_ERROR=Parent is not of type AjaxContainer, type is\: {0}
+NOT_PARENT_AJAX_COMPONENT_ERROR=Parent component {0} for a ajaxListener is not source of AjaxEvent's
+MUST_BE_LITERAL_ERROR=Must be literal
+FACET_TAG_MANY_CHILDREN_ERROR=Facet Tag can only have one child UIComponent
+NO_UI_COMPONENT_TAG_ANCESTOR_ERROR={0} has no UIComponentTag ancestor
+NO_VALUE_REFERENCE_ERROR_2=property attribute is no valid value reference\: {0}
+NULL_TYPE_ATTRIBUTE_ERROR=type attribute not set
+INSTANTIATE_LISTENER_ERROR=Listener class {0} for Component {1} is not instantiable
+NOT_AJAX_CONTAINER_ERROR=Component {0} is no AjaxContainer
+INVALID_EXPRESSION=Invalid expression {0}
+NOT_INSTANCE_OF_ERROR={0} is not instance of {1}
+UNSUPPORTED_ENCODING_ERROR=Unsupported encoding\: {0}
+UNSUPPORTED_INPUT_SOURCE_ERROR=Unsupported type of input source\: {0}
+STRING_CONVERSION_ERROR=String to UTF-8 conversion failed\: {0}
+UTF_CONVERSION_ERROR=UTF-8 to string conversion failed\: {0}
+READ_ONLY_NODE_ERROR=Node is read only
+AJAX_VIEW_EXPIRED=View state could't be restored - reload page ?
+SKIN_CYCLIC_REFERENCE=Cyclic reference in Skin configuration for property \: {0}
+SKIN_ILLEGAL_REFERENCE=Reference for property "{0}" not present in Skin configuration
+NULL_ATTRIBUTE_ERROR="Requied attribute {0} for component {1} is null
\ No newline at end of file
Copied: trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/output.properties (from rev 1590, trunk/framework/impl/src/main/resources/org/ajax4jsf/framework/ajax/xmlfilter/output.properties)
===================================================================
--- trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/output.properties (rev 0)
+++ trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/output.properties 2007-07-11 00:20:34 UTC (rev 1594)
@@ -0,0 +1,4 @@
+method = xml
+omit-xml-declaration = no
+doctype-public = -//W3C//DTD XHTML 1.0 Transitional//EN
+doctype-system = http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
\ No newline at end of file
Copied: trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/tidy (from rev 1590, trunk/framework/impl/src/main/resources/org/ajax4jsf/framework/ajax/xmlfilter/tidy)
Deleted: trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/tidy/tidy.properties
===================================================================
--- trunk/framework/impl/src/main/resources/org/ajax4jsf/framework/ajax/xmlfilter/tidy/tidy.properties 2007-07-10 19:28:19 UTC (rev 1590)
+++ trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/tidy/tidy.properties 2007-07-11 00:20:34 UTC (rev 1594)
@@ -1,55 +0,0 @@
-add-xml-decl=false
-doctype=ignore
-#add-xml-space=
-#alt-text=
-#assume-xml-procins=
-break-before-br=false
-#char-encoding=1
-#clean=
-#drop-empty-paras=
-#drop-font-tags=
-#enclose-block-text=
-#enclose-text=
-#error-file=
-#fix-bad-comments=
-#hide-endtags=
-indent-attributes=false
-#indent-spaces=2
-#indent=
-#input-xml=
-#keep-time=
-#literal-attributes=
-#logical-emphasis=
-#markup=
-#new-blocklevel-tags=
-#new-empty-tags=
-#new-inline-tags=
-#new-pre-tags=
-numeric-entities=true
-#output-xhtml=true
-#output-xml=true
-quiet=true
-#quote-ampersand=true
-#quote-marks=
-#quote-nbsp=
-#raw=
-show-warnings=true
-#slide-style=
-#split=
-#tab-size=4
-tidy-mark=false
-uppercase-attributes=false
-uppercase-tags=false
-#word-2000=
-#wrap-asp=
-#wrap-jste=
-#wrap-php=
-#wrap-script-literals=false
-#wrap-sections=
-wrap=0
-#write-back=
-join-classes=true
-join-styles=true
-#literal-attributes=true
-smart-indent=false
-trim-empty-elements=false
\ No newline at end of file
Copied: trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/tidy/tidy.properties (from rev 1593, trunk/framework/impl/src/main/resources/org/ajax4jsf/framework/ajax/xmlfilter/tidy/tidy.properties)
===================================================================
--- trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/tidy/tidy.properties (rev 0)
+++ trunk/framework/impl/src/main/resources/org/ajax4jsf/webapp/tidy/tidy.properties 2007-07-11 00:20:34 UTC (rev 1594)
@@ -0,0 +1,55 @@
+add-xml-decl=false
+doctype=ignore
+#add-xml-space=
+#alt-text=
+#assume-xml-procins=
+break-before-br=false
+#char-encoding=1
+#clean=
+#drop-empty-paras=
+#drop-font-tags=
+#enclose-block-text=
+#enclose-text=
+#error-file=
+#fix-bad-comments=
+#hide-endtags=
+indent-attributes=false
+#indent-spaces=2
+#indent=
+#input-xml=
+#keep-time=
+#literal-attributes=
+#logical-emphasis=
+#markup=
+#new-blocklevel-tags=
+#new-empty-tags=
+#new-inline-tags=
+#new-pre-tags=
+numeric-entities=true
+#output-xhtml=true
+#output-xml=true
+quiet=true
+#quote-ampersand=true
+#quote-marks=
+#quote-nbsp=
+#raw=
+show-warnings=true
+#slide-style=
+#split=
+#tab-size=4
+tidy-mark=false
+uppercase-attributes=false
+uppercase-tags=false
+#word-2000=
+#wrap-asp=
+#wrap-jste=
+#wrap-php=
+#wrap-script-literals=false
+#wrap-sections=
+wrap=0
+#write-back=
+join-classes=true
+join-styles=true
+#literal-attributes=true
+smart-indent=false
+trim-empty-elements=false
\ No newline at end of file
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoParserTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoParserTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoParserTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -38,6 +38,7 @@
parser = new NekkoParser();
parser.setInputEncoding("UTF-8");
parser.setOutputEncoding("UTF-8");
+ parser.init();
super.setUp();
}
Modified: trunk/sandbox/samples/scrollable-grid-demo/src/main/webapp/WEB-INF/lib/ajax4jsf-1.1.2-SNAPSHOT.jar
===================================================================
(Binary files differ)
Modified: trunk/sandbox/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
===================================================================
--- trunk/sandbox/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -6,7 +6,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase;
+import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
import org.ajax4jsf.framework.skin.Skin;
import org.richfaces.component.UIToolTip;
import org.richfaces.renderkit.html.image.cornerimages.BottomLeftToolTipCornerImage;
Modified: trunk/sandbox/tooltip/src/main/templates/org/richfaces/htmltooltip.jspx
===================================================================
--- trunk/sandbox/tooltip/src/main/templates/org/richfaces/htmltooltip.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/tooltip/src/main/templates/org/richfaces/htmltooltip.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -15,8 +15,8 @@
/org/richfaces/renderkit/html/css/tooltip.xcss
</h:styles>
<h:scripts>
- new org.ajax4jsf.framework.resource.PrototypeScript(),
- new org.ajax4jsf.framework.ajax.AjaxScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
+ new org.ajax4jsf.javascript.AjaxScript(),
/org/richfaces/renderkit/html/scripts/utils.js,
/org/richfaces/renderkit/html/scripts/tooltip.js
</h:scripts>
Modified: trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -31,7 +31,7 @@
public class CalendarRendererBase extends TemplateEncoderRendererBase {
/* (non-Javadoc)
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
*/
protected Class getComponentClass() {
return UICalendar.class;
Modified: trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -11,7 +11,7 @@
component="org.richfaces.component.UICalendar"
>
<f:clientid var="clientId"/>
- <h:scripts>new org.ajax4jsf.framework.resource.PrototypeScript(),new org.ajax4jsf.framework.ajax.AjaxScript(),/org/richfaces/renderkit/html/scripts/utils.js,/org/richfaces/renderkit/html/scripts/json/json-dom.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.javascript.PrototypeScript(),new org.ajax4jsf.javascript.AjaxScript(),/org/richfaces/renderkit/html/scripts/utils.js,/org/richfaces/renderkit/html/scripts/json/json-dom.js</h:scripts>
<div id="#{clientId}"
x:passThruWithExclusions="value,name,type,id"
>
Modified: trunk/sandbox/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
===================================================================
--- trunk/sandbox/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -28,8 +28,8 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
-import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.compiler.TemplateContext;
import org.ajax4jsf.framework.skin.Skin;
import org.ajax4jsf.framework.util.style.CSSFormat;
import org.richfaces.component.UIPanelMenu;
@@ -45,7 +45,7 @@
import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangle;
import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangleDown;
import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangleUp;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
* @author hans
Modified: trunk/sandbox/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
===================================================================
--- trunk/sandbox/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -30,7 +30,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.framework.util.javascript.JSFunction;
import org.richfaces.component.UIPanelMenu;
import org.richfaces.component.UIPanelMenuGroup;
@@ -40,7 +40,7 @@
public class PanelMenuRenderer extends PanelMenuRendererBase {
/* (non-Javadoc)
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
*/
protected Class getComponentClass() {
return UIComponent.class;
Modified: trunk/sandbox/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx
===================================================================
--- trunk/sandbox/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -15,8 +15,8 @@
/org/richfaces/renderkit/html/css/panelMenu.xcss
</h:styles>
<h:scripts>
- new org.ajax4jsf.framework.resource.PrototypeScript(),
- new org.ajax4jsf.framework.ajax.AjaxScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
+ new org.ajax4jsf.javascript.AjaxScript(),
/org/richfaces/renderkit/html/scripts/utils.js,
/org/richfaces/renderkit/html/scripts/panelMenu.js,
</h:scripts>
Modified: trunk/sandbox/ui/panelmenu/src/test/java/org/richfaces/component/PanelMenuComponentTest.java
===================================================================
--- trunk/sandbox/ui/panelmenu/src/test/java/org/richfaces/component/PanelMenuComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/panelmenu/src/test/java/org/richfaces/component/PanelMenuComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -64,8 +64,8 @@
};
static {
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
javaScripts.add("org/richfaces/renderkit/html/scripts/utils.js");
javaScripts.add("org/richfaces/renderkit/html/scripts/panelMenu.js");
}
Modified: trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java
===================================================================
--- trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -5,7 +5,7 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.framework.util.javascript.JSFunction;
import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
import org.ajax4jsf.framework.util.javascript.JSReference;
Modified: trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java
===================================================================
--- trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -15,7 +15,7 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.component.UIScrollableGrid;
/**
Modified: trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
===================================================================
--- trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -14,11 +14,11 @@
import org.ajax4jsf.ajax.repeat.DataVisitor;
import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.ComponentVariables;
-import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.ComponentVariables;
+import org.ajax4jsf.renderkit.ComponentsVariableResolver;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.framework.util.javascript.JSFunction;
import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
import org.ajax4jsf.framework.util.javascript.JSReference;
Modified: trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
===================================================================
--- trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -16,7 +16,7 @@
import org.ajax4jsf.ajax.repeat.DataVisitor;
import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UIScrollableGrid;
import org.richfaces.model.selection.ClientSelection;
import org.richfaces.model.selection.Selection;
Modified: trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/utils/TemplateLoader.java
===================================================================
--- trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/utils/TemplateLoader.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/utils/TemplateLoader.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -3,7 +3,7 @@
*/
package org.richfaces.utils;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/sandbox/ui/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
===================================================================
--- trunk/sandbox/ui/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -17,8 +17,8 @@
</h:styles>
<h:scripts>
- new org.ajax4jsf.framework.resource.PrototypeScript(),
- new org.ajax4jsf.framework.ajax.AjaxScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
+ new org.ajax4jsf.javascript.AjaxScript(),
/org/richfaces/renderkit/html/scripts/scrollable-grid.js
</h:scripts>
Modified: trunk/sandbox/ui/scrollable-grid/src/test/java/org/richfaces/renderkit/html/ScrollableGridRendererTest.java
===================================================================
--- trunk/sandbox/ui/scrollable-grid/src/test/java/org/richfaces/renderkit/html/ScrollableGridRendererTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/scrollable-grid/src/test/java/org/richfaces/renderkit/html/ScrollableGridRendererTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -29,9 +29,9 @@
private static Set javaScripts = new HashSet();
static {
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
- javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
javaScripts.add("org/richfaces/renderkit/html/scripts/scrollable-grid.js");
}
Modified: trunk/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/component/UISimpleTogglePanel2.java
===================================================================
--- trunk/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/component/UISimpleTogglePanel2.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/component/UISimpleTogglePanel2.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -24,7 +24,7 @@
import org.ajax4jsf.framework.ajax.AjaxActionComponent;
import org.ajax4jsf.framework.ajax.AjaxComponent;
import org.ajax4jsf.framework.ajax.AjaxSource;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import javax.faces.component.ActionSource;
import javax.faces.context.FacesContext;
Modified: trunk/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanel2Renderer.java
===================================================================
--- trunk/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanel2Renderer.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanel2Renderer.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -24,7 +24,7 @@
*/
package org.richfaces.renderkit.html;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.component.UISimpleTogglePanel2;
import org.richfaces.event.SimpleToggle2Event;
@@ -38,7 +38,7 @@
//public class SimpleTogglePanelRenderer extends AjaxCommandLinkRenderer {
-public class SimpleTogglePanel2Renderer extends org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase {
+public class SimpleTogglePanel2Renderer extends org.ajax4jsf.renderkit.HeaderResourcesRendererBase {
//XXXX by nick - denis - seems there is a lot of code common to org.richfaces.renderkit.html.ToggleControlRenderer. Please commonize!
//private InternetResource[] _scripts = {new PrototypeScript(), getResource("scripts/simpleTogglePanel.js") };
Modified: trunk/sandbox/ui/simpleTogglePanel2/src/main/templates/simpleTogglePanel2.jspx
===================================================================
--- trunk/sandbox/ui/simpleTogglePanel2/src/main/templates/simpleTogglePanel2.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/sandbox/ui/simpleTogglePanel2/src/main/templates/simpleTogglePanel2.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -12,10 +12,10 @@
<f:clientid var="clientId"/>
<h:styles>css/simpleTogglePanel2.xcss</h:styles>
<h:scripts>
-new org.ajax4jsf.framework.resource.PrototypeScript(),
-new org.ajax4jsf.framework.ajax.AjaxScript(),
-new org.ajax4jsf.framework.ajax.ImageCacheScript(),
-/org/ajax4jsf/renderkit/html/scripts/form.js,
+new org.ajax4jsf.javascript.PrototypeScript(),
+new org.ajax4jsf.javascript.AjaxScript(),
+new org.ajax4jsf.javascript.ImageCacheScript(),
+/org/ajax4jsf/javascript/scripts/form.js,
/org/richfaces/renderkit/html/scripts/browser_info.js,
scripts/simpleTogglePanel2.js
</h:scripts>
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -70,7 +70,7 @@
private static final String MYFACES_HIDDEN_FIELD_SUFFIX = NamingContainer.SEPARATOR_CHAR
+ "_link_hidden_";
- private InternetResource[] _scripts = { getResource("scripts/form.js") };
+ private InternetResource[] _scripts = { getResource("/org/ajax4jsf/javascript/scripts/form.js") };
private static final String[] exclusions = { "onsubmit" };
Modified: trunk/ui/dataFilterSlider/src/main/templates/dataFilterSlider.jspx
===================================================================
--- trunk/ui/dataFilterSlider/src/main/templates/dataFilterSlider.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/dataFilterSlider/src/main/templates/dataFilterSlider.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -12,7 +12,7 @@
component="org.richfaces.component.UIDataFltrSlider">
<h:styles>css/dataFilterSlider.xcss</h:styles>
- <h:scripts>new org.ajax4jsf.resource.PrototypeScript(),scripts/scriptaculous-js-1.6.5/src/slider.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.javascript.PrototypeScript(),scripts/scriptaculous-js-1.6.5/src/slider.js</h:scripts>
<f:clientid var="clientId"/>
<f:resource name="org.richfaces.renderkit.html.images.SliderArrowImage" var="arrow" />
Modified: trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
===================================================================
--- trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -79,8 +79,8 @@
*/
static {
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
javaScripts.add("scripts/scriptaculous-js-1.6.5/src/slider.js");
}
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractDefinitionListRenderer.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractDefinitionListRenderer.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractDefinitionListRenderer.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -28,7 +28,6 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.UIDataAdaptor;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
* @author shura
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractListRenderer.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractListRenderer.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractListRenderer.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -27,7 +27,6 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.UIDataAdaptor;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
* @author shura
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -31,7 +31,6 @@
import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
-import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.Row;
Modified: trunk/ui/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java
===================================================================
--- trunk/ui/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -36,7 +36,6 @@
import javax.faces.el.ValueBinding;
import javax.faces.model.ListDataModel;
-import org.ajax4jsf.component.AjaxSupport;
import org.ajax4jsf.component.UIAjaxSupport;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.collections.Predicate;
Modified: trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
===================================================================
--- trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -31,7 +31,7 @@
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.event.DataScrollerEvent;
import org.richfaces.event.DataScrollerListener;
import org.richfaces.event.DataScrollerSource;
Modified: trunk/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java
===================================================================
--- trunk/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -29,11 +29,11 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.ComponentVariables;
-import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.ComponentVariables;
+import org.ajax4jsf.renderkit.ComponentsVariableResolver;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.richfaces.component.UIDatascroller;
import org.richfaces.event.DataScrollerEvent;
Modified: trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
===================================================================
--- trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -12,7 +12,7 @@
<h:styles>css/datascroller.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.resource.PrototypeScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript(),
</h:scripts>
Modified: trunk/ui/datascroller/src/test/java/org/richfaces/component/DatascrollerComponentTest.java
===================================================================
--- trunk/ui/datascroller/src/test/java/org/richfaces/component/DatascrollerComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/datascroller/src/test/java/org/richfaces/component/DatascrollerComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -56,8 +56,8 @@
private static Set javaScripts = new HashSet();
static {
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScriptpt");
}
private UIDatascroller scroller;
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/component/UIDragIndicator.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/component/UIDragIndicator.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/component/UIDragIndicator.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -21,12 +21,7 @@
package org.richfaces.component;
-import java.util.Map;
-
-import javax.faces.application.Application;
import javax.faces.component.UIComponentBase;
-import javax.faces.component.UIOutput;
-import javax.faces.context.FacesContext;
/**
* Component for render Drag indicator ( marker )
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -30,8 +30,8 @@
import javax.faces.event.FacesEvent;
import org.ajax4jsf.javascript.DnDScript;
+import org.ajax4jsf.javascript.PrototypeScript;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.resource.PrototypeScript;
import org.richfaces.component.Draggable;
import org.richfaces.component.Dropzone;
import org.richfaces.event.DragEvent;
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -32,9 +32,9 @@
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.javascript.PrototypeScript;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.resource.PrototypeScript;
import org.richfaces.component.Draggable;
import org.richfaces.component.Dropzone;
import org.richfaces.event.DropEvent;
Modified: trunk/ui/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx
===================================================================
--- trunk/ui/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -12,7 +12,7 @@
xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
<h:scripts>
- new org.ajax4jsf.resource.PrototypeScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript(),
new org.ajax4jsf.javascript.DnDScript(),
/org/richfaces/renderkit/html/scripts/utils.js,
Modified: trunk/ui/drag-drop/src/test/java/org/richfaces/component/DragDropTest.java
===================================================================
--- trunk/ui/drag-drop/src/test/java/org/richfaces/component/DragDropTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/drag-drop/src/test/java/org/richfaces/component/DragDropTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -40,8 +40,8 @@
private static Set javaScripts = new HashSet();
static {
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScriptpt");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
javaScripts.add("scripts/browser_info.js");
javaScripts.add("org.ajax4jsf.dnd.DnDScript");
javaScripts.add("scripts/events.js");
Modified: trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
===================================================================
--- trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -12,7 +12,7 @@
<h:styles>css/dropdownmenu.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.resource.PrototypeScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript(),
scripts/menu.js
</h:scripts>
Modified: trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java
===================================================================
--- trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -50,8 +50,8 @@
private static Set javaScripts = new HashSet();
static {
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScriptpt");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
javaScripts.add("org.ajax4jsf.util.command.CommandScript");
javaScripts.add("scripts/menu.js");
}
Modified: trunk/ui/gmap/src/main/templates/gmap.jspx
===================================================================
--- trunk/ui/gmap/src/main/templates/gmap.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/gmap/src/main/templates/gmap.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -27,7 +27,7 @@
<c:set var="enableDoubleClickZoom" value="#{component.attributes['enableDoubleClickZoom']}"/>
<c:set var="enableContinuousZoom" value="#{component.attributes['enableContinuousZoom']}"/>
<h:styles>css/gmap.xcss</h:styles>
- <h:scripts>new org.ajax4jsf.resource.PrototypeScript(),script/gmap.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.javascript.PrototypeScript(),script/gmap.js</h:scripts>
<div id="#{clientId}" class="dr-gmap rich-gmap #{component.attributes['styleClass']}"
x:passThruWithExclusions="id, styleClass"
Modified: trunk/ui/gmap/src/test/java/org/richfaces/component/GmapComponentTest.java
===================================================================
--- trunk/ui/gmap/src/test/java/org/richfaces/component/GmapComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/gmap/src/test/java/org/richfaces/component/GmapComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -48,8 +48,8 @@
private final static String TEST_STYLE = "width:500px; height:400px";
static {
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScriptpt");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
javaScripts.add("script/gmap.js");
javaScripts.add("http://maps.google.com");
}
Modified: trunk/ui/inputnumber-slider/src/main/templates/inputNumberSlider.jspx
===================================================================
--- trunk/ui/inputnumber-slider/src/main/templates/inputNumberSlider.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/inputnumber-slider/src/main/templates/inputNumberSlider.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -10,7 +10,7 @@
component="org.richfaces.component.UIInputNumberSlider"
>
<h:styles>css/slider.xcss</h:styles>
- <h:scripts>new org.ajax4jsf.resource.PrototypeScript(),script/SliderScript.js,/org/richfaces/renderkit/html/scripts/browser_info.js,/org/richfaces/renderkit/html/scripts/events.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.javascript.PrototypeScript(),script/SliderScript.js,/org/richfaces/renderkit/html/scripts/browser_info.js,/org/richfaces/renderkit/html/scripts/events.js</h:scripts>
<f:clientid var="clientId"/>
<f:resource name="/org/richfaces/renderkit/html/images/spacer.gif" var="spacer" />
Modified: trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
===================================================================
--- trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -75,8 +75,8 @@
*/
static {
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScriptpt");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
javaScripts.add("script/SliderScript.js");
javaScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
javaScripts.add("org/richfaces/renderkit/html/scripts/events.js");
Modified: trunk/ui/inputnumber-spinner/src/main/templates/inputNumberSpinner.jspx
===================================================================
--- trunk/ui/inputnumber-spinner/src/main/templates/inputNumberSpinner.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/inputnumber-spinner/src/main/templates/inputNumberSpinner.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -17,7 +17,7 @@
<f:resource name="org.richfaces.renderkit.html.images.buttons.SpinnerButtonDown"
var="down_arrow" />
- <h:scripts>new org.ajax4jsf.resource.PrototypeScript(),script/SpinnerScript.js,/org/richfaces/renderkit/html/scripts/browser_info.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.javascript.PrototypeScript(),script/SpinnerScript.js,/org/richfaces/renderkit/html/scripts/browser_info.js</h:scripts>
<h:styles>css/spinner.xcss</h:styles>
<table width="2%" class="dr-spnr-c rich-spinner-c #{component.attributes['styleClass']}" id="#{clientId}" cellspacing="0" cellpadding="0" border="0" style="#{component.attributes['style']}">
Modified: trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
===================================================================
--- trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -68,8 +68,8 @@
private static Set javaScripts = new HashSet();
static {
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScriptpt");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
javaScripts.add("script/SpinnerScript.js");
javaScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
javaScripts.add("org/richfaces/renderkit/html/scripts/events.js");
Modified: trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
===================================================================
--- trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -13,7 +13,7 @@
<h:styles>css/menucomponents.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.resource.PrototypeScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript()
</h:scripts>
Modified: trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
===================================================================
--- trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -12,10 +12,10 @@
<h:styles>css/menucomponents.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.resource.PrototypeScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript(),
/org/richfaces/renderkit/html/scripts/utils.js,
- /org/ajax4jsf/renderkit/html/scripts/form.js,
+ /org/ajax4jsf/javascript/scripts/form.js,
/org/richfaces/renderkit/html/scripts/form.js
</h:scripts>
Modified: trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuSeparatorComponentTest.java
===================================================================
--- trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuSeparatorComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuSeparatorComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -40,8 +40,8 @@
/* private static Set javaScripts = new HashSet();
static {
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript()");
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript()");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript()");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScriptpt()");
javaScripts.add("org.ajax4jsf.util.command.CommandScript()");
}
*/
Modified: trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
===================================================================
--- trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -16,7 +16,7 @@
/org/richfaces/renderkit/html/css/modalPanel.xcss
</h:styles>
<h:scripts>
- new org.ajax4jsf.resource.PrototypeScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
/org/richfaces/renderkit/html/scripts/utils.js,
/org/richfaces/renderkit/html/scripts/modalPanel.js,
/org/richfaces/renderkit/html/scripts/modalPanelBorders.js,
Modified: trunk/ui/modal-panel/src/test/java/org/richfaces/component/ModalPanelComponentTest.java
===================================================================
--- trunk/ui/modal-panel/src/test/java/org/richfaces/component/ModalPanelComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/modal-panel/src/test/java/org/richfaces/component/ModalPanelComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -55,8 +55,8 @@
};
static {
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScriptpt");
javaScripts.add("scripts/utils.js");
javaScripts.add("scripts/modalPanel.js");
javaScripts.add("scripts/modalPanelBorders.js");
Modified: trunk/ui/panelbar/src/main/java/org/richfaces/component/UIPanelBar.java
===================================================================
--- trunk/ui/panelbar/src/main/java/org/richfaces/component/UIPanelBar.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/panelbar/src/main/java/org/richfaces/component/UIPanelBar.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -25,7 +25,6 @@
import java.util.List;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.event.AbortProcessingException;
Modified: trunk/ui/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarItemRendererBase.java
===================================================================
--- trunk/ui/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarItemRendererBase.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarItemRendererBase.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -21,7 +21,7 @@
package org.richfaces.renderkit.html;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.richfaces.component.UIPanelBarItem;
public abstract class PanelBarItemRendererBase extends RendererBase {
Modified: trunk/ui/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarRendererBase.java
===================================================================
--- trunk/ui/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarRendererBase.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarRendererBase.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -30,11 +30,11 @@
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
-import org.ajax4jsf.framework.ajax.AjaxScript;
-import org.ajax4jsf.framework.ajax.ImageCacheScript;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
+import org.ajax4jsf.javascript.AjaxScript;
+import org.ajax4jsf.javascript.ImageCacheScript;
+import org.ajax4jsf.javascript.PrototypeScript;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.PrototypeScript;
import org.richfaces.component.UIPanelBar;
import org.richfaces.component.UIPanelBarItem;
import org.richfaces.event.SwitchablePanelSwitchEvent;
Modified: trunk/ui/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java
===================================================================
--- trunk/ui/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -26,18 +26,11 @@
import java.util.List;
import java.util.Set;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
import javax.faces.component.html.HtmlForm;
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
-import org.ajax4jsf.framework.ajax.AjaxScript;
-import org.ajax4jsf.framework.ajax.ImageCacheScript;
-import org.ajax4jsf.resource.PrototypeScript;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.ajax4jsf.tests.MockViewRoot;
import org.apache.commons.collections.Buffer;
Modified: trunk/ui/simpleTogglePanel/src/main/templates/simpleTogglePanel.jspx
===================================================================
--- trunk/ui/simpleTogglePanel/src/main/templates/simpleTogglePanel.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/simpleTogglePanel/src/main/templates/simpleTogglePanel.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -12,10 +12,10 @@
<f:clientid var="clientId"/>
<h:styles>css/simpleTogglePanel.xcss</h:styles>
<h:scripts>
-new org.ajax4jsf.resource.PrototypeScript(),
+new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript(),
new org.ajax4jsf.javascript.ImageCacheScript(),
-/org/ajax4jsf/renderkit/html/scripts/form.js,
+/org/ajax4jsf/javascript/scripts/form.js,
/org/richfaces/renderkit/html/scripts/browser_info.js,
scripts/simpleTogglePanel.js
</h:scripts>
Modified: trunk/ui/simpleTogglePanel/src/test/java/org/richfaces/component/SimpleTogglePanelComponentTest.java
===================================================================
--- trunk/ui/simpleTogglePanel/src/test/java/org/richfaces/component/SimpleTogglePanelComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/simpleTogglePanel/src/test/java/org/richfaces/component/SimpleTogglePanelComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -47,10 +47,10 @@
private static Set javaScripts = new HashSet();
static {
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
- javaScripts.add("org.ajax4jsf.framework.ajax.ImageCacheScript");
- javaScripts.add("org/ajax4jsf/renderkit/html/scripts/form.js");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScriptpt");
+ javaScripts.add("org.ajax4jsf.javascript.ImageCacheScript");
+ javaScripts.add("org/ajax4jsf/javascript/scripts/form.js");
javaScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
javaScripts.add("scripts/simpleTogglePanel.js");
}
Modified: trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
--- trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -80,8 +80,8 @@
* Additional scripts.
*/
private final InternetResource[] additionalScripts = {
- new org.ajax4jsf.resource.PrototypeScript(),
- new org.ajax4jsf.resource.SmartPositionScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
+ new org.ajax4jsf.javascript.SmartPositionScript(),
getResource("/org/richfaces/renderkit/html/scripts/browser_info.js"),
getResource("scripts/scriptaculo.js"),
getResource("scripts/suggestionbox.js")};
Modified: trunk/ui/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java
===================================================================
--- trunk/ui/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -42,7 +42,7 @@
private static Set javaScripts = new HashSet();
static {
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
javaScripts.add("prototype.js");
javaScripts.add("org.ajax4jsf.resource.SmartPositionScript");
javaScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
Modified: trunk/ui/tabPanel/src/main/templates/tabPanel.jspx
===================================================================
--- trunk/ui/tabPanel/src/main/templates/tabPanel.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/tabPanel/src/main/templates/tabPanel.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -12,11 +12,11 @@
<h:styles>css/tabPanel.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.resource.PrototypeScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript(),
new org.ajax4jsf.javascript.ImageCacheScript(),
/org/richfaces/renderkit/html/scripts/browser_info.js,
- /org/ajax4jsf/renderkit/html/scripts/form.js,
+ /org/ajax4jsf/javascript/scripts/form.js,
scripts/tabPanel.js
</h:scripts>
Modified: trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
===================================================================
--- trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -49,11 +49,11 @@
private static Set javaScripts = new HashSet();
static {
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
- javaScripts.add("org.ajax4jsf.framework.ajax.ImageCacheScript");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.javascript.ImageCacheScript");
javaScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
- javaScripts.add("org/ajax4jsf/renderkit/html/scripts/form.js");
+ javaScripts.add("org/ajax4jsf/javascript/scripts/form.js");
javaScripts.add("scripts/tabPanel.js");
}
Modified: trunk/ui/togglePanel/src/main/templates/toggleControl.jspx
===================================================================
--- trunk/ui/togglePanel/src/main/templates/toggleControl.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/togglePanel/src/main/templates/toggleControl.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -11,7 +11,7 @@
component="org.richfaces.component.UIToggleControl">
<h:styles>css/toggleControl.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.resource.PrototypeScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript(),
scripts/togglePanel.js
</h:scripts> <f:clientid var="clientId"/>
Modified: trunk/ui/togglePanel/src/test/java/org/richfaces/component/TogglePanelComponentTest.java
===================================================================
--- trunk/ui/togglePanel/src/test/java/org/richfaces/component/TogglePanelComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/togglePanel/src/test/java/org/richfaces/component/TogglePanelComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -50,8 +50,8 @@
private static Set javaScripts = new HashSet();
static {
- javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScriptpt");
javaScripts.add("scripts/togglePanel.js");
}
Modified: trunk/ui/tree/src/main/templates/htmlTree.jspx
===================================================================
--- trunk/ui/tree/src/main/templates/htmlTree.jspx 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/tree/src/main/templates/htmlTree.jspx 2007-07-11 00:20:34 UTC (rev 1594)
@@ -14,10 +14,10 @@
<h:styles>css/tree.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.resource.PrototypeScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
/org/ajax4jsf/framework/ajax/scripts/AJAX.js,
/org/richfaces/renderkit/html/scripts/utils.js,
- /org/ajax4jsf/renderkit/html/scripts/form.js,
+ /org/ajax4jsf/javascript/scripts/form.js,
/org/richfaces/renderkit/html/scripts/form.js,
/org/richfaces/renderkit/html/scripts/events.js,
/org/richfaces/renderkit/html/scripts/tree.js,
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2007-07-10 22:04:48 UTC (rev 1593)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2007-07-11 00:20:34 UTC (rev 1594)
@@ -73,7 +73,7 @@
static {
javaScripts.add("/org/richfaces/renderkit/html/scripts/json/json.js");
- javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScriptpt");
javaScripts.add("scripts/AJAX.js");
javaScripts.add("org.ajax4jsf.dnd.DnDScript");
@@ -83,7 +83,7 @@
javaScripts.add("/org/richfaces/renderkit/html/scripts/dnd/dnd-dropzone.js");
- javaScripts.add("/org/ajax4jsf/renderkit/html/scripts/form.js");
+ javaScripts.add("/org/ajax4jsf/javascript/scripts/form.js");
javaScripts.add("/org/richfaces/renderkit/html/scripts/form.js");
javaScripts.add("/org/richfaces/renderkit/html/scripts/events.js");
javaScripts.add("/org/richfaces/renderkit/html/scripts/tree.js");
18 years, 2 months
JBoss Rich Faces SVN: r1593 - in branches/3.0.2/sandbox/calendar/src/main: java/org/richfaces/component and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-07-10 18:04:48 -0400 (Tue, 10 Jul 2007)
New Revision: 1593
Modified:
branches/3.0.2/sandbox/calendar/src/main/config/component/calendar.xml
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java
Log:
slight fix for currentDate attribute
Modified: branches/3.0.2/sandbox/calendar/src/main/config/component/calendar.xml
===================================================================
--- branches/3.0.2/sandbox/calendar/src/main/config/component/calendar.xml 2007-07-10 19:44:45 UTC (rev 1592)
+++ branches/3.0.2/sandbox/calendar/src/main/config/component/calendar.xml 2007-07-10 22:04:48 UTC (rev 1593)
@@ -78,7 +78,7 @@
<name>currentDate</name>
<classname>java.util.Date</classname>
<description></description>
- <defaultvalue>new Date()</defaultvalue>
+ <defaultvalue>java.util.Calendar.getInstance(getTimeZone()).getTime()</defaultvalue>
</property>
</component>
</components>
Modified: branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
--- branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-07-10 19:44:45 UTC (rev 1592)
+++ branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-07-10 22:04:48 UTC (rev 1593)
@@ -80,9 +80,9 @@
public abstract void setPreloadDateRangeEnd(Date date);
- // public abstract Date getCurrentDate();
+ public abstract Date getCurrentDate();
- // public abstract void setCurrentDate(Date date);
+ public abstract void setCurrentDate(Date date);
public abstract CalendarDataModel getData();
@@ -92,14 +92,6 @@
private Date currentDate = null;
- public Date getCurrentDate() {
- return (this.currentDate);
- }
-
- public void setCurrentDate(Date currentDate) {
- this.currentDate = currentDate;
- }
-
public Converter getConverter(FacesContext context, UICalendar calendar) {
Converter converter = calendar.getConverter();
18 years, 2 months
JBoss Rich Faces SVN: r1591 - in trunk: framework/impl/src/main/java/org/ajax4jsf/util and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-10 15:43:06 -0400 (Tue, 10 Jul 2007)
New Revision: 1591
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/
trunk/framework/impl/src/main/java/org/ajax4jsf/taglib/
trunk/framework/impl/src/main/java/org/ajax4jsf/util/image/
trunk/framework/impl/src/main/java/org/richfaces/org/
trunk/framework/test/src/test/java/org/ajax4jsf/util/
Modified:
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java
Log:
packages and classes refactor in the "impl" project
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java 2007-07-10 19:28:19 UTC (rev 1590)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java 2007-07-10 19:43:06 UTC (rev 1591)
@@ -30,9 +30,9 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.richfaces.component.UIDragIndicator;
import org.richfaces.component.nsutils.NSUtils;
-import org.richfaces.org.apache.commons.lang.StringEscapeUtils;
/**
* Base renderer class for drag indicator ( marker ).
@@ -102,7 +102,7 @@
protected String getPredefinedMarker(FacesContext context, Object facetName) {
if (MARKERS_PREDEFINED.contains(facetName)) {
- return StringEscapeUtils.escapeJavaScript("<img alt=\"\" border=\"0\" width=\"16\" height=\"16\" src=\"" +
+ return ScriptUtils.toScript("<img alt=\"\" border=\"0\" width=\"16\" height=\"16\" src=\"" +
getResource("/org/richfaces/renderkit/html/images/" + facetName + ".gif").getUri(context, null) +"\" />");
}
Modified: trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java
===================================================================
--- trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java 2007-07-10 19:28:19 UTC (rev 1590)
+++ trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java 2007-07-10 19:43:06 UTC (rev 1591)
@@ -22,18 +22,19 @@
package org.richfaces.renderkit.html;
-import org.ajax4jsf.framework.util.CSSFormat;
+import java.io.IOException;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.util.HtmlDimensions;
+import org.ajax4jsf.util.style.CSSFormat;
import org.richfaces.component.UISeparator;
import org.richfaces.renderkit.html.images.BevelSeparatorImage;
import org.richfaces.renderkit.html.images.SimpleSeparatorImage;
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import java.io.IOException;
-
public class SeparatorRendererBase extends RendererBase {
private static final String[] SUPPORTED_TYPES = {
18 years, 2 months
JBoss Rich Faces SVN: r1590 - in trunk/framework: impl/src/main/java/org/ajax4jsf/taglib and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-10 15:28:19 -0400 (Tue, 10 Jul 2007)
New Revision: 1590
Added:
trunk/framework/test/src/test/java/org/ajax4jsf/webapp/
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/
trunk/framework/impl/src/main/java/org/ajax4jsf/taglib/html/
trunk/framework/impl/src/main/java/org/ajax4jsf/util/config/
trunk/framework/impl/src/main/java/org/ajax4jsf/util/image/imageio/
trunk/framework/test/src/test/java/org/ajax4jsf/framework/util/
trunk/framework/test/src/test/java/org/ajax4jsf/util/config/
Modified:
trunk/framework/test/src/test/java/org/ajax4jsf/webapp/AllTests.java
trunk/framework/test/src/test/java/org/ajax4jsf/webapp/WebXmlTest.java
Log:
packages and classes refactor in the "impl" project
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/webapp (from rev 1589, trunk/framework/test/src/test/java/org/ajax4jsf/util/config)
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/webapp/AllTests.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/util/config/AllTests.java 2007-07-10 19:14:51 UTC (rev 1589)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/webapp/AllTests.java 2007-07-10 19:28:19 UTC (rev 1590)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.util.config;
+package org.ajax4jsf.webapp;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -28,7 +28,7 @@
public static Test suite() {
TestSuite suite = new TestSuite(
- "Test for org.ajax4jsf.util.config");
+ "Test for org.ajax4jsf.webapp");
//$JUnit-BEGIN$
suite.addTestSuite(WebXmlTest.class);
//$JUnit-END$
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/webapp/WebXmlTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/util/config/WebXmlTest.java 2007-07-10 19:14:51 UTC (rev 1589)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/webapp/WebXmlTest.java 2007-07-10 19:28:19 UTC (rev 1590)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.util.config;
+package org.ajax4jsf.webapp;
import java.io.InputStream;
@@ -60,14 +60,14 @@
}
/*
- * Test method for 'org.ajax4jsf.util.config.WebXml.reset()'
+ * Test method for 'org.ajax4jsf.webapp.WebXml.reset()'
*/
public void testReset() {
}
/*
- * Test method for 'org.ajax4jsf.util.config.WebXml.init(ServletContext, String)'
+ * Test method for 'org.ajax4jsf.webapp.WebXml.init(ServletContext, String)'
*/
public void testInit() throws ServletException {
WebXml webXml = new WebXml();
@@ -79,14 +79,14 @@
}
/*
- * Test method for 'org.ajax4jsf.util.config.WebXml.getInstance()'
+ * Test method for 'org.ajax4jsf.webapp.WebXml.getInstance()'
*/
public void testGetInstance() {
}
/*
- * Test method for 'org.ajax4jsf.util.config.WebXml.getFacesResourceURL(FacesContext, String)'
+ * Test method for 'org.ajax4jsf.webapp.WebXml.getFacesResourceURL(FacesContext, String)'
*/
public void testGetFacesResourceURL() throws ServletException {
WebXml webXml = new WebXml();
@@ -98,21 +98,21 @@
}
/*
- * Test method for 'org.ajax4jsf.util.config.WebXml.getFacesResourceKey(HttpServletRequest)'
+ * Test method for 'org.ajax4jsf.webapp.WebXml.getFacesResourceKey(HttpServletRequest)'
*/
public void testGetFacesResourceKey() {
}
/*
- * Test method for 'org.ajax4jsf.util.config.WebXml.isFacesRequest(HttpServletRequest)'
+ * Test method for 'org.ajax4jsf.webapp.WebXml.isFacesRequest(HttpServletRequest)'
*/
public void testIsFacesRequest() {
}
/*
- * Test method for 'org.ajax4jsf.util.config.WebXml.setFilterName(String)'
+ * Test method for 'org.ajax4jsf.webapp.WebXml.setFilterName(String)'
*/
public void testSetFilterName() {
18 years, 2 months
JBoss Rich Faces SVN: r1589 - in trunk: framework/impl/src/main/java/org/ajax4jsf/framework and 60 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-10 15:14:51 -0400 (Tue, 10 Jul 2007)
New Revision: 1589
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/util/
trunk/framework/impl/src/main/java/org/ajax4jsf/util/GifEncoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/HtmlColor.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/HtmlDimensions.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/InputUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/SelectUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/ServicesUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Base64.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryDecoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryEncoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Codec.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Decoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/DecoderException.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Encoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/EncoderException.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URL64Codec.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URLCodec.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/config/
trunk/framework/impl/src/main/java/org/ajax4jsf/util/image/
trunk/framework/impl/src/main/java/org/ajax4jsf/util/image/imageio/
trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/
trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSFormat.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSSelector.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/FontFamily.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/FilterBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ServletBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/WebXml.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/HtmlComponentTagBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/SimpleActionMethodBinding.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentBodyTagBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentTagBase.java
trunk/framework/test/src/test/java/org/ajax4jsf/util/
trunk/framework/test/src/test/java/org/ajax4jsf/util/config/
trunk/framework/test/src/test/java/org/ajax4jsf/util/config/AllTests.java
trunk/framework/test/src/test/java/org/ajax4jsf/util/config/WebXmlTest.java
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/GifEncoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/HtmlColor.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/HtmlDimensions.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/InputUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/SelectUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/ServicesUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/config/
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/imageio/
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/style/
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Base64.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryDecoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryEncoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Codec.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Decoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/DecoderException.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Encoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/EncoderException.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URL64Codec.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URLCodec.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/config/FilterBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/config/ServletBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/config/WebXml.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/image/imageio/ImageIOGenerator.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/image/imageio/gif/
trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSFormat.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSSelector.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/FontFamily.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/HtmlComponentTagBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/SimpleActionMethodBinding.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentBodyTagBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentTagBase.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/util/config/
trunk/framework/test/src/test/java/org/ajax4jsf/util/config/AllTests.java
trunk/framework/test/src/test/java/org/ajax4jsf/util/config/WebXmlTest.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowImage.java
trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/codec/CodecTest.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java
trunk/ui/core/src/main/config/component/commandButton.xml
trunk/ui/core/src/main/config/component/commandLink.xml
trunk/ui/core/src/main/config/component/form.xml
trunk/ui/core/src/main/config/component/function.xml
trunk/ui/core/src/main/config/component/loadBundle.xml
trunk/ui/core/src/main/config/component/loadScript.xml
trunk/ui/core/src/main/config/component/loadStyle.xml
trunk/ui/core/src/main/config/component/log.xml
trunk/ui/core/src/main/config/component/mediaOutput.xml
trunk/ui/core/src/main/config/component/outputPanel.xml
trunk/ui/core/src/main/config/component/page.xml
trunk/ui/core/src/main/config/component/poll.xml
trunk/ui/core/src/main/config/component/portlet.xml
trunk/ui/core/src/main/config/component/push.xml
trunk/ui/core/src/main/config/component/region.xml
trunk/ui/core/src/main/config/component/repeat.xml
trunk/ui/core/src/main/config/component/status.xml
trunk/ui/core/src/main/config/component/support.xml
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java
trunk/ui/dataFilterSlider/src/main/config/component/dataFilterSlider.xml
trunk/ui/dataFilterSlider/src/main/java/org/richfaces/renderkit/DataFilterSliderRendererBase.java
trunk/ui/dataTable/src/main/config/component/colgroup.xml
trunk/ui/dataTable/src/main/config/component/column.xml
trunk/ui/dataTable/src/main/config/component/dataGrid.xml
trunk/ui/dataTable/src/main/config/component/dataList.xml
trunk/ui/dataTable/src/main/config/component/dataTable.xml
trunk/ui/dataTable/src/main/config/component/subTable.xml
trunk/ui/datascroller/src/main/config/component/datascroller.xml
trunk/ui/drag-drop/src/main/config/component/dndParam.xml
trunk/ui/drag-drop/src/main/config/component/dragIndicator.xml
trunk/ui/drag-drop/src/main/config/component/dragSupport.xml
trunk/ui/drag-drop/src/main/config/component/dropSupport.xml
trunk/ui/dropdown-menu/src/main/config/component/dropdownmenu.xml
trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java
trunk/ui/gmap/src/main/config/component/gmap.xml
trunk/ui/inputnumber-slider/src/main/config/component/inputNumberSlider.xml
trunk/ui/inputnumber-slider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowSelectedImage.java
trunk/ui/inputnumber-spinner/src/main/config/component/inputNumberSpinner.xml
trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/buttons/SpinnerButtonImage.java
trunk/ui/menu-components/src/main/config/component/menucomponents.xml
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/MenuNodeImage.java
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuSeparatorComponentTest.java
trunk/ui/modal-panel/src/main/config/component/modalPanel.xml
trunk/ui/paint2D/src/main/config/component/paint2D.xml
trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DResource.java
trunk/ui/panel/src/main/config/component/panel.xml
trunk/ui/panelbar/src/main/config/component/panelbar.xml
trunk/ui/separator/src/main/config/component/separator.xml
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java
trunk/ui/simpleTogglePanel/src/main/config/component/simpleTogglePanel.xml
trunk/ui/spacer/src/main/config/component/spacer.xml
trunk/ui/suggestionbox/src/main/config/component/suggestionbox.xml
trunk/ui/tabPanel/src/main/config/component/tabPanel.xml
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java
trunk/ui/togglePanel/src/main/config/component/togglePanel.xml
trunk/ui/toolBar/src/main/config/component/toolBar.xml
trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/images/ToolBarSeparatorImage.java
trunk/ui/tree/src/main/config/component/tree.xml
trunk/ui/tree/src/main/config/component/treeNode.xml
trunk/ui/tree/src/main/java/org/richfaces/renderkit/html/images/TreeImageBase.java
Log:
packages and classes refactor in the "impl" project
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/GifEncoder.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/GifEncoder.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/GifEncoder.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,566 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util;
-
-import java.awt.Image;
-import java.awt.image.ColorModel;
-import java.awt.image.IndexColorModel;
-import java.awt.image.PixelGrabber;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.ajax4jsf.Messages;
-
-/** GifEncoder - writes out an image as a GIF.
- *
- * Transparency handling and variable bit size courtesy of Jack Palevich.
- *
- * Copyright (C) 1996 by Jef Poskanzer <jef(a)acme.com>. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Visit the ACME Labs Java page for up-to-date versions of this and other
- * fine Java utilities: http://www.acme.com/java/
- */
-
-public class GifEncoder {
-
- private boolean interlace = false;
-
- private int width, height;
-
- private byte[] pixels;
-
- private byte[] r, g, b; // the color look-up table
-
- private int pixelIndex;
-
- private int numPixels;
-
- private int transparentPixel = -1; // hpm
-
- /**
- * Constructs a new GifEncoder.
- * @param width The image width.
- * @param height The image height.
- * @param pixels The pixel data.
- * @param r The red look-up table.
- * @param g The green look-up table.
- * @param b The blue look-up table.
- */
- public GifEncoder(int width, int height, byte[] pixels, byte[] r, byte[] g, byte[] b) {
- this.width = width;
- this.height = height;
- this.pixels = pixels;
- this.r = r;
- this.g = g;
- this.b = b;
- interlace = false;
- pixelIndex = 0;
- numPixels = width * height;
- }
-
- /** Constructs a new GifEncoder using an 8-bit AWT Image.
- The image is assumed to be fully loaded. */
- public GifEncoder(Image img) {
- width = img.getWidth(null);
- height = img.getHeight(null);
- pixels = new byte[width * height];
- PixelGrabber pg = new PixelGrabber(img, 0, 0, width, height, false);
- try {
- pg.grabPixels();
- } catch (InterruptedException e) {
- System.err.println(e);
- }
- ColorModel cm = pg.getColorModel();
- if (cm instanceof IndexColorModel) {
- pixels = (byte[]) (pg.getPixels());
- // hpm
- IndexColorModel icm = (IndexColorModel) cm;
- setTransparentPixel(icm.getTransparentPixel());
- } else
- throw new IllegalArgumentException(Messages.getMessage(Messages.IMAGE_ERROR));
- IndexColorModel m = (IndexColorModel) cm;
- int mapSize = m.getMapSize();
- r = new byte[mapSize];
- g = new byte[mapSize];
- b = new byte[mapSize];
- m.getReds(r);
- m.getGreens(g);
- m.getBlues(b);
- interlace = false;
- pixelIndex = 0;
- numPixels = width * height;
- }
-
- /** Saves the image as a GIF file. */
- public void write(OutputStream out) throws IOException {
- // Figure out how many bits to use.
- int numColors = r.length;
- int BitsPerPixel;
- if (numColors <= 2)
- BitsPerPixel = 1;
- else if (numColors <= 4)
- BitsPerPixel = 2;
- else if (numColors <= 16)
- BitsPerPixel = 4;
- else
- BitsPerPixel = 8;
-
- int ColorMapSize = 1 << BitsPerPixel;
- byte[] reds = new byte[ColorMapSize];
- byte[] grns = new byte[ColorMapSize];
- byte[] blus = new byte[ColorMapSize];
- for (int i = 0; i < numColors; i++) {
- reds[i] = r[i];
- grns[i] = g[i];
- blus[i] = b[i];
- }
-
- // hpm
- GIFEncode(out, width, height, interlace, (byte) 0, getTransparentPixel(), BitsPerPixel, reds, grns, blus);
- }
-
- // hpm
- public void setTransparentPixel(int pixel) {
- transparentPixel = pixel;
- }
-
- // hpm
- public int getTransparentPixel() {
- return transparentPixel;
- }
-
- static void writeString(OutputStream out, String str) throws IOException {
- byte[] buf = str.getBytes();
- out.write(buf);
- }
-
- // Adapted from ppmtogif, which is based on GIFENCOD by David
- // Rowley <mgardi(a)watdscu.waterloo.edu>. Lempel-Zim compression
- // based on "compress".
-
- int Width, Height;
-
- boolean Interlace;
-
- void GIFEncode(OutputStream outs, int Width, int Height, boolean Interlace,
- byte Background, int Transparent, int BitsPerPixel, byte[] Red,
- byte[] Green, byte[] Blue) throws IOException {
- byte B;
- int LeftOfs, TopOfs;
- int ColorMapSize;
- int InitCodeSize;
- int i;
-
- this.Width = Width;
- this.Height = Height;
- this.Interlace = Interlace;
- ColorMapSize = 1 << BitsPerPixel;
- LeftOfs = TopOfs = 0;
-
- // The initial code size
- if (BitsPerPixel <= 1)
- InitCodeSize = 2;
- else
- InitCodeSize = BitsPerPixel;
-
- // Write the Magic header
- writeString(outs, "GIF89a");
-
- // Write out the screen width and height
- Putword(Width, outs);
- Putword(Height, outs);
-
- // Indicate that there is a global colour map
- B = (byte) 0x80; // Yes, there is a color map
- // OR in the resolution
- B |= (byte) ((8 - 1) << 4);
- // Not sorted
- // OR in the Bits per Pixel
- B |= (byte) ((BitsPerPixel - 1));
-
- // Write it out
- Putbyte(B, outs);
-
- // Write out the Background colour
- Putbyte(Background, outs);
-
- // Pixel aspect ratio - 1:1.
- //Putbyte( (byte) 49, outs );
- // Java's GIF reader currently has a bug, if the aspect ratio byte is
- // not zero it throws an ImageFormatException. It doesn't know that
- // 49 means a 1:1 aspect ratio. Well, whatever, zero works with all
- // the other decoders I've tried so it probably doesn't hurt.
- Putbyte((byte) 0, outs);
-
- // Write out the Global Colour Map
- for (i = 0; i < ColorMapSize; ++i) {
- Putbyte(Red[i], outs);
- Putbyte(Green[i], outs);
- Putbyte(Blue[i], outs);
- }
-
- // Write out extension for transparent colour index, if necessary.
- if (Transparent != -1) {
- Putbyte((byte) '!', outs);
- Putbyte((byte) 0xf9, outs);
- Putbyte((byte) 4, outs);
- Putbyte((byte) 1, outs);
- Putbyte((byte) 0, outs);
- Putbyte((byte) 0, outs);
- Putbyte((byte) Transparent, outs);
- Putbyte((byte) 0, outs);
- }
-
- // Write an Image separator
- Putbyte((byte) ',', outs);
-
- // Write the Image header
- Putword(LeftOfs, outs);
- Putword(TopOfs, outs);
- Putword(Width, outs);
- Putword(Height, outs);
-
- // Write out whether or not the image is interlaced
- if (Interlace)
- Putbyte((byte) 0x40, outs);
- else
- Putbyte((byte) 0x00, outs);
-
- // Write out the initial code size
- Putbyte((byte) InitCodeSize, outs);
-
- // Go and actually compress the data
- compress(InitCodeSize + 1, outs);
-
- // Write out a Zero-length packet (to end the series)
- Putbyte((byte) 0, outs);
-
- // Write the GIF file terminator
- Putbyte((byte) ';', outs);
- }
-
- static final int EOF = -1;
-
- // Return the next pixel from the image
- int GIFNextPixel() throws IOException {
- if (pixelIndex == numPixels)
- return EOF;
- else
- return ((byte[]) pixels)[pixelIndex++] & 0xff;
- }
-
- // Write out a word to the GIF file
- void Putword(int w, OutputStream outs) throws IOException {
- Putbyte((byte) (w & 0xff), outs);
- Putbyte((byte) ((w >> 8) & 0xff), outs);
- }
-
- // Write out a byte to the GIF file
- void Putbyte(byte b, OutputStream outs) throws IOException {
- outs.write(b);
- }
-
- // GIFCOMPR.C - GIF Image compression routines
- //
- // Lempel-Ziv compression based on 'compress'. GIF modifications by
- // David Rowley (mgardi(a)watdcsu.waterloo.edu)
-
- // General DEFINEs
-
- static final int BITS = 12;
-
- static final int HSIZE = 5003; // 80% occupancy
-
- // GIF Image compression - modified 'compress'
- //
- // Based on: compress.c - File compression ala IEEE Computer, June 1984.
- //
- // By Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
- // Jim McKie (decvax!mcvax!jim)
- // Steve Davies (decvax!vax135!petsd!peora!srd)
- // Ken Turkowski (decvax!decwrl!turtlevax!ken)
- // James A. Woods (decvax!ihnp4!ames!jaw)
- // Joe Orost (decvax!vax135!petsd!joe)
-
- int n_bits; // number of bits/code
-
- int maxbits = BITS; // user settable max # bits/code
-
- int maxcode; // maximum code, given n_bits
-
- int maxmaxcode = 1 << BITS; // should NEVER generate this code
-
- final int MAXCODE(int n_bits) {
- return (1 << n_bits) - 1;
- }
-
- int[] htab = new int[HSIZE];
-
- int[] codetab = new int[HSIZE];
-
- int hsize = HSIZE; // for dynamic table sizing
-
- int free_ent = 0; // first unused entry
-
- // block compression parameters -- after all codes are used up,
- // and compression rate changes, start over.
- boolean clear_flg = false;
-
- // Algorithm: use open addressing double hashing (no chaining) on the
- // prefix code / next character combination. We do a variant of Knuth's
- // algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
- // secondary probe. Here, the modular division first probe is gives way
- // to a faster exclusive-or manipulation. Also do block compression with
- // an adaptive reset, whereby the code table is cleared when the compression
- // ratio decreases, but after the table fills. The variable-length output
- // codes are re-sized at this point, and a special CLEAR code is generated
- // for the decompressor. Late addition: construct the table according to
- // file size for noticeable speed improvement on small files. Please direct
- // questions about this implementation to ames!jaw.
-
- int g_init_bits;
-
- int ClearCode;
-
- int EOFCode;
-
- void compress(int init_bits, OutputStream outs) throws IOException {
- int fcode;
- int i /* = 0 */;
- int c;
- int ent;
- int disp;
- int hsize_reg;
- int hshift;
-
- // Set up the globals: g_init_bits - initial number of bits
- g_init_bits = init_bits;
-
- // Set up the necessary values
- clear_flg = false;
- n_bits = g_init_bits;
- maxcode = MAXCODE(n_bits);
-
- ClearCode = 1 << (init_bits - 1);
- EOFCode = ClearCode + 1;
- free_ent = ClearCode + 2;
-
- char_init();
-
- ent = GIFNextPixel();
-
- hshift = 0;
- for (fcode = hsize; fcode < 65536; fcode *= 2)
- ++hshift;
- hshift = 8 - hshift; // set hash code range bound
-
- hsize_reg = hsize;
- cl_hash(hsize_reg); // clear hash table
-
- output(ClearCode, outs);
-
- outer_loop: while ((c = GIFNextPixel()) != EOF) {
- fcode = (c << maxbits) + ent;
- i = (c << hshift) ^ ent; // xor hashing
-
- if (htab[i] == fcode) {
- ent = codetab[i];
- continue;
- } else if (htab[i] >= 0) // non-empty slot
- {
- disp = hsize_reg - i; // secondary hash (after G. Knott)
- if (i == 0)
- disp = 1;
- do {
- if ((i -= disp) < 0)
- i += hsize_reg;
-
- if (htab[i] == fcode) {
- ent = codetab[i];
- continue outer_loop;
- }
- } while (htab[i] >= 0);
- }
- output(ent, outs);
- ent = c;
- if (free_ent < maxmaxcode) {
- codetab[i] = free_ent++; // code -> hashtable
- htab[i] = fcode;
- } else
- cl_block(outs);
- }
- // Put out the final code.
- output(ent, outs);
- output(EOFCode, outs);
- }
-
- // output
- //
- // Output the given code.
- // Inputs:
- // code: A n_bits-bit integer. If == -1, then EOF. This assumes
- // that n_bits =< wordsize - 1.
- // Outputs:
- // Outputs code to the file.
- // Assumptions:
- // Chars are 8 bits long.
- // Algorithm:
- // Maintain a BITS character long buffer (so that 8 codes will
- // fit in it exactly). Use the VAX insv instruction to insert each
- // code in turn. When the buffer fills up empty it and start over.
-
- int cur_accum = 0;
-
- int cur_bits = 0;
-
- int masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F,
- 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF,
- 0x7FFF, 0xFFFF };
-
- void output(int code, OutputStream outs) throws IOException {
- cur_accum &= masks[cur_bits];
-
- if (cur_bits > 0)
- cur_accum |= (code << cur_bits);
- else
- cur_accum = code;
-
- cur_bits += n_bits;
-
- while (cur_bits >= 8) {
- char_out((byte) (cur_accum & 0xff), outs);
- cur_accum >>= 8;
- cur_bits -= 8;
- }
-
- // If the next entry is going to be too big for the code size,
- // then increase it, if possible.
- if (free_ent > maxcode || clear_flg) {
- if (clear_flg) {
- maxcode = MAXCODE(n_bits = g_init_bits);
- clear_flg = false;
- } else {
- ++n_bits;
- if (n_bits == maxbits)
- maxcode = maxmaxcode;
- else
- maxcode = MAXCODE(n_bits);
- }
- }
-
- if (code == EOFCode) {
- // At EOF, write the rest of the buffer.
- while (cur_bits > 0) {
- char_out((byte) (cur_accum & 0xff), outs);
- cur_accum >>= 8;
- cur_bits -= 8;
- }
-
- flush_char(outs);
- }
- }
-
- // Clear out the hash table
-
- // table clear for block compress
- void cl_block(OutputStream outs) throws IOException {
- cl_hash(hsize);
- free_ent = ClearCode + 2;
- clear_flg = true;
-
- output(ClearCode, outs);
- }
-
- // reset code table
- void cl_hash(int hsize) {
- for (int i = 0; i < hsize; ++i)
- htab[i] = -1;
- }
-
- // GIF Specific routines
-
- // Number of characters so far in this 'packet'
- int a_count;
-
- // Set up the 'byte output' routine
- void char_init() {
- a_count = 0;
- }
-
- // Define the storage for the packet accumulator
- byte[] accum = new byte[256];
-
- // Add a character to the end of the current packet, and if it is 254
- // characters, flush the packet to disk.
- void char_out(byte c, OutputStream outs) throws IOException {
- accum[a_count++] = c;
- if (a_count >= 254)
- flush_char(outs);
- }
-
- // Flush the packet to disk, and reset the accumulator
- void flush_char(OutputStream outs) throws IOException {
- if (a_count > 0) {
- outs.write(a_count);
- outs.write(accum, 0, a_count);
- a_count = 0;
- }
- }
-
-}
-
-class GifEncoderHashitem {
- public int rgb;
- public int count;
- public int index;
- public boolean isTransparent;
-
- public GifEncoderHashitem(int rgb, int count, int index,
- boolean isTransparent) {
- this.rgb = rgb;
- this.count = count;
- this.index = index;
- this.isTransparent = isTransparent;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/HtmlColor.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/HtmlColor.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/HtmlColor.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,90 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util;
-
-import java.awt.Color;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.ajax4jsf.Messages;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:16 $
- *
- */
-public class HtmlColor {
- private static Map colorNames;
-
- static {
- // color names.
- colorNames = new HashMap();
- colorNames.put("black", new Color(0x000000));
- colorNames.put("green", new Color(0x008000));
- colorNames.put("silver", new Color(0xC0C0C0));
- colorNames.put("lime", new Color(0x00FF00));
- colorNames.put("gray", new Color(0x808080));
- colorNames.put("olive", new Color(0x808000));
- colorNames.put("white", new Color(0xFFFFFF));
- colorNames.put("yellow", new Color(0xFFFF00));
- colorNames.put("maroon", new Color(0x800000));
- colorNames.put("navy", new Color(0x000080));
- colorNames.put("red", new Color(0xFF0000));
- colorNames.put("blue", new Color(0x0000FF));
- colorNames.put("purple", new Color(0x800080));
- colorNames.put("teal", new Color(0x008080));
- colorNames.put("fuchsia", new Color(0xFF00FF));
- colorNames.put("aqua", new Color(0x00FFFF));
- }
-
- /**
- * Decode HTML-attribute style of color to {@link Color}
- * @param color - color name or #RRGGBB string
- * @return - color for this value.
- */
- public static Color decode(String color){
- if(null == color) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NULL_COLOR_PARAMETER_ERROR));
- }
- Color c = (Color) colorNames.get(color.trim().toLowerCase());
- if (null == c) {
- try {
- c = Color.decode(color.trim());
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.DECODE_COLOR_PARAMETER_ERROR, color, e.getMessage()));
- }
- }
- return c;
- }
-
- public static Integer integerValue(String color){
- return new Integer(decode(color).getRGB());
- }
-
- public static String encodeRGB(Color color){
- if(null == color) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NULL_COLOR_PARAMETER_ERROR_2));
- }
- return "#" + Integer.toHexString(color.getRGB()).substring(2).toUpperCase();
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/HtmlDimensions.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/HtmlDimensions.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/HtmlDimensions.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,80 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util;
-
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.text.ParseException;
-import java.util.regex.Pattern;
-
-import org.ajax4jsf.Messages;
-
-public class HtmlDimensions {
-
- private static final Pattern PATTERN_NUMERIC = Pattern.compile("^[+-]?\\d+(\\.\\d+)?$");
- private static final Pattern PATTERN_PX = Pattern.compile("^[+-]?\\d+(\\.\\d+)?px$");
- private static final Pattern PATTERN_PCT = Pattern.compile("^[+-]?\\d+(\\.\\d+)?%$");
-
- private static final NumberFormat numericFormat = new DecimalFormat();
- private static final DecimalFormat pxFormat = new DecimalFormat();
- private static final NumberFormat pctFormat = NumberFormat.getPercentInstance();
-
- static{
- pxFormat.setPositiveSuffix("px");
- pxFormat.setNegativeSuffix("px");
- }
- public static Double decode(String size){
- // TODO - handle px,ex,pt enc suffixes.
- double d = 0;
- try {
- if(size != null){
- if(PATTERN_NUMERIC.matcher(size).matches()){
- synchronized(numericFormat){
- d = numericFormat.parse(size).doubleValue();
- }
- } else if(PATTERN_PX.matcher(size).matches()){
- synchronized (pxFormat) {
- d = pxFormat.parse(size).doubleValue();
- }
- } else if(PATTERN_PCT.matcher(size).matches()){
- synchronized (pctFormat) {
- d = pctFormat.parse(size).doubleValue();
- }
- }
- }
- } catch (ParseException e) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.DECODE_PARAMETER_ERROR, new Object[]{"size", size, e.getMessage()}));
- }
- return new Double(d);
- }
-
- public static String formatPx(Double value){
- return (value.intValue() + "px");
- }
- public static String formatPct(Double value){
- String v = "";
- synchronized (pctFormat) {
- v = pctFormat.format(value.doubleValue());
- }
- return v;
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/InputUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/InputUtils.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/InputUtils.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,55 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util;
-
-import java.io.Serializable;
-
-import javax.faces.component.UIComponent;
-
-/**
- * @author Maksim Kaszynski
- * @author Manfred Geiler
- *
- */
-public class InputUtils {
-
- public static final String EMPTY_STRING = new String();
- public static final Object NOTHING = new Serializable() {};
-
- public static boolean isTrue(Object obj)
- {
- if(!(obj instanceof Boolean))
- return false;
-
- return ((Boolean) obj).booleanValue();
- }
-
- public static boolean isDisabled(UIComponent component)
- {
- return isTrue(component.getAttributes().get("disabled"));
- }
- public static boolean isReadOnly(UIComponent component)
- {
- return isTrue(component.getAttributes().get("readonly"));
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/SelectUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/SelectUtils.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/SelectUtils.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,291 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util;
-
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-import javax.faces.component.UIOutput;
-import javax.faces.component.UISelectItem;
-import javax.faces.component.UISelectItems;
-import javax.faces.component.UISelectMany;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
-import javax.faces.el.ValueBinding;
-import javax.faces.model.SelectItem;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class SelectUtils {
-
- private static final Log log = LogFactory.getLog(SelectUtils.class);
-
- /**
- * Gathers all select items from specified component's children
- * @param context
- * @param component
- * @return list of {@link SelectItems} taken from f:selectItem and f:selectItems
- */
- public static List getSelectItems(FacesContext context, UIComponent component) {
- ArrayList list = new ArrayList();
- Iterator kids = component.getChildren().iterator();
- while (kids.hasNext()) {
- UIComponent kid = (UIComponent) kids.next();
- if (kid instanceof UISelectItem) {
- Object value = ((UISelectItem) kid).getValue();
- if (value == null) {
- UISelectItem item = (UISelectItem) kid;
- list.add(new SelectItem(item.getItemValue(), item.getItemLabel(), item.getItemDescription(), item.isItemDisabled()));
- } else if (value instanceof SelectItem) {
- list.add(value);
- } else {
- String valueClass = (value != null ? "'" + value.getClass().getName() + "'" : "");
- throw new IllegalArgumentException(Messages.getMessage(Messages.INVALID_ATTRIBUTE_VALUE, valueClass, "<selectItem>"));
- }
- } else if (kid instanceof UISelectItems && null != context) {
- Object value = ((UISelectItems) kid).getValue();
- if (value instanceof SelectItem) {
- list.add(value);
- } else if (value instanceof SelectItem[]) {
- SelectItem items[] = (SelectItem[]) value;
- for (int i = 0; i < items.length; i++) {
- list.add(items[i]);
- }
- } else if (value instanceof Collection) {
- Iterator elements = ((Collection) value).iterator();
- while (elements.hasNext()) {
- list.add(elements.next());
- }
- } else if (value instanceof Map) {
- Iterator keys = ((Map) value).keySet().iterator();
- while (keys.hasNext()) {
- Object key = keys.next();
- if (key == null) {
- continue;
- }
- Object val = ((Map) value).get(key);
- if (val == null) {
- continue;
- }
- list.add(new SelectItem(val.toString(), key.toString(),
- null));
- }
- } else {
- String valueClass = (value != null ? "'" + value.getClass().getName() + "'" : "");
- throw new IllegalArgumentException(Messages.getMessage(Messages.INVALID_ATTRIBUTE_VALUE, valueClass, "<selectItems>"));
- }
- }
- }
- return list;
-
- }
-
- /**
- * Converts UISelectMany submitted value to converted value
- *
- * @author Manfred Geiler
- * @param facesContext
- * @param component
- * @param submittedValue
- * @return
- * @throws ConverterException
- */
- public static Object getConvertedUISelectManyValue(
- FacesContext facesContext, UISelectMany component,
- String[] submittedValue) throws ConverterException {
- // Attention!
- // This code is duplicated in jsfapi component package.
- // If you change something here please do the same in the other class!
-
- if (submittedValue == null)
- throw new NullPointerException("submittedValue");
-
- ValueBinding vb = component.getValueBinding("value");
- Class valueType = null;
- Class arrayComponentType = null;
- if (vb != null) {
- valueType = vb.getType(facesContext);
- if (valueType != null && valueType.isArray()) {
- arrayComponentType = valueType.getComponentType();
- }
- }
-
- Converter converter = component.getConverter();
- if (converter == null) {
- if (valueType == null) {
- // No converter, and no idea of expected type
- // --> return the submitted String array
- return submittedValue;
- }
-
- if (List.class.isAssignableFrom(valueType)) {
- // expected type is a List
- // --> according to javadoc of UISelectMany we assume that the
- // element type
- // is java.lang.String, and copy the String array to a new List
- int len = submittedValue.length;
- List lst = new ArrayList(len);
- for (int i = 0; i < len; i++) {
- lst.add(submittedValue[i]);
- }
- return lst;
- }
-
- if (arrayComponentType == null) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.VALUE_BINDING_TYPE_ERROR));
- }
-
- if (String.class.equals(arrayComponentType))
- return submittedValue; // No conversion needed for String type
- if (Object.class.equals(arrayComponentType))
- return submittedValue; // No conversion for Object class
-
- try {
- converter = facesContext.getApplication().createConverter(
- arrayComponentType);
- } catch (FacesException e) {
- log.error(Messages.getMessage(Messages.NO_CONVERTER_FOUND_ERROR, arrayComponentType.getName()), e);
- return submittedValue;
- }
- }
-
- // Now, we have a converter...
- if (valueType == null) {
- // ...but have no idea of expected type
- // --> so let's convert it to an Object array
- int len = submittedValue.length;
- Object[] convertedValues = (Object[]) Array.newInstance(
- arrayComponentType == null ? Object.class
- : arrayComponentType, len);
- for (int i = 0; i < len; i++) {
- convertedValues[i] = converter.getAsObject(facesContext,
- component, submittedValue[i]);
- }
- return convertedValues;
- }
-
- if (List.class.isAssignableFrom(valueType)) {
- // Curious case: According to specs we should assume, that the
- // element type
- // of this List is java.lang.String. But there is a Converter set
- // for this
- // component. Because the user must know what he is doing, we will
- // convert the values.
- int len = submittedValue.length;
- List lst = new ArrayList(len);
- for (int i = 0; i < len; i++) {
- lst.add(converter.getAsObject(facesContext, component,
- submittedValue[i]));
- }
- return lst;
- }
-
- if (arrayComponentType == null) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.VALUE_BINDING_TYPE_ERROR));
- }
-
- if (arrayComponentType.isPrimitive()) {
- // primitive array
- int len = submittedValue.length;
- Object convertedValues = Array.newInstance(arrayComponentType, len);
- for (int i = 0; i < len; i++) {
- Array.set(convertedValues, i, converter.getAsObject(
- facesContext, component, submittedValue[i]));
- }
- return convertedValues;
- } else {
- // Object array
- int len = submittedValue.length;
- ArrayList convertedValues = new ArrayList(len);
- for (int i = 0; i < len; i++) {
- convertedValues.add(i, converter.getAsObject(facesContext,
- component, submittedValue[i]));
- }
- return convertedValues.toArray((Object[]) Array.newInstance(
- arrayComponentType, len));
- }
- }
-
- public static Object getConvertedUIInputValue(
- FacesContext facesContext, UIInput component,
- String submittedValue) throws ConverterException{
-
- Object convertedValue = null;
-
- /*
- if (submittedValue == null)
- throw new NullPointerException("submittedValue");
- */
- if(InputUtils.EMPTY_STRING.equals(submittedValue)){
- return null;
- }
- Converter converter = getConverterForProperty(facesContext, component, "value");
- if(converter != null){
- convertedValue = converter.getAsObject(facesContext, component, submittedValue);
- } else {
- convertedValue = submittedValue;
- }
-
- return convertedValue;
-
- }
- /**
- *
- * @param facesContext
- * @param component
- * @param property
- * @return converter for specified component attribute
- */
- public static Converter getConverterForProperty(FacesContext facesContext, UIOutput component, String property){
- Converter converter = component.getConverter();
- if(converter == null){
- ValueBinding valueBinding = component.getValueBinding(property);
- if(valueBinding != null){
- Class valueType = valueBinding.getType(facesContext);
- if(valueType == null || String.class.equals(valueType) || Object.class.equals(valueType)){
- //No converter needed
- } else {
- converter = facesContext.getApplication().createConverter(valueType);
- if(converter == null){
- throw new ConverterException(Messages.getMessage(Messages.NO_CONVERTER_FOUND_ERROR, valueType.getName()));
- }
- }
- }
- }
- return converter;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/ServicesUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/ServicesUtils.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/ServicesUtils.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,151 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.FacesException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura
- *
- */
-public class ServicesUtils {
-
- private static final Log log = LogFactory.getLog(ServicesUtils.class);
-
- private static Map _services = Collections.synchronizedMap(new HashMap());
-
- private static Map _instances = Collections.synchronizedMap(new HashMap());
- /**
- *
- */
- private ServicesUtils() {
- // This is a static utility class.
- }
-
- /**
- * @param name
- * @return
- * @throws ClassNotFoundException
- */
- public static Class getService(String name) throws ClassNotFoundException {
- Map contextClasses = (Map) _services.get(name);
- if (null == contextClasses) {
- contextClasses = Collections.synchronizedMap(new HashMap());
- _services.put(name, contextClasses);
- }
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Class serviceClass = (Class) contextClasses.get(loader);
- if (null == serviceClass) {
- serviceClass = loadServiceClass(loader, name);
- contextClasses.put(loader, serviceClass);
- }
- return serviceClass;
- }
-
- /**
- * Get per-context instance for service.
- * @param name - name ( default classname ) for service.
- * @return current instance for this service.
- * @throws ClassNotFoundException
- */
- public static Object getServiceInstance(String name) {
- Map contextInstances = (Map) _instances.get(name);
- if (null == contextInstances) {
- contextInstances = Collections.synchronizedMap(new HashMap());
- _instances.put(name, contextInstances);
- }
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Object serviceInstance = contextInstances.get(loader);
- if (null == serviceInstance) {
- try{
- Class serviceClass = loadServiceClass(loader, name);
- serviceInstance = serviceClass.newInstance();
- } catch (Exception e) {
- throw new FacesException("Error create instance for service "+name,e);
- }
- contextInstances.put(loader, serviceInstance);
- }
- return serviceInstance;
- }
-
-
- /**
- * @param loader
- * @param name
- * @return
- * @throws ClassNotFoundException
- */
- public static Class loadServiceClass(ClassLoader loader, String name) throws ClassNotFoundException {
- Class serviceClass;
- try {
- String resource = "META-INF/services/" + name;
- InputStream in = loader.getResourceAsStream(resource);
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(in));
- String serviceClassName = reader.readLine();
- reader.close();
- serviceClass = loadClass(loader, serviceClassName);
- if (log.isDebugEnabled()) {
- log.debug("Class for service "+name+ " set to "+ serviceClassName);
- }
- } catch (Exception e) {
- serviceClass = loadClass(loader, name);
- if (log.isDebugEnabled()) {
- log
- .debug("Service class set to default implementation "+name);
- }
- }
- return serviceClass;
- }
-
- /**
- * @param loader
- * @param name
- * @return
- * @throws ClassNotFoundException
- */
- public static Class loadClass(ClassLoader loader, String name)
- throws ClassNotFoundException {
- Class clazz;
- try {
- clazz = loader.loadClass(name);
- } catch (ClassNotFoundException e) {
- if (log.isWarnEnabled()) {
- log.warn("Class " + name + "not found by Context Classloader");
- }
- // Try internal library classloader.
- clazz = ServicesUtils.class.getClassLoader().loadClass(name);
- }
- return clazz;
- }
-
-}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -51,11 +51,11 @@
import org.ajax4jsf.component.AjaxViewRoot;
import org.ajax4jsf.component.JavaScriptParameter;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.util.ServicesUtils;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.util.ServicesUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -39,10 +39,10 @@
import javax.faces.convert.Converter;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.renderkit.compiler.TemplateContext;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.util.HtmlDimensions;
/**
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -27,7 +27,7 @@
import javax.faces.FacesException;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.util.style.CSSFormat;
+import org.ajax4jsf.util.style.CSSFormat;
import org.xml.sax.SAXException;
/**
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -47,13 +47,13 @@
import org.ajax4jsf.cache.CacheLoader;
import org.ajax4jsf.cache.CacheManager;
import org.ajax4jsf.cache.ServletContextInitMap;
-import org.ajax4jsf.framework.util.config.WebXml;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceContext;
import org.ajax4jsf.resource.ResourceNotFoundException;
import org.ajax4jsf.webapp.BaseFilter;
import org.ajax4jsf.webapp.CacheContent;
+import org.ajax4jsf.webapp.WebXml;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -44,12 +44,12 @@
import javax.servlet.ServletContext;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.util.base64.Codec;
-import org.ajax4jsf.framework.util.config.WebXml;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceNotFoundException;
import org.ajax4jsf.resource.ResourceRenderer;
+import org.ajax4jsf.util.base64.Codec;
+import org.ajax4jsf.webapp.WebXml;
import org.apache.commons.digester.Digester;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/GifEncoder.java (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/GifEncoder.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/GifEncoder.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/GifEncoder.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,566 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.util;
+
+import java.awt.Image;
+import java.awt.image.ColorModel;
+import java.awt.image.IndexColorModel;
+import java.awt.image.PixelGrabber;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.ajax4jsf.Messages;
+
+/** GifEncoder - writes out an image as a GIF.
+ *
+ * Transparency handling and variable bit size courtesy of Jack Palevich.
+ *
+ * Copyright (C) 1996 by Jef Poskanzer <jef(a)acme.com>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Visit the ACME Labs Java page for up-to-date versions of this and other
+ * fine Java utilities: http://www.acme.com/java/
+ */
+
+public class GifEncoder {
+
+ private boolean interlace = false;
+
+ private int width, height;
+
+ private byte[] pixels;
+
+ private byte[] r, g, b; // the color look-up table
+
+ private int pixelIndex;
+
+ private int numPixels;
+
+ private int transparentPixel = -1; // hpm
+
+ /**
+ * Constructs a new GifEncoder.
+ * @param width The image width.
+ * @param height The image height.
+ * @param pixels The pixel data.
+ * @param r The red look-up table.
+ * @param g The green look-up table.
+ * @param b The blue look-up table.
+ */
+ public GifEncoder(int width, int height, byte[] pixels, byte[] r, byte[] g, byte[] b) {
+ this.width = width;
+ this.height = height;
+ this.pixels = pixels;
+ this.r = r;
+ this.g = g;
+ this.b = b;
+ interlace = false;
+ pixelIndex = 0;
+ numPixels = width * height;
+ }
+
+ /** Constructs a new GifEncoder using an 8-bit AWT Image.
+ The image is assumed to be fully loaded. */
+ public GifEncoder(Image img) {
+ width = img.getWidth(null);
+ height = img.getHeight(null);
+ pixels = new byte[width * height];
+ PixelGrabber pg = new PixelGrabber(img, 0, 0, width, height, false);
+ try {
+ pg.grabPixels();
+ } catch (InterruptedException e) {
+ System.err.println(e);
+ }
+ ColorModel cm = pg.getColorModel();
+ if (cm instanceof IndexColorModel) {
+ pixels = (byte[]) (pg.getPixels());
+ // hpm
+ IndexColorModel icm = (IndexColorModel) cm;
+ setTransparentPixel(icm.getTransparentPixel());
+ } else
+ throw new IllegalArgumentException(Messages.getMessage(Messages.IMAGE_ERROR));
+ IndexColorModel m = (IndexColorModel) cm;
+ int mapSize = m.getMapSize();
+ r = new byte[mapSize];
+ g = new byte[mapSize];
+ b = new byte[mapSize];
+ m.getReds(r);
+ m.getGreens(g);
+ m.getBlues(b);
+ interlace = false;
+ pixelIndex = 0;
+ numPixels = width * height;
+ }
+
+ /** Saves the image as a GIF file. */
+ public void write(OutputStream out) throws IOException {
+ // Figure out how many bits to use.
+ int numColors = r.length;
+ int BitsPerPixel;
+ if (numColors <= 2)
+ BitsPerPixel = 1;
+ else if (numColors <= 4)
+ BitsPerPixel = 2;
+ else if (numColors <= 16)
+ BitsPerPixel = 4;
+ else
+ BitsPerPixel = 8;
+
+ int ColorMapSize = 1 << BitsPerPixel;
+ byte[] reds = new byte[ColorMapSize];
+ byte[] grns = new byte[ColorMapSize];
+ byte[] blus = new byte[ColorMapSize];
+ for (int i = 0; i < numColors; i++) {
+ reds[i] = r[i];
+ grns[i] = g[i];
+ blus[i] = b[i];
+ }
+
+ // hpm
+ GIFEncode(out, width, height, interlace, (byte) 0, getTransparentPixel(), BitsPerPixel, reds, grns, blus);
+ }
+
+ // hpm
+ public void setTransparentPixel(int pixel) {
+ transparentPixel = pixel;
+ }
+
+ // hpm
+ public int getTransparentPixel() {
+ return transparentPixel;
+ }
+
+ static void writeString(OutputStream out, String str) throws IOException {
+ byte[] buf = str.getBytes();
+ out.write(buf);
+ }
+
+ // Adapted from ppmtogif, which is based on GIFENCOD by David
+ // Rowley <mgardi(a)watdscu.waterloo.edu>. Lempel-Zim compression
+ // based on "compress".
+
+ int Width, Height;
+
+ boolean Interlace;
+
+ void GIFEncode(OutputStream outs, int Width, int Height, boolean Interlace,
+ byte Background, int Transparent, int BitsPerPixel, byte[] Red,
+ byte[] Green, byte[] Blue) throws IOException {
+ byte B;
+ int LeftOfs, TopOfs;
+ int ColorMapSize;
+ int InitCodeSize;
+ int i;
+
+ this.Width = Width;
+ this.Height = Height;
+ this.Interlace = Interlace;
+ ColorMapSize = 1 << BitsPerPixel;
+ LeftOfs = TopOfs = 0;
+
+ // The initial code size
+ if (BitsPerPixel <= 1)
+ InitCodeSize = 2;
+ else
+ InitCodeSize = BitsPerPixel;
+
+ // Write the Magic header
+ writeString(outs, "GIF89a");
+
+ // Write out the screen width and height
+ Putword(Width, outs);
+ Putword(Height, outs);
+
+ // Indicate that there is a global colour map
+ B = (byte) 0x80; // Yes, there is a color map
+ // OR in the resolution
+ B |= (byte) ((8 - 1) << 4);
+ // Not sorted
+ // OR in the Bits per Pixel
+ B |= (byte) ((BitsPerPixel - 1));
+
+ // Write it out
+ Putbyte(B, outs);
+
+ // Write out the Background colour
+ Putbyte(Background, outs);
+
+ // Pixel aspect ratio - 1:1.
+ //Putbyte( (byte) 49, outs );
+ // Java's GIF reader currently has a bug, if the aspect ratio byte is
+ // not zero it throws an ImageFormatException. It doesn't know that
+ // 49 means a 1:1 aspect ratio. Well, whatever, zero works with all
+ // the other decoders I've tried so it probably doesn't hurt.
+ Putbyte((byte) 0, outs);
+
+ // Write out the Global Colour Map
+ for (i = 0; i < ColorMapSize; ++i) {
+ Putbyte(Red[i], outs);
+ Putbyte(Green[i], outs);
+ Putbyte(Blue[i], outs);
+ }
+
+ // Write out extension for transparent colour index, if necessary.
+ if (Transparent != -1) {
+ Putbyte((byte) '!', outs);
+ Putbyte((byte) 0xf9, outs);
+ Putbyte((byte) 4, outs);
+ Putbyte((byte) 1, outs);
+ Putbyte((byte) 0, outs);
+ Putbyte((byte) 0, outs);
+ Putbyte((byte) Transparent, outs);
+ Putbyte((byte) 0, outs);
+ }
+
+ // Write an Image separator
+ Putbyte((byte) ',', outs);
+
+ // Write the Image header
+ Putword(LeftOfs, outs);
+ Putword(TopOfs, outs);
+ Putword(Width, outs);
+ Putword(Height, outs);
+
+ // Write out whether or not the image is interlaced
+ if (Interlace)
+ Putbyte((byte) 0x40, outs);
+ else
+ Putbyte((byte) 0x00, outs);
+
+ // Write out the initial code size
+ Putbyte((byte) InitCodeSize, outs);
+
+ // Go and actually compress the data
+ compress(InitCodeSize + 1, outs);
+
+ // Write out a Zero-length packet (to end the series)
+ Putbyte((byte) 0, outs);
+
+ // Write the GIF file terminator
+ Putbyte((byte) ';', outs);
+ }
+
+ static final int EOF = -1;
+
+ // Return the next pixel from the image
+ int GIFNextPixel() throws IOException {
+ if (pixelIndex == numPixels)
+ return EOF;
+ else
+ return ((byte[]) pixels)[pixelIndex++] & 0xff;
+ }
+
+ // Write out a word to the GIF file
+ void Putword(int w, OutputStream outs) throws IOException {
+ Putbyte((byte) (w & 0xff), outs);
+ Putbyte((byte) ((w >> 8) & 0xff), outs);
+ }
+
+ // Write out a byte to the GIF file
+ void Putbyte(byte b, OutputStream outs) throws IOException {
+ outs.write(b);
+ }
+
+ // GIFCOMPR.C - GIF Image compression routines
+ //
+ // Lempel-Ziv compression based on 'compress'. GIF modifications by
+ // David Rowley (mgardi(a)watdcsu.waterloo.edu)
+
+ // General DEFINEs
+
+ static final int BITS = 12;
+
+ static final int HSIZE = 5003; // 80% occupancy
+
+ // GIF Image compression - modified 'compress'
+ //
+ // Based on: compress.c - File compression ala IEEE Computer, June 1984.
+ //
+ // By Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
+ // Jim McKie (decvax!mcvax!jim)
+ // Steve Davies (decvax!vax135!petsd!peora!srd)
+ // Ken Turkowski (decvax!decwrl!turtlevax!ken)
+ // James A. Woods (decvax!ihnp4!ames!jaw)
+ // Joe Orost (decvax!vax135!petsd!joe)
+
+ int n_bits; // number of bits/code
+
+ int maxbits = BITS; // user settable max # bits/code
+
+ int maxcode; // maximum code, given n_bits
+
+ int maxmaxcode = 1 << BITS; // should NEVER generate this code
+
+ final int MAXCODE(int n_bits) {
+ return (1 << n_bits) - 1;
+ }
+
+ int[] htab = new int[HSIZE];
+
+ int[] codetab = new int[HSIZE];
+
+ int hsize = HSIZE; // for dynamic table sizing
+
+ int free_ent = 0; // first unused entry
+
+ // block compression parameters -- after all codes are used up,
+ // and compression rate changes, start over.
+ boolean clear_flg = false;
+
+ // Algorithm: use open addressing double hashing (no chaining) on the
+ // prefix code / next character combination. We do a variant of Knuth's
+ // algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
+ // secondary probe. Here, the modular division first probe is gives way
+ // to a faster exclusive-or manipulation. Also do block compression with
+ // an adaptive reset, whereby the code table is cleared when the compression
+ // ratio decreases, but after the table fills. The variable-length output
+ // codes are re-sized at this point, and a special CLEAR code is generated
+ // for the decompressor. Late addition: construct the table according to
+ // file size for noticeable speed improvement on small files. Please direct
+ // questions about this implementation to ames!jaw.
+
+ int g_init_bits;
+
+ int ClearCode;
+
+ int EOFCode;
+
+ void compress(int init_bits, OutputStream outs) throws IOException {
+ int fcode;
+ int i /* = 0 */;
+ int c;
+ int ent;
+ int disp;
+ int hsize_reg;
+ int hshift;
+
+ // Set up the globals: g_init_bits - initial number of bits
+ g_init_bits = init_bits;
+
+ // Set up the necessary values
+ clear_flg = false;
+ n_bits = g_init_bits;
+ maxcode = MAXCODE(n_bits);
+
+ ClearCode = 1 << (init_bits - 1);
+ EOFCode = ClearCode + 1;
+ free_ent = ClearCode + 2;
+
+ char_init();
+
+ ent = GIFNextPixel();
+
+ hshift = 0;
+ for (fcode = hsize; fcode < 65536; fcode *= 2)
+ ++hshift;
+ hshift = 8 - hshift; // set hash code range bound
+
+ hsize_reg = hsize;
+ cl_hash(hsize_reg); // clear hash table
+
+ output(ClearCode, outs);
+
+ outer_loop: while ((c = GIFNextPixel()) != EOF) {
+ fcode = (c << maxbits) + ent;
+ i = (c << hshift) ^ ent; // xor hashing
+
+ if (htab[i] == fcode) {
+ ent = codetab[i];
+ continue;
+ } else if (htab[i] >= 0) // non-empty slot
+ {
+ disp = hsize_reg - i; // secondary hash (after G. Knott)
+ if (i == 0)
+ disp = 1;
+ do {
+ if ((i -= disp) < 0)
+ i += hsize_reg;
+
+ if (htab[i] == fcode) {
+ ent = codetab[i];
+ continue outer_loop;
+ }
+ } while (htab[i] >= 0);
+ }
+ output(ent, outs);
+ ent = c;
+ if (free_ent < maxmaxcode) {
+ codetab[i] = free_ent++; // code -> hashtable
+ htab[i] = fcode;
+ } else
+ cl_block(outs);
+ }
+ // Put out the final code.
+ output(ent, outs);
+ output(EOFCode, outs);
+ }
+
+ // output
+ //
+ // Output the given code.
+ // Inputs:
+ // code: A n_bits-bit integer. If == -1, then EOF. This assumes
+ // that n_bits =< wordsize - 1.
+ // Outputs:
+ // Outputs code to the file.
+ // Assumptions:
+ // Chars are 8 bits long.
+ // Algorithm:
+ // Maintain a BITS character long buffer (so that 8 codes will
+ // fit in it exactly). Use the VAX insv instruction to insert each
+ // code in turn. When the buffer fills up empty it and start over.
+
+ int cur_accum = 0;
+
+ int cur_bits = 0;
+
+ int masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F,
+ 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF,
+ 0x7FFF, 0xFFFF };
+
+ void output(int code, OutputStream outs) throws IOException {
+ cur_accum &= masks[cur_bits];
+
+ if (cur_bits > 0)
+ cur_accum |= (code << cur_bits);
+ else
+ cur_accum = code;
+
+ cur_bits += n_bits;
+
+ while (cur_bits >= 8) {
+ char_out((byte) (cur_accum & 0xff), outs);
+ cur_accum >>= 8;
+ cur_bits -= 8;
+ }
+
+ // If the next entry is going to be too big for the code size,
+ // then increase it, if possible.
+ if (free_ent > maxcode || clear_flg) {
+ if (clear_flg) {
+ maxcode = MAXCODE(n_bits = g_init_bits);
+ clear_flg = false;
+ } else {
+ ++n_bits;
+ if (n_bits == maxbits)
+ maxcode = maxmaxcode;
+ else
+ maxcode = MAXCODE(n_bits);
+ }
+ }
+
+ if (code == EOFCode) {
+ // At EOF, write the rest of the buffer.
+ while (cur_bits > 0) {
+ char_out((byte) (cur_accum & 0xff), outs);
+ cur_accum >>= 8;
+ cur_bits -= 8;
+ }
+
+ flush_char(outs);
+ }
+ }
+
+ // Clear out the hash table
+
+ // table clear for block compress
+ void cl_block(OutputStream outs) throws IOException {
+ cl_hash(hsize);
+ free_ent = ClearCode + 2;
+ clear_flg = true;
+
+ output(ClearCode, outs);
+ }
+
+ // reset code table
+ void cl_hash(int hsize) {
+ for (int i = 0; i < hsize; ++i)
+ htab[i] = -1;
+ }
+
+ // GIF Specific routines
+
+ // Number of characters so far in this 'packet'
+ int a_count;
+
+ // Set up the 'byte output' routine
+ void char_init() {
+ a_count = 0;
+ }
+
+ // Define the storage for the packet accumulator
+ byte[] accum = new byte[256];
+
+ // Add a character to the end of the current packet, and if it is 254
+ // characters, flush the packet to disk.
+ void char_out(byte c, OutputStream outs) throws IOException {
+ accum[a_count++] = c;
+ if (a_count >= 254)
+ flush_char(outs);
+ }
+
+ // Flush the packet to disk, and reset the accumulator
+ void flush_char(OutputStream outs) throws IOException {
+ if (a_count > 0) {
+ outs.write(a_count);
+ outs.write(accum, 0, a_count);
+ a_count = 0;
+ }
+ }
+
+}
+
+class GifEncoderHashitem {
+ public int rgb;
+ public int count;
+ public int index;
+ public boolean isTransparent;
+
+ public GifEncoderHashitem(int rgb, int count, int index,
+ boolean isTransparent) {
+ this.rgb = rgb;
+ this.count = count;
+ this.index = index;
+ this.isTransparent = isTransparent;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/HtmlColor.java (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/HtmlColor.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/HtmlColor.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/HtmlColor.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,90 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.util;
+
+import java.awt.Color;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:16 $
+ *
+ */
+public class HtmlColor {
+ private static Map colorNames;
+
+ static {
+ // color names.
+ colorNames = new HashMap();
+ colorNames.put("black", new Color(0x000000));
+ colorNames.put("green", new Color(0x008000));
+ colorNames.put("silver", new Color(0xC0C0C0));
+ colorNames.put("lime", new Color(0x00FF00));
+ colorNames.put("gray", new Color(0x808080));
+ colorNames.put("olive", new Color(0x808000));
+ colorNames.put("white", new Color(0xFFFFFF));
+ colorNames.put("yellow", new Color(0xFFFF00));
+ colorNames.put("maroon", new Color(0x800000));
+ colorNames.put("navy", new Color(0x000080));
+ colorNames.put("red", new Color(0xFF0000));
+ colorNames.put("blue", new Color(0x0000FF));
+ colorNames.put("purple", new Color(0x800080));
+ colorNames.put("teal", new Color(0x008080));
+ colorNames.put("fuchsia", new Color(0xFF00FF));
+ colorNames.put("aqua", new Color(0x00FFFF));
+ }
+
+ /**
+ * Decode HTML-attribute style of color to {@link Color}
+ * @param color - color name or #RRGGBB string
+ * @return - color for this value.
+ */
+ public static Color decode(String color){
+ if(null == color) {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.NULL_COLOR_PARAMETER_ERROR));
+ }
+ Color c = (Color) colorNames.get(color.trim().toLowerCase());
+ if (null == c) {
+ try {
+ c = Color.decode(color.trim());
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.DECODE_COLOR_PARAMETER_ERROR, color, e.getMessage()));
+ }
+ }
+ return c;
+ }
+
+ public static Integer integerValue(String color){
+ return new Integer(decode(color).getRGB());
+ }
+
+ public static String encodeRGB(Color color){
+ if(null == color) {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.NULL_COLOR_PARAMETER_ERROR_2));
+ }
+ return "#" + Integer.toHexString(color.getRGB()).substring(2).toUpperCase();
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/HtmlDimensions.java (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/HtmlDimensions.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/HtmlDimensions.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/HtmlDimensions.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,80 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.util;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.regex.Pattern;
+
+import org.ajax4jsf.Messages;
+
+public class HtmlDimensions {
+
+ private static final Pattern PATTERN_NUMERIC = Pattern.compile("^[+-]?\\d+(\\.\\d+)?$");
+ private static final Pattern PATTERN_PX = Pattern.compile("^[+-]?\\d+(\\.\\d+)?px$");
+ private static final Pattern PATTERN_PCT = Pattern.compile("^[+-]?\\d+(\\.\\d+)?%$");
+
+ private static final NumberFormat numericFormat = new DecimalFormat();
+ private static final DecimalFormat pxFormat = new DecimalFormat();
+ private static final NumberFormat pctFormat = NumberFormat.getPercentInstance();
+
+ static{
+ pxFormat.setPositiveSuffix("px");
+ pxFormat.setNegativeSuffix("px");
+ }
+ public static Double decode(String size){
+ // TODO - handle px,ex,pt enc suffixes.
+ double d = 0;
+ try {
+ if(size != null){
+ if(PATTERN_NUMERIC.matcher(size).matches()){
+ synchronized(numericFormat){
+ d = numericFormat.parse(size).doubleValue();
+ }
+ } else if(PATTERN_PX.matcher(size).matches()){
+ synchronized (pxFormat) {
+ d = pxFormat.parse(size).doubleValue();
+ }
+ } else if(PATTERN_PCT.matcher(size).matches()){
+ synchronized (pctFormat) {
+ d = pctFormat.parse(size).doubleValue();
+ }
+ }
+ }
+ } catch (ParseException e) {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.DECODE_PARAMETER_ERROR, new Object[]{"size", size, e.getMessage()}));
+ }
+ return new Double(d);
+ }
+
+ public static String formatPx(Double value){
+ return (value.intValue() + "px");
+ }
+ public static String formatPct(Double value){
+ String v = "";
+ synchronized (pctFormat) {
+ v = pctFormat.format(value.doubleValue());
+ }
+ return v;
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/InputUtils.java (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/InputUtils.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/InputUtils.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/InputUtils.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.util;
+
+import java.io.Serializable;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * @author Maksim Kaszynski
+ * @author Manfred Geiler
+ *
+ */
+public class InputUtils {
+
+ public static final String EMPTY_STRING = new String();
+ public static final Object NOTHING = new Serializable() {};
+
+ public static boolean isTrue(Object obj)
+ {
+ if(!(obj instanceof Boolean))
+ return false;
+
+ return ((Boolean) obj).booleanValue();
+ }
+
+ public static boolean isDisabled(UIComponent component)
+ {
+ return isTrue(component.getAttributes().get("disabled"));
+ }
+ public static boolean isReadOnly(UIComponent component)
+ {
+ return isTrue(component.getAttributes().get("readonly"));
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/SelectUtils.java (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/SelectUtils.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/SelectUtils.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/SelectUtils.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,291 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.util;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIOutput;
+import javax.faces.component.UISelectItem;
+import javax.faces.component.UISelectItems;
+import javax.faces.component.UISelectMany;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.el.ValueBinding;
+import javax.faces.model.SelectItem;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SelectUtils {
+
+ private static final Log log = LogFactory.getLog(SelectUtils.class);
+
+ /**
+ * Gathers all select items from specified component's children
+ * @param context
+ * @param component
+ * @return list of {@link SelectItems} taken from f:selectItem and f:selectItems
+ */
+ public static List getSelectItems(FacesContext context, UIComponent component) {
+ ArrayList list = new ArrayList();
+ Iterator kids = component.getChildren().iterator();
+ while (kids.hasNext()) {
+ UIComponent kid = (UIComponent) kids.next();
+ if (kid instanceof UISelectItem) {
+ Object value = ((UISelectItem) kid).getValue();
+ if (value == null) {
+ UISelectItem item = (UISelectItem) kid;
+ list.add(new SelectItem(item.getItemValue(), item.getItemLabel(), item.getItemDescription(), item.isItemDisabled()));
+ } else if (value instanceof SelectItem) {
+ list.add(value);
+ } else {
+ String valueClass = (value != null ? "'" + value.getClass().getName() + "'" : "");
+ throw new IllegalArgumentException(Messages.getMessage(Messages.INVALID_ATTRIBUTE_VALUE, valueClass, "<selectItem>"));
+ }
+ } else if (kid instanceof UISelectItems && null != context) {
+ Object value = ((UISelectItems) kid).getValue();
+ if (value instanceof SelectItem) {
+ list.add(value);
+ } else if (value instanceof SelectItem[]) {
+ SelectItem items[] = (SelectItem[]) value;
+ for (int i = 0; i < items.length; i++) {
+ list.add(items[i]);
+ }
+ } else if (value instanceof Collection) {
+ Iterator elements = ((Collection) value).iterator();
+ while (elements.hasNext()) {
+ list.add(elements.next());
+ }
+ } else if (value instanceof Map) {
+ Iterator keys = ((Map) value).keySet().iterator();
+ while (keys.hasNext()) {
+ Object key = keys.next();
+ if (key == null) {
+ continue;
+ }
+ Object val = ((Map) value).get(key);
+ if (val == null) {
+ continue;
+ }
+ list.add(new SelectItem(val.toString(), key.toString(),
+ null));
+ }
+ } else {
+ String valueClass = (value != null ? "'" + value.getClass().getName() + "'" : "");
+ throw new IllegalArgumentException(Messages.getMessage(Messages.INVALID_ATTRIBUTE_VALUE, valueClass, "<selectItems>"));
+ }
+ }
+ }
+ return list;
+
+ }
+
+ /**
+ * Converts UISelectMany submitted value to converted value
+ *
+ * @author Manfred Geiler
+ * @param facesContext
+ * @param component
+ * @param submittedValue
+ * @return
+ * @throws ConverterException
+ */
+ public static Object getConvertedUISelectManyValue(
+ FacesContext facesContext, UISelectMany component,
+ String[] submittedValue) throws ConverterException {
+ // Attention!
+ // This code is duplicated in jsfapi component package.
+ // If you change something here please do the same in the other class!
+
+ if (submittedValue == null)
+ throw new NullPointerException("submittedValue");
+
+ ValueBinding vb = component.getValueBinding("value");
+ Class valueType = null;
+ Class arrayComponentType = null;
+ if (vb != null) {
+ valueType = vb.getType(facesContext);
+ if (valueType != null && valueType.isArray()) {
+ arrayComponentType = valueType.getComponentType();
+ }
+ }
+
+ Converter converter = component.getConverter();
+ if (converter == null) {
+ if (valueType == null) {
+ // No converter, and no idea of expected type
+ // --> return the submitted String array
+ return submittedValue;
+ }
+
+ if (List.class.isAssignableFrom(valueType)) {
+ // expected type is a List
+ // --> according to javadoc of UISelectMany we assume that the
+ // element type
+ // is java.lang.String, and copy the String array to a new List
+ int len = submittedValue.length;
+ List lst = new ArrayList(len);
+ for (int i = 0; i < len; i++) {
+ lst.add(submittedValue[i]);
+ }
+ return lst;
+ }
+
+ if (arrayComponentType == null) {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.VALUE_BINDING_TYPE_ERROR));
+ }
+
+ if (String.class.equals(arrayComponentType))
+ return submittedValue; // No conversion needed for String type
+ if (Object.class.equals(arrayComponentType))
+ return submittedValue; // No conversion for Object class
+
+ try {
+ converter = facesContext.getApplication().createConverter(
+ arrayComponentType);
+ } catch (FacesException e) {
+ log.error(Messages.getMessage(Messages.NO_CONVERTER_FOUND_ERROR, arrayComponentType.getName()), e);
+ return submittedValue;
+ }
+ }
+
+ // Now, we have a converter...
+ if (valueType == null) {
+ // ...but have no idea of expected type
+ // --> so let's convert it to an Object array
+ int len = submittedValue.length;
+ Object[] convertedValues = (Object[]) Array.newInstance(
+ arrayComponentType == null ? Object.class
+ : arrayComponentType, len);
+ for (int i = 0; i < len; i++) {
+ convertedValues[i] = converter.getAsObject(facesContext,
+ component, submittedValue[i]);
+ }
+ return convertedValues;
+ }
+
+ if (List.class.isAssignableFrom(valueType)) {
+ // Curious case: According to specs we should assume, that the
+ // element type
+ // of this List is java.lang.String. But there is a Converter set
+ // for this
+ // component. Because the user must know what he is doing, we will
+ // convert the values.
+ int len = submittedValue.length;
+ List lst = new ArrayList(len);
+ for (int i = 0; i < len; i++) {
+ lst.add(converter.getAsObject(facesContext, component,
+ submittedValue[i]));
+ }
+ return lst;
+ }
+
+ if (arrayComponentType == null) {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.VALUE_BINDING_TYPE_ERROR));
+ }
+
+ if (arrayComponentType.isPrimitive()) {
+ // primitive array
+ int len = submittedValue.length;
+ Object convertedValues = Array.newInstance(arrayComponentType, len);
+ for (int i = 0; i < len; i++) {
+ Array.set(convertedValues, i, converter.getAsObject(
+ facesContext, component, submittedValue[i]));
+ }
+ return convertedValues;
+ } else {
+ // Object array
+ int len = submittedValue.length;
+ ArrayList convertedValues = new ArrayList(len);
+ for (int i = 0; i < len; i++) {
+ convertedValues.add(i, converter.getAsObject(facesContext,
+ component, submittedValue[i]));
+ }
+ return convertedValues.toArray((Object[]) Array.newInstance(
+ arrayComponentType, len));
+ }
+ }
+
+ public static Object getConvertedUIInputValue(
+ FacesContext facesContext, UIInput component,
+ String submittedValue) throws ConverterException{
+
+ Object convertedValue = null;
+
+ /*
+ if (submittedValue == null)
+ throw new NullPointerException("submittedValue");
+ */
+ if(InputUtils.EMPTY_STRING.equals(submittedValue)){
+ return null;
+ }
+ Converter converter = getConverterForProperty(facesContext, component, "value");
+ if(converter != null){
+ convertedValue = converter.getAsObject(facesContext, component, submittedValue);
+ } else {
+ convertedValue = submittedValue;
+ }
+
+ return convertedValue;
+
+ }
+ /**
+ *
+ * @param facesContext
+ * @param component
+ * @param property
+ * @return converter for specified component attribute
+ */
+ public static Converter getConverterForProperty(FacesContext facesContext, UIOutput component, String property){
+ Converter converter = component.getConverter();
+ if(converter == null){
+ ValueBinding valueBinding = component.getValueBinding(property);
+ if(valueBinding != null){
+ Class valueType = valueBinding.getType(facesContext);
+ if(valueType == null || String.class.equals(valueType) || Object.class.equals(valueType)){
+ //No converter needed
+ } else {
+ converter = facesContext.getApplication().createConverter(valueType);
+ if(converter == null){
+ throw new ConverterException(Messages.getMessage(Messages.NO_CONVERTER_FOUND_ERROR, valueType.getName()));
+ }
+ }
+ }
+ }
+ return converter;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/ServicesUtils.java (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/ServicesUtils.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/ServicesUtils.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/ServicesUtils.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,151 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.util;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.FacesException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura
+ *
+ */
+public class ServicesUtils {
+
+ private static final Log log = LogFactory.getLog(ServicesUtils.class);
+
+ private static Map _services = Collections.synchronizedMap(new HashMap());
+
+ private static Map _instances = Collections.synchronizedMap(new HashMap());
+ /**
+ *
+ */
+ private ServicesUtils() {
+ // This is a static utility class.
+ }
+
+ /**
+ * @param name
+ * @return
+ * @throws ClassNotFoundException
+ */
+ public static Class getService(String name) throws ClassNotFoundException {
+ Map contextClasses = (Map) _services.get(name);
+ if (null == contextClasses) {
+ contextClasses = Collections.synchronizedMap(new HashMap());
+ _services.put(name, contextClasses);
+ }
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Class serviceClass = (Class) contextClasses.get(loader);
+ if (null == serviceClass) {
+ serviceClass = loadServiceClass(loader, name);
+ contextClasses.put(loader, serviceClass);
+ }
+ return serviceClass;
+ }
+
+ /**
+ * Get per-context instance for service.
+ * @param name - name ( default classname ) for service.
+ * @return current instance for this service.
+ * @throws ClassNotFoundException
+ */
+ public static Object getServiceInstance(String name) {
+ Map contextInstances = (Map) _instances.get(name);
+ if (null == contextInstances) {
+ contextInstances = Collections.synchronizedMap(new HashMap());
+ _instances.put(name, contextInstances);
+ }
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Object serviceInstance = contextInstances.get(loader);
+ if (null == serviceInstance) {
+ try{
+ Class serviceClass = loadServiceClass(loader, name);
+ serviceInstance = serviceClass.newInstance();
+ } catch (Exception e) {
+ throw new FacesException("Error create instance for service "+name,e);
+ }
+ contextInstances.put(loader, serviceInstance);
+ }
+ return serviceInstance;
+ }
+
+
+ /**
+ * @param loader
+ * @param name
+ * @return
+ * @throws ClassNotFoundException
+ */
+ public static Class loadServiceClass(ClassLoader loader, String name) throws ClassNotFoundException {
+ Class serviceClass;
+ try {
+ String resource = "META-INF/services/" + name;
+ InputStream in = loader.getResourceAsStream(resource);
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(in));
+ String serviceClassName = reader.readLine();
+ reader.close();
+ serviceClass = loadClass(loader, serviceClassName);
+ if (log.isDebugEnabled()) {
+ log.debug("Class for service "+name+ " set to "+ serviceClassName);
+ }
+ } catch (Exception e) {
+ serviceClass = loadClass(loader, name);
+ if (log.isDebugEnabled()) {
+ log
+ .debug("Service class set to default implementation "+name);
+ }
+ }
+ return serviceClass;
+ }
+
+ /**
+ * @param loader
+ * @param name
+ * @return
+ * @throws ClassNotFoundException
+ */
+ public static Class loadClass(ClassLoader loader, String name)
+ throws ClassNotFoundException {
+ Class clazz;
+ try {
+ clazz = loader.loadClass(name);
+ } catch (ClassNotFoundException e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Class " + name + "not found by Context Classloader");
+ }
+ // Try internal library classloader.
+ clazz = ServicesUtils.class.getClassLoader().loadClass(name);
+ }
+ return clazz;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64 (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64)
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Base64.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/Base64.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Base64.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,542 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.ajax4jsf.framework.util.base64;
-
-import org.ajax4jsf.Messages;
-
-
-/**
- * Provides Base64 encoding and decoding as defined by RFC 2045.
- *
- * <p>This class implements section <cite>6.8. Base64 Content-Transfer-Encoding</cite>
- * from RFC 2045 <cite>Multipurpose Internet Mail Extensions (MIME) Part One:
- * Format of Internet Message Bodies</cite> by Freed and Borenstein.</p>
- *
- * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>
- * @author Apache Software Foundation
- * @since 1.0-dev
- * @version $Id: Base64.java,v 1.1.2.1 2007/01/09 18:59:11 alexsmirnov Exp $
- */
-public class Base64 implements BinaryEncoder, BinaryDecoder {
-
- /**
- * Chunk size per RFC 2045 section 6.8.
- *
- * <p>The {@value} character limit does not count the trailing CRLF, but counts
- * all other characters, including any equal signs.</p>
- *
- * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 6.8</a>
- */
- static final int CHUNK_SIZE = 76;
-
- /**
- * Chunk separator per RFC 2045 section 2.1.
- *
- * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 2.1</a>
- */
- static final byte[] CHUNK_SEPARATOR = "\r\n".getBytes();
-
- /**
- * The base length.
- */
- static final int BASELENGTH = 255;
-
- /**
- * Lookup length.
- */
- static final int LOOKUPLENGTH = 64;
-
- /**
- * Used to calculate the number of bits in a byte.
- */
- static final int EIGHTBIT = 8;
-
- /**
- * Used when encoding something which has fewer than 24 bits.
- */
- static final int SIXTEENBIT = 16;
-
- /**
- * Used to determine how many bits data contains.
- */
- static final int TWENTYFOURBITGROUP = 24;
-
- /**
- * Used to get the number of Quadruples.
- */
- static final int FOURBYTE = 4;
-
- /**
- * Used to test the sign of a byte.
- */
- static final int SIGN = -128;
-
- /**
- * Byte used to pad output.
- */
- static final byte PAD = (byte) '=';
-
- // Create arrays to hold the base64 characters and a
- // lookup for base64 chars
- private static byte[] base64Alphabet = new byte[BASELENGTH];
- private static byte[] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
-
- // Populating the lookup and character arrays
- static {
- for (int i = 0; i < BASELENGTH; i++) {
- base64Alphabet[i] = (byte) -1;
- }
- for (int i = 'Z'; i >= 'A'; i--) {
- base64Alphabet[i] = (byte) (i - 'A');
- }
- for (int i = 'z'; i >= 'a'; i--) {
- base64Alphabet[i] = (byte) (i - 'a' + 26);
- }
- for (int i = '9'; i >= '0'; i--) {
- base64Alphabet[i] = (byte) (i - '0' + 52);
- }
-
- base64Alphabet['+'] = 62;
- base64Alphabet['/'] = 63;
-
- for (int i = 0; i <= 25; i++) {
- lookUpBase64Alphabet[i] = (byte) ('A' + i);
- }
-
- for (int i = 26, j = 0; i <= 51; i++, j++) {
- lookUpBase64Alphabet[i] = (byte) ('a' + j);
- }
-
- for (int i = 52, j = 0; i <= 61; i++, j++) {
- lookUpBase64Alphabet[i] = (byte) ('0' + j);
- }
-
- lookUpBase64Alphabet[62] = (byte) '+';
- lookUpBase64Alphabet[63] = (byte) '/';
- }
-
- private static boolean isBase64(byte octect) {
- if (octect == PAD) {
- return true;
- } else if (base64Alphabet[octect] == -1) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Tests a given byte array to see if it contains
- * only valid characters within the Base64 alphabet.
- *
- * @param arrayOctect byte array to test
- * @return true if all bytes are valid characters in the Base64
- * alphabet or if the byte array is empty; false, otherwise
- */
- public static boolean isArrayByteBase64(byte[] arrayOctect) {
-
- arrayOctect = discardWhitespace(arrayOctect);
-
- int length = arrayOctect.length;
- if (length == 0) {
- // shouldn't a 0 length array be valid base64 data?
- // return false;
- return true;
- }
- for (int i = 0; i < length; i++) {
- if (!isBase64(arrayOctect[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Encodes binary data using the base64 algorithm but
- * does not chunk the output.
- *
- * @param binaryData binary data to encode
- * @return Base64 characters
- */
- public static byte[] encodeBase64(byte[] binaryData) {
- return encodeBase64(binaryData, false);
- }
-
- /**
- * Encodes binary data using the base64 algorithm and chunks
- * the encoded output into 76 character blocks
- *
- * @param binaryData binary data to encode
- * @return Base64 characters chunked in 76 character blocks
- */
- public static byte[] encodeBase64Chunked(byte[] binaryData) {
- return encodeBase64(binaryData, true);
- }
-
-
- /**
- * Decodes an Object using the base64 algorithm. This method
- * is provided in order to satisfy the requirements of the
- * Decoder interface, and will throw a DecoderException if the
- * supplied object is not of type byte[].
- *
- * @param pObject Object to decode
- * @return An object (of type byte[]) containing the
- * binary data which corresponds to the byte[] supplied.
- * @throws DecoderException if the parameter supplied is not
- * of type byte[]
- */
- public Object decode(Object pObject) throws DecoderException {
- if (!(pObject instanceof byte[])) {
- throw new DecoderException(Messages.getMessage(Messages.NO_BYTE_ARRAY_ERROR));
- }
- return decode((byte[]) pObject);
- }
-
- /**
- * Decodes a byte[] containing containing
- * characters in the Base64 alphabet.
- *
- * @param pArray A byte array containing Base64 character data
- * @return a byte array containing binary data
- */
- public byte[] decode(byte[] pArray) {
- return decodeBase64(pArray);
- }
-
- /**
- * Encodes binary data using the base64 algorithm, optionally
- * chunking the output into 76 character blocks.
- *
- * @param binaryData Array containing binary data to encode.
- * @param isChunked if isChunked is true this encoder will chunk
- * the base64 output into 76 character blocks
- * @return Base64-encoded data.
- */
- public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
- int lengthDataBits = binaryData.length * EIGHTBIT;
- int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
- int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
- byte encodedData[] = null;
- int encodedDataLength = 0;
- int nbrChunks = 0;
-
- if (fewerThan24bits != 0) {
- //data not divisible by 24 bit
- encodedDataLength = (numberTriplets + 1) * 4;
- } else {
- // 16 or 8 bit
- encodedDataLength = numberTriplets * 4;
- }
-
- // If the output is to be "chunked" into 76 character sections,
- // for compliance with RFC 2045 MIME, then it is important to
- // allow for extra length to account for the separator(s)
- if (isChunked) {
-
- nbrChunks =
- (CHUNK_SEPARATOR.length == 0 ? 0 : (int) Math.ceil((float) encodedDataLength / CHUNK_SIZE));
- encodedDataLength += nbrChunks * CHUNK_SEPARATOR.length;
- }
-
- encodedData = new byte[encodedDataLength];
-
- byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0;
-
- int encodedIndex = 0;
- int dataIndex = 0;
- int i = 0;
- int nextSeparatorIndex = CHUNK_SIZE;
- int chunksSoFar = 0;
-
- //log.debug("number of triplets = " + numberTriplets);
- for (i = 0; i < numberTriplets; i++) {
- dataIndex = i * 3;
- b1 = binaryData[dataIndex];
- b2 = binaryData[dataIndex + 1];
- b3 = binaryData[dataIndex + 2];
-
- //log.debug("b1= " + b1 +", b2= " + b2 + ", b3= " + b3);
-
- l = (byte) (b2 & 0x0f);
- k = (byte) (b1 & 0x03);
-
- byte val1 =
- ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
- byte val2 =
- ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
- byte val3 =
- ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc);
-
- encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
- //log.debug( "val2 = " + val2 );
- //log.debug( "k4 = " + (k<<4) );
- //log.debug( "vak = " + (val2 | (k<<4)) );
- encodedData[encodedIndex + 1] =
- lookUpBase64Alphabet[val2 | (k << 4)];
- encodedData[encodedIndex + 2] =
- lookUpBase64Alphabet[(l << 2) | val3];
- encodedData[encodedIndex + 3] = lookUpBase64Alphabet[b3 & 0x3f];
-
- encodedIndex += 4;
-
- // If we are chunking, let's put a chunk separator down.
- if (isChunked) {
- // this assumes that CHUNK_SIZE % 4 == 0
- if (encodedIndex == nextSeparatorIndex) {
- System.arraycopy(
- CHUNK_SEPARATOR,
- 0,
- encodedData,
- encodedIndex,
- CHUNK_SEPARATOR.length);
- chunksSoFar++;
- nextSeparatorIndex =
- (CHUNK_SIZE * (chunksSoFar + 1)) +
- (chunksSoFar * CHUNK_SEPARATOR.length);
- encodedIndex += CHUNK_SEPARATOR.length;
- }
- }
- }
-
- // form integral number of 6-bit groups
- dataIndex = i * 3;
-
- if (fewerThan24bits == EIGHTBIT) {
- b1 = binaryData[dataIndex];
- k = (byte) (b1 & 0x03);
- //log.debug("b1=" + b1);
- //log.debug("b1<<2 = " + (b1>>2) );
- byte val1 =
- ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
- encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
- encodedData[encodedIndex + 1] = lookUpBase64Alphabet[k << 4];
- encodedData[encodedIndex + 2] = PAD;
- encodedData[encodedIndex + 3] = PAD;
- } else if (fewerThan24bits == SIXTEENBIT) {
-
- b1 = binaryData[dataIndex];
- b2 = binaryData[dataIndex + 1];
- l = (byte) (b2 & 0x0f);
- k = (byte) (b1 & 0x03);
-
- byte val1 =
- ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
- byte val2 =
- ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
-
- encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
- encodedData[encodedIndex + 1] =
- lookUpBase64Alphabet[val2 | (k << 4)];
- encodedData[encodedIndex + 2] = lookUpBase64Alphabet[l << 2];
- encodedData[encodedIndex + 3] = PAD;
- }
-
- if (isChunked) {
- // we also add a separator to the end of the final chunk.
- if (chunksSoFar < nbrChunks) {
- System.arraycopy(
- CHUNK_SEPARATOR,
- 0,
- encodedData,
- encodedDataLength - CHUNK_SEPARATOR.length,
- CHUNK_SEPARATOR.length);
- }
- }
-
- return encodedData;
- }
-
- /**
- * Decodes Base64 data into octects
- *
- * @param base64Data Byte array containing Base64 data
- * @return Array containing decoded data.
- */
- public static byte[] decodeBase64(byte[] base64Data) {
- // RFC 2045 requires that we discard ALL non-Base64 characters
- base64Data = discardNonBase64(base64Data);
-
- // handle the edge case, so we don't have to worry about it later
- if (base64Data.length == 0) {
- return new byte[0];
- }
-
- int numberQuadruple = base64Data.length / FOURBYTE;
- byte decodedData[] = null;
- byte b1 = 0, b2 = 0, b3 = 0, b4 = 0, marker0 = 0, marker1 = 0;
-
- // Throw away anything not in base64Data
-
- int encodedIndex = 0;
- int dataIndex = 0;
- {
- // this sizes the output array properly - rlw
- int lastData = base64Data.length;
- // ignore the '=' padding
- while (base64Data[lastData - 1] == PAD) {
- if (--lastData == 0) {
- return new byte[0];
- }
- }
- decodedData = new byte[lastData - numberQuadruple];
- }
-
- for (int i = 0; i < numberQuadruple; i++) {
- dataIndex = i * 4;
- marker0 = base64Data[dataIndex + 2];
- marker1 = base64Data[dataIndex + 3];
-
- b1 = base64Alphabet[base64Data[dataIndex]];
- b2 = base64Alphabet[base64Data[dataIndex + 1]];
-
- if (marker0 != PAD && marker1 != PAD) {
- //No PAD e.g 3cQl
- b3 = base64Alphabet[marker0];
- b4 = base64Alphabet[marker1];
-
- decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
- decodedData[encodedIndex + 1] =
- (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
- decodedData[encodedIndex + 2] = (byte) (b3 << 6 | b4);
- } else if (marker0 == PAD) {
- //Two PAD e.g. 3c[Pad][Pad]
- decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
- } else if (marker1 == PAD) {
- //One PAD e.g. 3cQ[Pad]
- b3 = base64Alphabet[marker0];
-
- decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
- decodedData[encodedIndex + 1] =
- (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
- }
- encodedIndex += 3;
- }
- return decodedData;
- }
-
- /**
- * Discards any whitespace from a base-64 encoded block.
- *
- * @param data The base-64 encoded data to discard the whitespace
- * from.
- * @return The data, less whitespace (see RFC 2045).
- */
- static byte[] discardWhitespace(byte[] data) {
- byte groomedData[] = new byte[data.length];
- int bytesCopied = 0;
-
- for (int i = 0; i < data.length; i++) {
- switch (data[i]) {
- case (byte) ' ' :
- case (byte) '\n' :
- case (byte) '\r' :
- case (byte) '\t' :
- break;
- default:
- groomedData[bytesCopied++] = data[i];
- }
- }
-
- byte packedData[] = new byte[bytesCopied];
-
- System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
-
- return packedData;
- }
-
- /**
- * Discards any characters outside of the base64 alphabet, per
- * the requirements on page 25 of RFC 2045 - "Any characters
- * outside of the base64 alphabet are to be ignored in base64
- * encoded data."
- *
- * @param data The base-64 encoded data to groom
- * @return The data, less non-base64 characters (see RFC 2045).
- */
- static byte[] discardNonBase64(byte[] data) {
- byte groomedData[] = new byte[data.length];
- int bytesCopied = 0;
-
- for (int i = 0; i < data.length; i++) {
- if (isBase64(data[i])) {
- groomedData[bytesCopied++] = data[i];
- }
- }
-
- byte packedData[] = new byte[bytesCopied];
-
- System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
-
- return packedData;
- }
-
-
- // Implementation of the Encoder Interface
-
- /**
- * Encodes an Object using the base64 algorithm. This method
- * is provided in order to satisfy the requirements of the
- * Encoder interface, and will throw an EncoderException if the
- * supplied object is not of type byte[].
- *
- * @param pObject Object to encode
- * @return An object (of type byte[]) containing the
- * base64 encoded data which corresponds to the byte[] supplied.
- * @throws EncoderException if the parameter supplied is not
- * of type byte[]
- */
- public Object encode(Object pObject) throws EncoderException {
- if (!(pObject instanceof byte[])) {
- throw new EncoderException(Messages.getMessage(Messages.NO_BYTE_ARRAY_ERROR));
- }
- return encode((byte[]) pObject);
- }
-
- /**
- * Encodes a byte[] containing binary data, into a byte[] containing
- * characters in the Base64 alphabet.
- *
- * @param pArray a byte array containing binary data
- * @return A byte array containing only Base64 character data
- */
- public byte[] encode(byte[] pArray) {
- return encodeBase64(pArray, false);
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Base64.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/Base64.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Base64.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Base64.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,542 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.ajax4jsf.util.base64;
+
+import org.ajax4jsf.Messages;
+
+
+/**
+ * Provides Base64 encoding and decoding as defined by RFC 2045.
+ *
+ * <p>This class implements section <cite>6.8. Base64 Content-Transfer-Encoding</cite>
+ * from RFC 2045 <cite>Multipurpose Internet Mail Extensions (MIME) Part One:
+ * Format of Internet Message Bodies</cite> by Freed and Borenstein.</p>
+ *
+ * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>
+ * @author Apache Software Foundation
+ * @since 1.0-dev
+ * @version $Id: Base64.java,v 1.1.2.1 2007/01/09 18:59:11 alexsmirnov Exp $
+ */
+public class Base64 implements BinaryEncoder, BinaryDecoder {
+
+ /**
+ * Chunk size per RFC 2045 section 6.8.
+ *
+ * <p>The {@value} character limit does not count the trailing CRLF, but counts
+ * all other characters, including any equal signs.</p>
+ *
+ * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 6.8</a>
+ */
+ static final int CHUNK_SIZE = 76;
+
+ /**
+ * Chunk separator per RFC 2045 section 2.1.
+ *
+ * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 2.1</a>
+ */
+ static final byte[] CHUNK_SEPARATOR = "\r\n".getBytes();
+
+ /**
+ * The base length.
+ */
+ static final int BASELENGTH = 255;
+
+ /**
+ * Lookup length.
+ */
+ static final int LOOKUPLENGTH = 64;
+
+ /**
+ * Used to calculate the number of bits in a byte.
+ */
+ static final int EIGHTBIT = 8;
+
+ /**
+ * Used when encoding something which has fewer than 24 bits.
+ */
+ static final int SIXTEENBIT = 16;
+
+ /**
+ * Used to determine how many bits data contains.
+ */
+ static final int TWENTYFOURBITGROUP = 24;
+
+ /**
+ * Used to get the number of Quadruples.
+ */
+ static final int FOURBYTE = 4;
+
+ /**
+ * Used to test the sign of a byte.
+ */
+ static final int SIGN = -128;
+
+ /**
+ * Byte used to pad output.
+ */
+ static final byte PAD = (byte) '=';
+
+ // Create arrays to hold the base64 characters and a
+ // lookup for base64 chars
+ private static byte[] base64Alphabet = new byte[BASELENGTH];
+ private static byte[] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
+
+ // Populating the lookup and character arrays
+ static {
+ for (int i = 0; i < BASELENGTH; i++) {
+ base64Alphabet[i] = (byte) -1;
+ }
+ for (int i = 'Z'; i >= 'A'; i--) {
+ base64Alphabet[i] = (byte) (i - 'A');
+ }
+ for (int i = 'z'; i >= 'a'; i--) {
+ base64Alphabet[i] = (byte) (i - 'a' + 26);
+ }
+ for (int i = '9'; i >= '0'; i--) {
+ base64Alphabet[i] = (byte) (i - '0' + 52);
+ }
+
+ base64Alphabet['+'] = 62;
+ base64Alphabet['/'] = 63;
+
+ for (int i = 0; i <= 25; i++) {
+ lookUpBase64Alphabet[i] = (byte) ('A' + i);
+ }
+
+ for (int i = 26, j = 0; i <= 51; i++, j++) {
+ lookUpBase64Alphabet[i] = (byte) ('a' + j);
+ }
+
+ for (int i = 52, j = 0; i <= 61; i++, j++) {
+ lookUpBase64Alphabet[i] = (byte) ('0' + j);
+ }
+
+ lookUpBase64Alphabet[62] = (byte) '+';
+ lookUpBase64Alphabet[63] = (byte) '/';
+ }
+
+ private static boolean isBase64(byte octect) {
+ if (octect == PAD) {
+ return true;
+ } else if (base64Alphabet[octect] == -1) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Tests a given byte array to see if it contains
+ * only valid characters within the Base64 alphabet.
+ *
+ * @param arrayOctect byte array to test
+ * @return true if all bytes are valid characters in the Base64
+ * alphabet or if the byte array is empty; false, otherwise
+ */
+ public static boolean isArrayByteBase64(byte[] arrayOctect) {
+
+ arrayOctect = discardWhitespace(arrayOctect);
+
+ int length = arrayOctect.length;
+ if (length == 0) {
+ // shouldn't a 0 length array be valid base64 data?
+ // return false;
+ return true;
+ }
+ for (int i = 0; i < length; i++) {
+ if (!isBase64(arrayOctect[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Encodes binary data using the base64 algorithm but
+ * does not chunk the output.
+ *
+ * @param binaryData binary data to encode
+ * @return Base64 characters
+ */
+ public static byte[] encodeBase64(byte[] binaryData) {
+ return encodeBase64(binaryData, false);
+ }
+
+ /**
+ * Encodes binary data using the base64 algorithm and chunks
+ * the encoded output into 76 character blocks
+ *
+ * @param binaryData binary data to encode
+ * @return Base64 characters chunked in 76 character blocks
+ */
+ public static byte[] encodeBase64Chunked(byte[] binaryData) {
+ return encodeBase64(binaryData, true);
+ }
+
+
+ /**
+ * Decodes an Object using the base64 algorithm. This method
+ * is provided in order to satisfy the requirements of the
+ * Decoder interface, and will throw a DecoderException if the
+ * supplied object is not of type byte[].
+ *
+ * @param pObject Object to decode
+ * @return An object (of type byte[]) containing the
+ * binary data which corresponds to the byte[] supplied.
+ * @throws DecoderException if the parameter supplied is not
+ * of type byte[]
+ */
+ public Object decode(Object pObject) throws DecoderException {
+ if (!(pObject instanceof byte[])) {
+ throw new DecoderException(Messages.getMessage(Messages.NO_BYTE_ARRAY_ERROR));
+ }
+ return decode((byte[]) pObject);
+ }
+
+ /**
+ * Decodes a byte[] containing containing
+ * characters in the Base64 alphabet.
+ *
+ * @param pArray A byte array containing Base64 character data
+ * @return a byte array containing binary data
+ */
+ public byte[] decode(byte[] pArray) {
+ return decodeBase64(pArray);
+ }
+
+ /**
+ * Encodes binary data using the base64 algorithm, optionally
+ * chunking the output into 76 character blocks.
+ *
+ * @param binaryData Array containing binary data to encode.
+ * @param isChunked if isChunked is true this encoder will chunk
+ * the base64 output into 76 character blocks
+ * @return Base64-encoded data.
+ */
+ public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
+ int lengthDataBits = binaryData.length * EIGHTBIT;
+ int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
+ int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
+ byte encodedData[] = null;
+ int encodedDataLength = 0;
+ int nbrChunks = 0;
+
+ if (fewerThan24bits != 0) {
+ //data not divisible by 24 bit
+ encodedDataLength = (numberTriplets + 1) * 4;
+ } else {
+ // 16 or 8 bit
+ encodedDataLength = numberTriplets * 4;
+ }
+
+ // If the output is to be "chunked" into 76 character sections,
+ // for compliance with RFC 2045 MIME, then it is important to
+ // allow for extra length to account for the separator(s)
+ if (isChunked) {
+
+ nbrChunks =
+ (CHUNK_SEPARATOR.length == 0 ? 0 : (int) Math.ceil((float) encodedDataLength / CHUNK_SIZE));
+ encodedDataLength += nbrChunks * CHUNK_SEPARATOR.length;
+ }
+
+ encodedData = new byte[encodedDataLength];
+
+ byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0;
+
+ int encodedIndex = 0;
+ int dataIndex = 0;
+ int i = 0;
+ int nextSeparatorIndex = CHUNK_SIZE;
+ int chunksSoFar = 0;
+
+ //log.debug("number of triplets = " + numberTriplets);
+ for (i = 0; i < numberTriplets; i++) {
+ dataIndex = i * 3;
+ b1 = binaryData[dataIndex];
+ b2 = binaryData[dataIndex + 1];
+ b3 = binaryData[dataIndex + 2];
+
+ //log.debug("b1= " + b1 +", b2= " + b2 + ", b3= " + b3);
+
+ l = (byte) (b2 & 0x0f);
+ k = (byte) (b1 & 0x03);
+
+ byte val1 =
+ ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
+ byte val2 =
+ ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
+ byte val3 =
+ ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc);
+
+ encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
+ //log.debug( "val2 = " + val2 );
+ //log.debug( "k4 = " + (k<<4) );
+ //log.debug( "vak = " + (val2 | (k<<4)) );
+ encodedData[encodedIndex + 1] =
+ lookUpBase64Alphabet[val2 | (k << 4)];
+ encodedData[encodedIndex + 2] =
+ lookUpBase64Alphabet[(l << 2) | val3];
+ encodedData[encodedIndex + 3] = lookUpBase64Alphabet[b3 & 0x3f];
+
+ encodedIndex += 4;
+
+ // If we are chunking, let's put a chunk separator down.
+ if (isChunked) {
+ // this assumes that CHUNK_SIZE % 4 == 0
+ if (encodedIndex == nextSeparatorIndex) {
+ System.arraycopy(
+ CHUNK_SEPARATOR,
+ 0,
+ encodedData,
+ encodedIndex,
+ CHUNK_SEPARATOR.length);
+ chunksSoFar++;
+ nextSeparatorIndex =
+ (CHUNK_SIZE * (chunksSoFar + 1)) +
+ (chunksSoFar * CHUNK_SEPARATOR.length);
+ encodedIndex += CHUNK_SEPARATOR.length;
+ }
+ }
+ }
+
+ // form integral number of 6-bit groups
+ dataIndex = i * 3;
+
+ if (fewerThan24bits == EIGHTBIT) {
+ b1 = binaryData[dataIndex];
+ k = (byte) (b1 & 0x03);
+ //log.debug("b1=" + b1);
+ //log.debug("b1<<2 = " + (b1>>2) );
+ byte val1 =
+ ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
+ encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
+ encodedData[encodedIndex + 1] = lookUpBase64Alphabet[k << 4];
+ encodedData[encodedIndex + 2] = PAD;
+ encodedData[encodedIndex + 3] = PAD;
+ } else if (fewerThan24bits == SIXTEENBIT) {
+
+ b1 = binaryData[dataIndex];
+ b2 = binaryData[dataIndex + 1];
+ l = (byte) (b2 & 0x0f);
+ k = (byte) (b1 & 0x03);
+
+ byte val1 =
+ ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
+ byte val2 =
+ ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
+
+ encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
+ encodedData[encodedIndex + 1] =
+ lookUpBase64Alphabet[val2 | (k << 4)];
+ encodedData[encodedIndex + 2] = lookUpBase64Alphabet[l << 2];
+ encodedData[encodedIndex + 3] = PAD;
+ }
+
+ if (isChunked) {
+ // we also add a separator to the end of the final chunk.
+ if (chunksSoFar < nbrChunks) {
+ System.arraycopy(
+ CHUNK_SEPARATOR,
+ 0,
+ encodedData,
+ encodedDataLength - CHUNK_SEPARATOR.length,
+ CHUNK_SEPARATOR.length);
+ }
+ }
+
+ return encodedData;
+ }
+
+ /**
+ * Decodes Base64 data into octects
+ *
+ * @param base64Data Byte array containing Base64 data
+ * @return Array containing decoded data.
+ */
+ public static byte[] decodeBase64(byte[] base64Data) {
+ // RFC 2045 requires that we discard ALL non-Base64 characters
+ base64Data = discardNonBase64(base64Data);
+
+ // handle the edge case, so we don't have to worry about it later
+ if (base64Data.length == 0) {
+ return new byte[0];
+ }
+
+ int numberQuadruple = base64Data.length / FOURBYTE;
+ byte decodedData[] = null;
+ byte b1 = 0, b2 = 0, b3 = 0, b4 = 0, marker0 = 0, marker1 = 0;
+
+ // Throw away anything not in base64Data
+
+ int encodedIndex = 0;
+ int dataIndex = 0;
+ {
+ // this sizes the output array properly - rlw
+ int lastData = base64Data.length;
+ // ignore the '=' padding
+ while (base64Data[lastData - 1] == PAD) {
+ if (--lastData == 0) {
+ return new byte[0];
+ }
+ }
+ decodedData = new byte[lastData - numberQuadruple];
+ }
+
+ for (int i = 0; i < numberQuadruple; i++) {
+ dataIndex = i * 4;
+ marker0 = base64Data[dataIndex + 2];
+ marker1 = base64Data[dataIndex + 3];
+
+ b1 = base64Alphabet[base64Data[dataIndex]];
+ b2 = base64Alphabet[base64Data[dataIndex + 1]];
+
+ if (marker0 != PAD && marker1 != PAD) {
+ //No PAD e.g 3cQl
+ b3 = base64Alphabet[marker0];
+ b4 = base64Alphabet[marker1];
+
+ decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
+ decodedData[encodedIndex + 1] =
+ (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
+ decodedData[encodedIndex + 2] = (byte) (b3 << 6 | b4);
+ } else if (marker0 == PAD) {
+ //Two PAD e.g. 3c[Pad][Pad]
+ decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
+ } else if (marker1 == PAD) {
+ //One PAD e.g. 3cQ[Pad]
+ b3 = base64Alphabet[marker0];
+
+ decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
+ decodedData[encodedIndex + 1] =
+ (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
+ }
+ encodedIndex += 3;
+ }
+ return decodedData;
+ }
+
+ /**
+ * Discards any whitespace from a base-64 encoded block.
+ *
+ * @param data The base-64 encoded data to discard the whitespace
+ * from.
+ * @return The data, less whitespace (see RFC 2045).
+ */
+ static byte[] discardWhitespace(byte[] data) {
+ byte groomedData[] = new byte[data.length];
+ int bytesCopied = 0;
+
+ for (int i = 0; i < data.length; i++) {
+ switch (data[i]) {
+ case (byte) ' ' :
+ case (byte) '\n' :
+ case (byte) '\r' :
+ case (byte) '\t' :
+ break;
+ default:
+ groomedData[bytesCopied++] = data[i];
+ }
+ }
+
+ byte packedData[] = new byte[bytesCopied];
+
+ System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
+
+ return packedData;
+ }
+
+ /**
+ * Discards any characters outside of the base64 alphabet, per
+ * the requirements on page 25 of RFC 2045 - "Any characters
+ * outside of the base64 alphabet are to be ignored in base64
+ * encoded data."
+ *
+ * @param data The base-64 encoded data to groom
+ * @return The data, less non-base64 characters (see RFC 2045).
+ */
+ static byte[] discardNonBase64(byte[] data) {
+ byte groomedData[] = new byte[data.length];
+ int bytesCopied = 0;
+
+ for (int i = 0; i < data.length; i++) {
+ if (isBase64(data[i])) {
+ groomedData[bytesCopied++] = data[i];
+ }
+ }
+
+ byte packedData[] = new byte[bytesCopied];
+
+ System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
+
+ return packedData;
+ }
+
+
+ // Implementation of the Encoder Interface
+
+ /**
+ * Encodes an Object using the base64 algorithm. This method
+ * is provided in order to satisfy the requirements of the
+ * Encoder interface, and will throw an EncoderException if the
+ * supplied object is not of type byte[].
+ *
+ * @param pObject Object to encode
+ * @return An object (of type byte[]) containing the
+ * base64 encoded data which corresponds to the byte[] supplied.
+ * @throws EncoderException if the parameter supplied is not
+ * of type byte[]
+ */
+ public Object encode(Object pObject) throws EncoderException {
+ if (!(pObject instanceof byte[])) {
+ throw new EncoderException(Messages.getMessage(Messages.NO_BYTE_ARRAY_ERROR));
+ }
+ return encode((byte[]) pObject);
+ }
+
+ /**
+ * Encodes a byte[] containing binary data, into a byte[] containing
+ * characters in the Base64 alphabet.
+ *
+ * @param pArray a byte array containing binary data
+ * @return A byte array containing only Base64 character data
+ */
+ public byte[] encode(byte[] pArray) {
+ return encodeBase64(pArray, false);
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryDecoder.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/BinaryDecoder.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryDecoder.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,62 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.ajax4jsf.framework.util.base64;
-
-/**
- * Defines common decoding methods for byte array decoders.
- *
- * @author Apache Software Foundation
- * @version $Id: BinaryDecoder.java,v 1.1.2.1 2007/01/09 18:59:12 alexsmirnov Exp $
- */
-public interface BinaryDecoder extends Decoder {
-
- /**
- * Decodes a byte array and returns the results as a byte array.
- *
- * @param pArray A byte array which has been encoded with the
- * appropriate encoder
- *
- * @return a byte array that contains decoded content
- *
- * @throws DecoderException A decoder exception is thrown
- * if a Decoder encounters a failure condition during
- * the decode process.
- */
- byte[] decode(byte[] pArray) throws DecoderException;
-}
-
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryDecoder.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/BinaryDecoder.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryDecoder.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryDecoder.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,62 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.ajax4jsf.util.base64;
+
+/**
+ * Defines common decoding methods for byte array decoders.
+ *
+ * @author Apache Software Foundation
+ * @version $Id: BinaryDecoder.java,v 1.1.2.1 2007/01/09 18:59:12 alexsmirnov Exp $
+ */
+public interface BinaryDecoder extends Decoder {
+
+ /**
+ * Decodes a byte array and returns the results as a byte array.
+ *
+ * @param pArray A byte array which has been encoded with the
+ * appropriate encoder
+ *
+ * @return a byte array that contains decoded content
+ *
+ * @throws DecoderException A decoder exception is thrown
+ * if a Decoder encounters a failure condition during
+ * the decode process.
+ */
+ byte[] decode(byte[] pArray) throws DecoderException;
+}
+
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryEncoder.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/BinaryEncoder.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryEncoder.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,62 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.ajax4jsf.framework.util.base64;
-
-/**
- * Defines common encoding methods for byte array encoders.
- *
- * @author Apache Software Foundation
- * @version $Id: BinaryEncoder.java,v 1.1.2.1 2007/01/09 18:59:13 alexsmirnov Exp $
- */
-public interface BinaryEncoder extends Encoder {
-
- /**
- * Encodes a byte array and return the encoded data
- * as a byte array.
- *
- * @param pArray Data to be encoded
- *
- * @return A byte array containing the encoded data
- *
- * @throws EncoderException thrown if the Encoder
- * encounters a failure condition during the
- * encoding process.
- */
- byte[] encode(byte[] pArray) throws EncoderException;
-}
-
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryEncoder.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/BinaryEncoder.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryEncoder.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/BinaryEncoder.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,62 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.ajax4jsf.util.base64;
+
+/**
+ * Defines common encoding methods for byte array encoders.
+ *
+ * @author Apache Software Foundation
+ * @version $Id: BinaryEncoder.java,v 1.1.2.1 2007/01/09 18:59:13 alexsmirnov Exp $
+ */
+public interface BinaryEncoder extends Encoder {
+
+ /**
+ * Encodes a byte array and return the encoded data
+ * as a byte array.
+ *
+ * @param pArray Data to be encoded
+ *
+ * @return A byte array containing the encoded data
+ *
+ * @throws EncoderException thrown if the Encoder
+ * encounters a failure condition during the
+ * encoding process.
+ */
+ byte[] encode(byte[] pArray) throws EncoderException;
+}
+
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Codec.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/Codec.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Codec.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,138 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.base64;
-
-import java.io.UnsupportedEncodingException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.KeySpec;
-
-import javax.crypto.Cipher;
-import javax.crypto.NoSuchPaddingException;
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactory;
-import javax.crypto.spec.DESKeySpec;
-import javax.faces.FacesException;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:10 $
- *
- */
-public class Codec {
-
- private Cipher e = null;
- private Cipher d = null;
-
-
- /**
- *
- */
- public Codec() {
- }
-
- /**
- *
- */
- public Codec( String p ) throws Exception {
- setPassword(p);
- }
-
- /**
- * @param p
- * @throws InvalidKeyException
- * @throws UnsupportedEncodingException
- * @throws InvalidKeySpecException
- * @throws NoSuchAlgorithmException
- * @throws NoSuchPaddingException
- */
- public void setPassword(String p) throws FacesException {
- byte[] s = {
- (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
- (byte)0x56, (byte)0x34, (byte)0xE3, (byte)0x03
- };
- try {
- KeySpec keySpec = new DESKeySpec(p.getBytes("UTF8"));
- SecretKey key = SecretKeyFactory.getInstance("DES")
- .generateSecret(keySpec);
- e = Cipher.getInstance(key.getAlgorithm());
- d = Cipher.getInstance(key.getAlgorithm());
-
- // Prepare the parameters to the cipthers
-// AlgorithmParameterSpec paramSpec = new IvParameterSpec(s);
-
- e.init(Cipher.ENCRYPT_MODE, key);
- d.init(Cipher.DECRYPT_MODE, key);
- } catch (Exception e) {
- throw new FacesException("Error set encryption key",e);
- }
- }
-
- public String decode(String str) throws Exception {
- byte[] src = str.getBytes("UTF8");
- byte[] utf8 = decode(src);
- // Decode using utf-8
- return new String(utf8, "UTF8");
- }
- public String encode(String str) throws Exception {
-// try {
-
- byte[] src = str.getBytes("UTF8");
-// int len = (src.length/8+1)*8;
-// byte[] block = new byte[len];
-// Arrays.fill(block,0,len,(byte)0x20);
-// System.arraycopy(src,0,block,0,src.length);
-
- // Decrypt
- byte[] utf8 = encode(src);
-
- // Decode using utf-8
- return new String(utf8, "UTF8");
-// } catch (Exception e) {
-// // TODO: handle exception
-// return null;
-// }
- }
-
- public byte[] decode(byte[] src) throws Exception {
- byte[] dec = URL64Codec.decodeBase64(src);
- // Decrypt
- if (null != d) {
- return d.doFinal(dec);
- } else {
- return dec;
- }
- }
-
- public byte[] encode(byte[] src) throws Exception {
- byte[] dec;
- if(null != e){
- dec = e.doFinal(src);
- } else {
- dec = src;
- }
- // Decrypt
- return URL64Codec.encodeBase64(dec);
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Codec.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/Codec.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Codec.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Codec.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,138 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.util.base64;
+
+import java.io.UnsupportedEncodingException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.KeySpec;
+
+import javax.crypto.Cipher;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.DESKeySpec;
+import javax.faces.FacesException;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:10 $
+ *
+ */
+public class Codec {
+
+ private Cipher e = null;
+ private Cipher d = null;
+
+
+ /**
+ *
+ */
+ public Codec() {
+ }
+
+ /**
+ *
+ */
+ public Codec( String p ) throws Exception {
+ setPassword(p);
+ }
+
+ /**
+ * @param p
+ * @throws InvalidKeyException
+ * @throws UnsupportedEncodingException
+ * @throws InvalidKeySpecException
+ * @throws NoSuchAlgorithmException
+ * @throws NoSuchPaddingException
+ */
+ public void setPassword(String p) throws FacesException {
+ byte[] s = {
+ (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
+ (byte)0x56, (byte)0x34, (byte)0xE3, (byte)0x03
+ };
+ try {
+ KeySpec keySpec = new DESKeySpec(p.getBytes("UTF8"));
+ SecretKey key = SecretKeyFactory.getInstance("DES")
+ .generateSecret(keySpec);
+ e = Cipher.getInstance(key.getAlgorithm());
+ d = Cipher.getInstance(key.getAlgorithm());
+
+ // Prepare the parameters to the cipthers
+// AlgorithmParameterSpec paramSpec = new IvParameterSpec(s);
+
+ e.init(Cipher.ENCRYPT_MODE, key);
+ d.init(Cipher.DECRYPT_MODE, key);
+ } catch (Exception e) {
+ throw new FacesException("Error set encryption key",e);
+ }
+ }
+
+ public String decode(String str) throws Exception {
+ byte[] src = str.getBytes("UTF8");
+ byte[] utf8 = decode(src);
+ // Decode using utf-8
+ return new String(utf8, "UTF8");
+ }
+ public String encode(String str) throws Exception {
+// try {
+
+ byte[] src = str.getBytes("UTF8");
+// int len = (src.length/8+1)*8;
+// byte[] block = new byte[len];
+// Arrays.fill(block,0,len,(byte)0x20);
+// System.arraycopy(src,0,block,0,src.length);
+
+ // Decrypt
+ byte[] utf8 = encode(src);
+
+ // Decode using utf-8
+ return new String(utf8, "UTF8");
+// } catch (Exception e) {
+// // TODO: handle exception
+// return null;
+// }
+ }
+
+ public byte[] decode(byte[] src) throws Exception {
+ byte[] dec = URL64Codec.decodeBase64(src);
+ // Decrypt
+ if (null != d) {
+ return d.doFinal(dec);
+ } else {
+ return dec;
+ }
+ }
+
+ public byte[] encode(byte[] src) throws Exception {
+ byte[] dec;
+ if(null != e){
+ dec = e.doFinal(src);
+ } else {
+ dec = src;
+ }
+ // Decrypt
+ return URL64Codec.encodeBase64(dec);
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Decoder.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/Decoder.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Decoder.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,75 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.ajax4jsf.framework.util.base64;
-
-/**
- * <p>Provides the highest level of abstraction for Decoders.
- * This is the sister interface of {@link Encoder}. All
- * Decoders implement this common generic interface.</p>
- *
- * <p>Allows a user to pass a generic Object to any Decoder
- * implementation in the codec package.</p>
- *
- * <p>One of the two interfaces at the center of the codec package.</p>
- *
- * @author Apache Software Foundation
- * @version $Id: Decoder.java,v 1.1.2.1 2007/01/09 18:59:14 alexsmirnov Exp $
- */
-public interface Decoder {
-
- /**
- * Decodes an "encoded" Object and returns a "decoded"
- * Object. Note that the implementation of this
- * interface will try to cast the Object parameter
- * to the specific type expected by a particular Decoder
- * implementation. If a {@link java.lang.ClassCastException} occurs
- * this decode method will throw a DecoderException.
- *
- * @param pObject an object to "decode"
- *
- * @return a 'decoded" object
- *
- * @throws DecoderException a decoder exception can
- * be thrown for any number of reasons. Some good
- * candidates are that the parameter passed to this
- * method is null, a param cannot be cast to the
- * appropriate type for a specific encoder.
- */
- Object decode(Object pObject) throws DecoderException;
-}
-
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Decoder.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/Decoder.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Decoder.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Decoder.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,75 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.ajax4jsf.util.base64;
+
+/**
+ * <p>Provides the highest level of abstraction for Decoders.
+ * This is the sister interface of {@link Encoder}. All
+ * Decoders implement this common generic interface.</p>
+ *
+ * <p>Allows a user to pass a generic Object to any Decoder
+ * implementation in the codec package.</p>
+ *
+ * <p>One of the two interfaces at the center of the codec package.</p>
+ *
+ * @author Apache Software Foundation
+ * @version $Id: Decoder.java,v 1.1.2.1 2007/01/09 18:59:14 alexsmirnov Exp $
+ */
+public interface Decoder {
+
+ /**
+ * Decodes an "encoded" Object and returns a "decoded"
+ * Object. Note that the implementation of this
+ * interface will try to cast the Object parameter
+ * to the specific type expected by a particular Decoder
+ * implementation. If a {@link java.lang.ClassCastException} occurs
+ * this decode method will throw a DecoderException.
+ *
+ * @param pObject an object to "decode"
+ *
+ * @return a 'decoded" object
+ *
+ * @throws DecoderException a decoder exception can
+ * be thrown for any number of reasons. Some good
+ * candidates are that the parameter passed to this
+ * method is null, a param cannot be cast to the
+ * appropriate type for a specific encoder.
+ */
+ Object decode(Object pObject) throws DecoderException;
+}
+
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/DecoderException.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/DecoderException.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/DecoderException.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,58 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.ajax4jsf.framework.util.base64;
-
-/**
- * Thrown when a Decoder has encountered a failure condition during a decode.
- *
- * @author Apache Software Foundation
- * @version $Id: DecoderException.java,v 1.1.2.1 2007/01/09 18:59:13 alexsmirnov Exp $
- */
-public class DecoderException extends Exception {
-
- /**
- * Creates a DecoderException
- *
- * @param pMessage A message with meaning to a human
- */
- public DecoderException(String pMessage) {
- super(pMessage);
- }
-
-}
-
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/DecoderException.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/DecoderException.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/DecoderException.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/DecoderException.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,58 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.ajax4jsf.util.base64;
+
+/**
+ * Thrown when a Decoder has encountered a failure condition during a decode.
+ *
+ * @author Apache Software Foundation
+ * @version $Id: DecoderException.java,v 1.1.2.1 2007/01/09 18:59:13 alexsmirnov Exp $
+ */
+public class DecoderException extends Exception {
+
+ /**
+ * Creates a DecoderException
+ *
+ * @param pMessage A message with meaning to a human
+ */
+ public DecoderException(String pMessage) {
+ super(pMessage);
+ }
+
+}
+
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Encoder.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/Encoder.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Encoder.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,66 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.ajax4jsf.framework.util.base64;
-
-/**
- * <p>Provides the highest level of abstraction for Encoders.
- * This is the sister interface of {@link Decoder}. Every implementation of
- * Encoder provides this common generic interface whic allows a user to pass a
- * generic Object to any Encoder implementation in the codec package.</p>
- *
- * @author Apache Software Foundation
- * @version $Id: Encoder.java,v 1.1.2.1 2007/01/09 18:59:12 alexsmirnov Exp $
- */
-public interface Encoder {
-
- /**
- * Encodes an "Object" and returns the encoded content
- * as an Object. The Objects here may just be <code>byte[]</code>
- * or <code>String</code>s depending on the implementation used.
- *
- * @param pObject An object ot encode
- *
- * @return An "encoded" Object
- *
- * @throws EncoderException an encoder exception is
- * thrown if the encoder experiences a failure
- * condition during the encoding process.
- */
- Object encode(Object pObject) throws EncoderException;
-}
-
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Encoder.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/Encoder.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Encoder.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/Encoder.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.ajax4jsf.util.base64;
+
+/**
+ * <p>Provides the highest level of abstraction for Encoders.
+ * This is the sister interface of {@link Decoder}. Every implementation of
+ * Encoder provides this common generic interface whic allows a user to pass a
+ * generic Object to any Encoder implementation in the codec package.</p>
+ *
+ * @author Apache Software Foundation
+ * @version $Id: Encoder.java,v 1.1.2.1 2007/01/09 18:59:12 alexsmirnov Exp $
+ */
+public interface Encoder {
+
+ /**
+ * Encodes an "Object" and returns the encoded content
+ * as an Object. The Objects here may just be <code>byte[]</code>
+ * or <code>String</code>s depending on the implementation used.
+ *
+ * @param pObject An object ot encode
+ *
+ * @return An "encoded" Object
+ *
+ * @throws EncoderException an encoder exception is
+ * thrown if the encoder experiences a failure
+ * condition during the encoding process.
+ */
+ Object encode(Object pObject) throws EncoderException;
+}
+
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/EncoderException.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/EncoderException.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/EncoderException.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,60 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.ajax4jsf.framework.util.base64;
-
-/**
- * Thrown when there is a failure condition during the encoding process. This
- * exception is thrown when an Encoder encounters a encoding specific exception
- * such as invalid data, inability to calculate a checksum, characters outside of the
- * expected range.
- *
- * @author Apache Software Foundation
- * @version $Id: EncoderException.java,v 1.1.2.1 2007/01/09 18:59:12 alexsmirnov Exp $
- */
-public class EncoderException extends Exception {
-
- /**
- * Creates a new instance of this exception with an useful message.
- *
- * @param pMessage a useful message relating to the encoder specific error.
- */
- public EncoderException(String pMessage) {
- super(pMessage);
- }
-}
-
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/EncoderException.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/EncoderException.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/EncoderException.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/EncoderException.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,60 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.ajax4jsf.util.base64;
+
+/**
+ * Thrown when there is a failure condition during the encoding process. This
+ * exception is thrown when an Encoder encounters a encoding specific exception
+ * such as invalid data, inability to calculate a checksum, characters outside of the
+ * expected range.
+ *
+ * @author Apache Software Foundation
+ * @version $Id: EncoderException.java,v 1.1.2.1 2007/01/09 18:59:12 alexsmirnov Exp $
+ */
+public class EncoderException extends Exception {
+
+ /**
+ * Creates a new instance of this exception with an useful message.
+ *
+ * @param pMessage a useful message relating to the encoder specific error.
+ */
+ public EncoderException(String pMessage) {
+ super(pMessage);
+ }
+}
+
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URL64Codec.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/URL64Codec.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URL64Codec.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,542 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.ajax4jsf.framework.util.base64;
-
-import org.ajax4jsf.Messages;
-
-
-/**
- * Provides Base64 encoding and decoding like defined by RFC 2045, but with little difference :
- * chars '=' '+' and '/' , incorrectly processed in URL by any browsers, replaced by '_' '-' '.',
- *
- *
- * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>
- * @author Apache Software Foundation
- * @since 1.0-dev
- * @version $Id: URL64Codec.java,v 1.1.2.1 2007/01/09 18:59:11 alexsmirnov Exp $
- */
-public class URL64Codec implements BinaryEncoder, BinaryDecoder {
-
- /**
- * Chunk size per RFC 2045 section 6.8.
- *
- * <p>The {@value} character limit does not count the trailing CRLF, but counts
- * all other characters, including any equal signs.</p>
- *
- * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 6.8</a>
- */
- static final int CHUNK_SIZE = 76;
-
- /**
- * Chunk separator per RFC 2045 section 2.1.
- *
- * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 2.1</a>
- */
- static final byte[] CHUNK_SEPARATOR = "\r\n".getBytes();
-
- /**
- * The base length.
- */
- static final int BASELENGTH = 255;
-
- /**
- * Lookup length.
- */
- static final int LOOKUPLENGTH = 64;
-
- /**
- * Used to calculate the number of bits in a byte.
- */
- static final int EIGHTBIT = 8;
-
- /**
- * Used when encoding something which has fewer than 24 bits.
- */
- static final int SIXTEENBIT = 16;
-
- /**
- * Used to determine how many bits data contains.
- */
- static final int TWENTYFOURBITGROUP = 24;
-
- /**
- * Used to get the number of Quadruples.
- */
- static final int FOURBYTE = 4;
-
- /**
- * Used to test the sign of a byte.
- */
- static final int SIGN = -128;
-
- /**
- * Byte used to pad output. instesd of '=' in base64, used '_'
- */
- static final byte PAD = (byte) '_';
-
- // Create arrays to hold the base64 characters and a
- // lookup for base64 chars
- private static byte[] base64Alphabet = new byte[BASELENGTH];
- private static byte[] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
-
- // Populating the lookup and character arrays
- static {
- for (int i = 0; i < BASELENGTH; i++) {
- base64Alphabet[i] = (byte) -1;
- }
- for (int i = 'Z'; i >= 'A'; i--) {
- base64Alphabet[i] = (byte) (i - 'A');
- }
- for (int i = 'z'; i >= 'a'; i--) {
- base64Alphabet[i] = (byte) (i - 'a' + 26);
- }
- for (int i = '9'; i >= '0'; i--) {
- base64Alphabet[i] = (byte) (i - '0' + 52);
- }
-
- // To compatible with URL format, change '+' and '/' to :
- base64Alphabet['-'] = 62;
- base64Alphabet['.'] = 63;
-
- for (int i = 0; i <= 25; i++) {
- lookUpBase64Alphabet[i] = (byte) ('A' + i);
- }
-
- for (int i = 26, j = 0; i <= 51; i++, j++) {
- lookUpBase64Alphabet[i] = (byte) ('a' + j);
- }
-
- for (int i = 52, j = 0; i <= 61; i++, j++) {
- lookUpBase64Alphabet[i] = (byte) ('0' + j);
- }
-
- // To compatible with URL format, change '+' and '/' to :
- lookUpBase64Alphabet[62] = (byte) '-';
- lookUpBase64Alphabet[63] = (byte) '.';
- }
-
- private static boolean isBase64(byte octect) {
- if (octect == PAD) {
- return true;
- } else if (base64Alphabet[octect] == -1) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Tests a given byte array to see if it contains
- * only valid characters within the Base64 alphabet.
- *
- * @param arrayOctect byte array to test
- * @return true if all bytes are valid characters in the Base64
- * alphabet or if the byte array is empty; false, otherwise
- */
- public static boolean isArrayByteBase64(byte[] arrayOctect) {
-
- arrayOctect = discardWhitespace(arrayOctect);
-
- int length = arrayOctect.length;
- if (length == 0) {
- // shouldn't a 0 length array be valid base64 data?
- // return false;
- return true;
- }
- for (int i = 0; i < length; i++) {
- if (!isBase64(arrayOctect[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Encodes binary data using the base64 algorithm but
- * does not chunk the output.
- *
- * @param binaryData binary data to encode
- * @return Base64 characters
- */
- public static byte[] encodeBase64(byte[] binaryData) {
- return encodeBase64(binaryData, false);
- }
-
- /**
- * Encodes binary data using the base64 algorithm and chunks
- * the encoded output into 76 character blocks
- *
- * @param binaryData binary data to encode
- * @return Base64 characters chunked in 76 character blocks
- */
- public static byte[] encodeBase64Chunked(byte[] binaryData) {
- return encodeBase64(binaryData, true);
- }
-
-
- /**
- * Decodes an Object using the base64 algorithm. This method
- * is provided in order to satisfy the requirements of the
- * Decoder interface, and will throw a DecoderException if the
- * supplied object is not of type byte[].
- *
- * @param pObject Object to decode
- * @return An object (of type byte[]) containing the
- * binary data which corresponds to the byte[] supplied.
- * @throws DecoderException if the parameter supplied is not
- * of type byte[]
- */
- public Object decode(Object pObject) throws DecoderException {
- if (!(pObject instanceof byte[])) {
- throw new DecoderException(Messages.getMessage(Messages.NO_BYTE_ARRAY_ERROR));
- }
- return decode((byte[]) pObject);
- }
-
- /**
- * Decodes a byte[] containing containing
- * characters in the Base64 alphabet.
- *
- * @param pArray A byte array containing Base64 character data
- * @return a byte array containing binary data
- */
- public byte[] decode(byte[] pArray) {
- return decodeBase64(pArray);
- }
-
- /**
- * Encodes binary data using the base64 algorithm, optionally
- * chunking the output into 76 character blocks.
- *
- * @param binaryData Array containing binary data to encode.
- * @param isChunked if isChunked is true this encoder will chunk
- * the base64 output into 76 character blocks
- * @return Base64-encoded data.
- */
- public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
- int lengthDataBits = binaryData.length * EIGHTBIT;
- int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
- int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
- byte encodedData[] = null;
- int encodedDataLength = 0;
- int nbrChunks = 0;
-
- if (fewerThan24bits != 0) {
- //data not divisible by 24 bit
- encodedDataLength = (numberTriplets + 1) * 4;
- } else {
- // 16 or 8 bit
- encodedDataLength = numberTriplets * 4;
- }
-
- // If the output is to be "chunked" into 76 character sections,
- // for compliance with RFC 2045 MIME, then it is important to
- // allow for extra length to account for the separator(s)
- if (isChunked) {
-
- nbrChunks =
- (CHUNK_SEPARATOR.length == 0 ? 0 : (int) Math.ceil((float) encodedDataLength / CHUNK_SIZE));
- encodedDataLength += nbrChunks * CHUNK_SEPARATOR.length;
- }
-
- encodedData = new byte[encodedDataLength];
-
- byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0;
-
- int encodedIndex = 0;
- int dataIndex = 0;
- int i = 0;
- int nextSeparatorIndex = CHUNK_SIZE;
- int chunksSoFar = 0;
-
- //log.debug("number of triplets = " + numberTriplets);
- for (i = 0; i < numberTriplets; i++) {
- dataIndex = i * 3;
- b1 = binaryData[dataIndex];
- b2 = binaryData[dataIndex + 1];
- b3 = binaryData[dataIndex + 2];
-
- //log.debug("b1= " + b1 +", b2= " + b2 + ", b3= " + b3);
-
- l = (byte) (b2 & 0x0f);
- k = (byte) (b1 & 0x03);
-
- byte val1 =
- ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
- byte val2 =
- ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
- byte val3 =
- ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc);
-
- encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
- //log.debug( "val2 = " + val2 );
- //log.debug( "k4 = " + (k<<4) );
- //log.debug( "vak = " + (val2 | (k<<4)) );
- encodedData[encodedIndex + 1] =
- lookUpBase64Alphabet[val2 | (k << 4)];
- encodedData[encodedIndex + 2] =
- lookUpBase64Alphabet[(l << 2) | val3];
- encodedData[encodedIndex + 3] = lookUpBase64Alphabet[b3 & 0x3f];
-
- encodedIndex += 4;
-
- // If we are chunking, let's put a chunk separator down.
- if (isChunked) {
- // this assumes that CHUNK_SIZE % 4 == 0
- if (encodedIndex == nextSeparatorIndex) {
- System.arraycopy(
- CHUNK_SEPARATOR,
- 0,
- encodedData,
- encodedIndex,
- CHUNK_SEPARATOR.length);
- chunksSoFar++;
- nextSeparatorIndex =
- (CHUNK_SIZE * (chunksSoFar + 1)) +
- (chunksSoFar * CHUNK_SEPARATOR.length);
- encodedIndex += CHUNK_SEPARATOR.length;
- }
- }
- }
-
- // form integral number of 6-bit groups
- dataIndex = i * 3;
-
- if (fewerThan24bits == EIGHTBIT) {
- b1 = binaryData[dataIndex];
- k = (byte) (b1 & 0x03);
- //log.debug("b1=" + b1);
- //log.debug("b1<<2 = " + (b1>>2) );
- byte val1 =
- ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
- encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
- encodedData[encodedIndex + 1] = lookUpBase64Alphabet[k << 4];
- encodedData[encodedIndex + 2] = PAD;
- encodedData[encodedIndex + 3] = PAD;
- } else if (fewerThan24bits == SIXTEENBIT) {
-
- b1 = binaryData[dataIndex];
- b2 = binaryData[dataIndex + 1];
- l = (byte) (b2 & 0x0f);
- k = (byte) (b1 & 0x03);
-
- byte val1 =
- ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
- byte val2 =
- ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
-
- encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
- encodedData[encodedIndex + 1] =
- lookUpBase64Alphabet[val2 | (k << 4)];
- encodedData[encodedIndex + 2] = lookUpBase64Alphabet[l << 2];
- encodedData[encodedIndex + 3] = PAD;
- }
-
- if (isChunked) {
- // we also add a separator to the end of the final chunk.
- if (chunksSoFar < nbrChunks) {
- System.arraycopy(
- CHUNK_SEPARATOR,
- 0,
- encodedData,
- encodedDataLength - CHUNK_SEPARATOR.length,
- CHUNK_SEPARATOR.length);
- }
- }
-
- return encodedData;
- }
-
- /**
- * Decodes Base64 data into octects
- *
- * @param base64Data Byte array containing Base64 data
- * @return Array containing decoded data.
- */
- public static byte[] decodeBase64(byte[] base64Data) {
- // RFC 2045 requires that we discard ALL non-Base64 characters
- base64Data = discardNonBase64(base64Data);
-
- // handle the edge case, so we don't have to worry about it later
- if (base64Data.length == 0) {
- return new byte[0];
- }
-
- int numberQuadruple = base64Data.length / FOURBYTE;
- byte decodedData[] = null;
- byte b1 = 0, b2 = 0, b3 = 0, b4 = 0, marker0 = 0, marker1 = 0;
-
- // Throw away anything not in base64Data
-
- int encodedIndex = 0;
- int dataIndex = 0;
- {
- // this sizes the output array properly - rlw
- int lastData = base64Data.length;
- // ignore the '=' padding
- while (base64Data[lastData - 1] == PAD) {
- if (--lastData == 0) {
- return new byte[0];
- }
- }
- decodedData = new byte[lastData - numberQuadruple];
- }
-
- for (int i = 0; i < numberQuadruple; i++) {
- dataIndex = i * 4;
- marker0 = base64Data[dataIndex + 2];
- marker1 = base64Data[dataIndex + 3];
-
- b1 = base64Alphabet[base64Data[dataIndex]];
- b2 = base64Alphabet[base64Data[dataIndex + 1]];
-
- if (marker0 != PAD && marker1 != PAD) {
- //No PAD e.g 3cQl
- b3 = base64Alphabet[marker0];
- b4 = base64Alphabet[marker1];
-
- decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
- decodedData[encodedIndex + 1] =
- (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
- decodedData[encodedIndex + 2] = (byte) (b3 << 6 | b4);
- } else if (marker0 == PAD) {
- //Two PAD e.g. 3c[Pad][Pad]
- decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
- } else if (marker1 == PAD) {
- //One PAD e.g. 3cQ[Pad]
- b3 = base64Alphabet[marker0];
-
- decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
- decodedData[encodedIndex + 1] =
- (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
- }
- encodedIndex += 3;
- }
- return decodedData;
- }
-
- /**
- * Discards any whitespace from a base-64 encoded block.
- *
- * @param data The base-64 encoded data to discard the whitespace
- * from.
- * @return The data, less whitespace (see RFC 2045).
- */
- static byte[] discardWhitespace(byte[] data) {
- byte groomedData[] = new byte[data.length];
- int bytesCopied = 0;
-
- for (int i = 0; i < data.length; i++) {
- switch (data[i]) {
- case (byte) ' ' :
- case (byte) '\n' :
- case (byte) '\r' :
- case (byte) '\t' :
- break;
- default:
- groomedData[bytesCopied++] = data[i];
- }
- }
-
- byte packedData[] = new byte[bytesCopied];
-
- System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
-
- return packedData;
- }
-
- /**
- * Discards any characters outside of the base64 alphabet, per
- * the requirements on page 25 of RFC 2045 - "Any characters
- * outside of the base64 alphabet are to be ignored in base64
- * encoded data."
- *
- * @param data The base-64 encoded data to groom
- * @return The data, less non-base64 characters (see RFC 2045).
- */
- static byte[] discardNonBase64(byte[] data) {
- byte groomedData[] = new byte[data.length];
- int bytesCopied = 0;
-
- for (int i = 0; i < data.length; i++) {
- if (isBase64(data[i])) {
- groomedData[bytesCopied++] = data[i];
- }
- }
-
- byte packedData[] = new byte[bytesCopied];
-
- System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
-
- return packedData;
- }
-
-
- // Implementation of the Encoder Interface
-
- /**
- * Encodes an Object using the base64 algorithm. This method
- * is provided in order to satisfy the requirements of the
- * Encoder interface, and will throw an EncoderException if the
- * supplied object is not of type byte[].
- *
- * @param pObject Object to encode
- * @return An object (of type byte[]) containing the
- * base64 encoded data which corresponds to the byte[] supplied.
- * @throws EncoderException if the parameter supplied is not
- * of type byte[]
- */
- public Object encode(Object pObject) throws EncoderException {
- if (!(pObject instanceof byte[])) {
- throw new EncoderException(Messages.getMessage(Messages.NO_BYTE_ARRAY_ERROR));
- }
- return encode((byte[]) pObject);
- }
-
- /**
- * Encodes a byte[] containing binary data, into a byte[] containing
- * characters in the Base64 alphabet.
- *
- * @param pArray a byte array containing binary data
- * @return A byte array containing only Base64 character data
- */
- public byte[] encode(byte[] pArray) {
- return encodeBase64(pArray, false);
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URL64Codec.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/URL64Codec.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URL64Codec.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URL64Codec.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,542 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.ajax4jsf.util.base64;
+
+import org.ajax4jsf.Messages;
+
+
+/**
+ * Provides Base64 encoding and decoding like defined by RFC 2045, but with little difference :
+ * chars '=' '+' and '/' , incorrectly processed in URL by any browsers, replaced by '_' '-' '.',
+ *
+ *
+ * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>
+ * @author Apache Software Foundation
+ * @since 1.0-dev
+ * @version $Id: URL64Codec.java,v 1.1.2.1 2007/01/09 18:59:11 alexsmirnov Exp $
+ */
+public class URL64Codec implements BinaryEncoder, BinaryDecoder {
+
+ /**
+ * Chunk size per RFC 2045 section 6.8.
+ *
+ * <p>The {@value} character limit does not count the trailing CRLF, but counts
+ * all other characters, including any equal signs.</p>
+ *
+ * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 6.8</a>
+ */
+ static final int CHUNK_SIZE = 76;
+
+ /**
+ * Chunk separator per RFC 2045 section 2.1.
+ *
+ * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 2.1</a>
+ */
+ static final byte[] CHUNK_SEPARATOR = "\r\n".getBytes();
+
+ /**
+ * The base length.
+ */
+ static final int BASELENGTH = 255;
+
+ /**
+ * Lookup length.
+ */
+ static final int LOOKUPLENGTH = 64;
+
+ /**
+ * Used to calculate the number of bits in a byte.
+ */
+ static final int EIGHTBIT = 8;
+
+ /**
+ * Used when encoding something which has fewer than 24 bits.
+ */
+ static final int SIXTEENBIT = 16;
+
+ /**
+ * Used to determine how many bits data contains.
+ */
+ static final int TWENTYFOURBITGROUP = 24;
+
+ /**
+ * Used to get the number of Quadruples.
+ */
+ static final int FOURBYTE = 4;
+
+ /**
+ * Used to test the sign of a byte.
+ */
+ static final int SIGN = -128;
+
+ /**
+ * Byte used to pad output. instesd of '=' in base64, used '_'
+ */
+ static final byte PAD = (byte) '_';
+
+ // Create arrays to hold the base64 characters and a
+ // lookup for base64 chars
+ private static byte[] base64Alphabet = new byte[BASELENGTH];
+ private static byte[] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
+
+ // Populating the lookup and character arrays
+ static {
+ for (int i = 0; i < BASELENGTH; i++) {
+ base64Alphabet[i] = (byte) -1;
+ }
+ for (int i = 'Z'; i >= 'A'; i--) {
+ base64Alphabet[i] = (byte) (i - 'A');
+ }
+ for (int i = 'z'; i >= 'a'; i--) {
+ base64Alphabet[i] = (byte) (i - 'a' + 26);
+ }
+ for (int i = '9'; i >= '0'; i--) {
+ base64Alphabet[i] = (byte) (i - '0' + 52);
+ }
+
+ // To compatible with URL format, change '+' and '/' to :
+ base64Alphabet['-'] = 62;
+ base64Alphabet['.'] = 63;
+
+ for (int i = 0; i <= 25; i++) {
+ lookUpBase64Alphabet[i] = (byte) ('A' + i);
+ }
+
+ for (int i = 26, j = 0; i <= 51; i++, j++) {
+ lookUpBase64Alphabet[i] = (byte) ('a' + j);
+ }
+
+ for (int i = 52, j = 0; i <= 61; i++, j++) {
+ lookUpBase64Alphabet[i] = (byte) ('0' + j);
+ }
+
+ // To compatible with URL format, change '+' and '/' to :
+ lookUpBase64Alphabet[62] = (byte) '-';
+ lookUpBase64Alphabet[63] = (byte) '.';
+ }
+
+ private static boolean isBase64(byte octect) {
+ if (octect == PAD) {
+ return true;
+ } else if (base64Alphabet[octect] == -1) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Tests a given byte array to see if it contains
+ * only valid characters within the Base64 alphabet.
+ *
+ * @param arrayOctect byte array to test
+ * @return true if all bytes are valid characters in the Base64
+ * alphabet or if the byte array is empty; false, otherwise
+ */
+ public static boolean isArrayByteBase64(byte[] arrayOctect) {
+
+ arrayOctect = discardWhitespace(arrayOctect);
+
+ int length = arrayOctect.length;
+ if (length == 0) {
+ // shouldn't a 0 length array be valid base64 data?
+ // return false;
+ return true;
+ }
+ for (int i = 0; i < length; i++) {
+ if (!isBase64(arrayOctect[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Encodes binary data using the base64 algorithm but
+ * does not chunk the output.
+ *
+ * @param binaryData binary data to encode
+ * @return Base64 characters
+ */
+ public static byte[] encodeBase64(byte[] binaryData) {
+ return encodeBase64(binaryData, false);
+ }
+
+ /**
+ * Encodes binary data using the base64 algorithm and chunks
+ * the encoded output into 76 character blocks
+ *
+ * @param binaryData binary data to encode
+ * @return Base64 characters chunked in 76 character blocks
+ */
+ public static byte[] encodeBase64Chunked(byte[] binaryData) {
+ return encodeBase64(binaryData, true);
+ }
+
+
+ /**
+ * Decodes an Object using the base64 algorithm. This method
+ * is provided in order to satisfy the requirements of the
+ * Decoder interface, and will throw a DecoderException if the
+ * supplied object is not of type byte[].
+ *
+ * @param pObject Object to decode
+ * @return An object (of type byte[]) containing the
+ * binary data which corresponds to the byte[] supplied.
+ * @throws DecoderException if the parameter supplied is not
+ * of type byte[]
+ */
+ public Object decode(Object pObject) throws DecoderException {
+ if (!(pObject instanceof byte[])) {
+ throw new DecoderException(Messages.getMessage(Messages.NO_BYTE_ARRAY_ERROR));
+ }
+ return decode((byte[]) pObject);
+ }
+
+ /**
+ * Decodes a byte[] containing containing
+ * characters in the Base64 alphabet.
+ *
+ * @param pArray A byte array containing Base64 character data
+ * @return a byte array containing binary data
+ */
+ public byte[] decode(byte[] pArray) {
+ return decodeBase64(pArray);
+ }
+
+ /**
+ * Encodes binary data using the base64 algorithm, optionally
+ * chunking the output into 76 character blocks.
+ *
+ * @param binaryData Array containing binary data to encode.
+ * @param isChunked if isChunked is true this encoder will chunk
+ * the base64 output into 76 character blocks
+ * @return Base64-encoded data.
+ */
+ public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
+ int lengthDataBits = binaryData.length * EIGHTBIT;
+ int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
+ int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
+ byte encodedData[] = null;
+ int encodedDataLength = 0;
+ int nbrChunks = 0;
+
+ if (fewerThan24bits != 0) {
+ //data not divisible by 24 bit
+ encodedDataLength = (numberTriplets + 1) * 4;
+ } else {
+ // 16 or 8 bit
+ encodedDataLength = numberTriplets * 4;
+ }
+
+ // If the output is to be "chunked" into 76 character sections,
+ // for compliance with RFC 2045 MIME, then it is important to
+ // allow for extra length to account for the separator(s)
+ if (isChunked) {
+
+ nbrChunks =
+ (CHUNK_SEPARATOR.length == 0 ? 0 : (int) Math.ceil((float) encodedDataLength / CHUNK_SIZE));
+ encodedDataLength += nbrChunks * CHUNK_SEPARATOR.length;
+ }
+
+ encodedData = new byte[encodedDataLength];
+
+ byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0;
+
+ int encodedIndex = 0;
+ int dataIndex = 0;
+ int i = 0;
+ int nextSeparatorIndex = CHUNK_SIZE;
+ int chunksSoFar = 0;
+
+ //log.debug("number of triplets = " + numberTriplets);
+ for (i = 0; i < numberTriplets; i++) {
+ dataIndex = i * 3;
+ b1 = binaryData[dataIndex];
+ b2 = binaryData[dataIndex + 1];
+ b3 = binaryData[dataIndex + 2];
+
+ //log.debug("b1= " + b1 +", b2= " + b2 + ", b3= " + b3);
+
+ l = (byte) (b2 & 0x0f);
+ k = (byte) (b1 & 0x03);
+
+ byte val1 =
+ ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
+ byte val2 =
+ ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
+ byte val3 =
+ ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc);
+
+ encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
+ //log.debug( "val2 = " + val2 );
+ //log.debug( "k4 = " + (k<<4) );
+ //log.debug( "vak = " + (val2 | (k<<4)) );
+ encodedData[encodedIndex + 1] =
+ lookUpBase64Alphabet[val2 | (k << 4)];
+ encodedData[encodedIndex + 2] =
+ lookUpBase64Alphabet[(l << 2) | val3];
+ encodedData[encodedIndex + 3] = lookUpBase64Alphabet[b3 & 0x3f];
+
+ encodedIndex += 4;
+
+ // If we are chunking, let's put a chunk separator down.
+ if (isChunked) {
+ // this assumes that CHUNK_SIZE % 4 == 0
+ if (encodedIndex == nextSeparatorIndex) {
+ System.arraycopy(
+ CHUNK_SEPARATOR,
+ 0,
+ encodedData,
+ encodedIndex,
+ CHUNK_SEPARATOR.length);
+ chunksSoFar++;
+ nextSeparatorIndex =
+ (CHUNK_SIZE * (chunksSoFar + 1)) +
+ (chunksSoFar * CHUNK_SEPARATOR.length);
+ encodedIndex += CHUNK_SEPARATOR.length;
+ }
+ }
+ }
+
+ // form integral number of 6-bit groups
+ dataIndex = i * 3;
+
+ if (fewerThan24bits == EIGHTBIT) {
+ b1 = binaryData[dataIndex];
+ k = (byte) (b1 & 0x03);
+ //log.debug("b1=" + b1);
+ //log.debug("b1<<2 = " + (b1>>2) );
+ byte val1 =
+ ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
+ encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
+ encodedData[encodedIndex + 1] = lookUpBase64Alphabet[k << 4];
+ encodedData[encodedIndex + 2] = PAD;
+ encodedData[encodedIndex + 3] = PAD;
+ } else if (fewerThan24bits == SIXTEENBIT) {
+
+ b1 = binaryData[dataIndex];
+ b2 = binaryData[dataIndex + 1];
+ l = (byte) (b2 & 0x0f);
+ k = (byte) (b1 & 0x03);
+
+ byte val1 =
+ ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
+ byte val2 =
+ ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
+
+ encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
+ encodedData[encodedIndex + 1] =
+ lookUpBase64Alphabet[val2 | (k << 4)];
+ encodedData[encodedIndex + 2] = lookUpBase64Alphabet[l << 2];
+ encodedData[encodedIndex + 3] = PAD;
+ }
+
+ if (isChunked) {
+ // we also add a separator to the end of the final chunk.
+ if (chunksSoFar < nbrChunks) {
+ System.arraycopy(
+ CHUNK_SEPARATOR,
+ 0,
+ encodedData,
+ encodedDataLength - CHUNK_SEPARATOR.length,
+ CHUNK_SEPARATOR.length);
+ }
+ }
+
+ return encodedData;
+ }
+
+ /**
+ * Decodes Base64 data into octects
+ *
+ * @param base64Data Byte array containing Base64 data
+ * @return Array containing decoded data.
+ */
+ public static byte[] decodeBase64(byte[] base64Data) {
+ // RFC 2045 requires that we discard ALL non-Base64 characters
+ base64Data = discardNonBase64(base64Data);
+
+ // handle the edge case, so we don't have to worry about it later
+ if (base64Data.length == 0) {
+ return new byte[0];
+ }
+
+ int numberQuadruple = base64Data.length / FOURBYTE;
+ byte decodedData[] = null;
+ byte b1 = 0, b2 = 0, b3 = 0, b4 = 0, marker0 = 0, marker1 = 0;
+
+ // Throw away anything not in base64Data
+
+ int encodedIndex = 0;
+ int dataIndex = 0;
+ {
+ // this sizes the output array properly - rlw
+ int lastData = base64Data.length;
+ // ignore the '=' padding
+ while (base64Data[lastData - 1] == PAD) {
+ if (--lastData == 0) {
+ return new byte[0];
+ }
+ }
+ decodedData = new byte[lastData - numberQuadruple];
+ }
+
+ for (int i = 0; i < numberQuadruple; i++) {
+ dataIndex = i * 4;
+ marker0 = base64Data[dataIndex + 2];
+ marker1 = base64Data[dataIndex + 3];
+
+ b1 = base64Alphabet[base64Data[dataIndex]];
+ b2 = base64Alphabet[base64Data[dataIndex + 1]];
+
+ if (marker0 != PAD && marker1 != PAD) {
+ //No PAD e.g 3cQl
+ b3 = base64Alphabet[marker0];
+ b4 = base64Alphabet[marker1];
+
+ decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
+ decodedData[encodedIndex + 1] =
+ (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
+ decodedData[encodedIndex + 2] = (byte) (b3 << 6 | b4);
+ } else if (marker0 == PAD) {
+ //Two PAD e.g. 3c[Pad][Pad]
+ decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
+ } else if (marker1 == PAD) {
+ //One PAD e.g. 3cQ[Pad]
+ b3 = base64Alphabet[marker0];
+
+ decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
+ decodedData[encodedIndex + 1] =
+ (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
+ }
+ encodedIndex += 3;
+ }
+ return decodedData;
+ }
+
+ /**
+ * Discards any whitespace from a base-64 encoded block.
+ *
+ * @param data The base-64 encoded data to discard the whitespace
+ * from.
+ * @return The data, less whitespace (see RFC 2045).
+ */
+ static byte[] discardWhitespace(byte[] data) {
+ byte groomedData[] = new byte[data.length];
+ int bytesCopied = 0;
+
+ for (int i = 0; i < data.length; i++) {
+ switch (data[i]) {
+ case (byte) ' ' :
+ case (byte) '\n' :
+ case (byte) '\r' :
+ case (byte) '\t' :
+ break;
+ default:
+ groomedData[bytesCopied++] = data[i];
+ }
+ }
+
+ byte packedData[] = new byte[bytesCopied];
+
+ System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
+
+ return packedData;
+ }
+
+ /**
+ * Discards any characters outside of the base64 alphabet, per
+ * the requirements on page 25 of RFC 2045 - "Any characters
+ * outside of the base64 alphabet are to be ignored in base64
+ * encoded data."
+ *
+ * @param data The base-64 encoded data to groom
+ * @return The data, less non-base64 characters (see RFC 2045).
+ */
+ static byte[] discardNonBase64(byte[] data) {
+ byte groomedData[] = new byte[data.length];
+ int bytesCopied = 0;
+
+ for (int i = 0; i < data.length; i++) {
+ if (isBase64(data[i])) {
+ groomedData[bytesCopied++] = data[i];
+ }
+ }
+
+ byte packedData[] = new byte[bytesCopied];
+
+ System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
+
+ return packedData;
+ }
+
+
+ // Implementation of the Encoder Interface
+
+ /**
+ * Encodes an Object using the base64 algorithm. This method
+ * is provided in order to satisfy the requirements of the
+ * Encoder interface, and will throw an EncoderException if the
+ * supplied object is not of type byte[].
+ *
+ * @param pObject Object to encode
+ * @return An object (of type byte[]) containing the
+ * base64 encoded data which corresponds to the byte[] supplied.
+ * @throws EncoderException if the parameter supplied is not
+ * of type byte[]
+ */
+ public Object encode(Object pObject) throws EncoderException {
+ if (!(pObject instanceof byte[])) {
+ throw new EncoderException(Messages.getMessage(Messages.NO_BYTE_ARRAY_ERROR));
+ }
+ return encode((byte[]) pObject);
+ }
+
+ /**
+ * Encodes a byte[] containing binary data, into a byte[] containing
+ * characters in the Base64 alphabet.
+ *
+ * @param pArray a byte array containing binary data
+ * @return A byte array containing only Base64 character data
+ */
+ public byte[] encode(byte[] pArray) {
+ return encodeBase64(pArray, false);
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URLCodec.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/URLCodec.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URLCodec.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,499 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
-
- * Copyright 2001-2004 The Apache Software Foundation.
-
- *
-
- * Licensed under the Apache License, Version 2.0 (the "License");
-
- * you may not use this file except in compliance with the License.
-
- * You may obtain a copy of the License at
-
- *
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- *
-
- * Unless required by applicable law or agreed to in writing, software
-
- * distributed under the License is distributed on an "AS IS" BASIS,
-
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
- * See the License for the specific language governing permissions and
-
- * limitations under the License.
-
- */
-
-
-
-package org.ajax4jsf.framework.util.base64;
-
-
-
-import java.io.ByteArrayOutputStream;
-
-import java.util.BitSet;
-
-
-
-/**
-
- * <p>Implements the 'www-form-urlencoded' encoding scheme,
-
- * also misleadingly known as URL encoding.</p>
-
- *
-
- * <p>For more detailed information please refer to
-
- * <a href="http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1">
-
- * Chapter 17.13.4 'Form content types'</a> of the
-
- * <a href="http://www.w3.org/TR/html4/">HTML 4.01 Specification<a></p>
-
- *
-
- * <p>
-
- * This codec is meant to be a replacement for standard Java classes
-
- * {@link java.net.URLEncoder} and {@link java.net.URLDecoder}
-
- * on older Java platforms, as these classes in Java versions below
-
- * 1.4 rely on the platform's default charset encoding.
-
- * </p>
-
- *
-
- * @author Apache Software Foundation
-
- * @since 1.2
-
- * @version $Id: URLCodec.java,v 1.1.2.1 2007/01/09 18:59:14 alexsmirnov Exp $
-
- */
-
-public class URLCodec implements BinaryEncoder, BinaryDecoder {
-
-
-
- protected static byte ESCAPE_CHAR = '%';
-
- /**
-
- * BitSet of www-form-url safe characters.
-
- */
-
- protected static final BitSet WWW_FORM_URL = new BitSet(256);
-
-
-
- // Static initializer for www_form_url
-
- static {
-
- // alpha characters
-
- for (int i = 'a'; i <= 'z'; i++) {
-
- WWW_FORM_URL.set(i);
-
- }
-
- for (int i = 'A'; i <= 'Z'; i++) {
-
- WWW_FORM_URL.set(i);
-
- }
-
- // numeric characters
-
- for (int i = '0'; i <= '9'; i++) {
-
- WWW_FORM_URL.set(i);
-
- }
-
- // special chars
-
- WWW_FORM_URL.set('-');
-
- WWW_FORM_URL.set('_');
-
- WWW_FORM_URL.set('.');
-
- WWW_FORM_URL.set('*');
-
- // blank to be replaced with +
-
- WWW_FORM_URL.set(' ');
-
- }
-
-
-
-
-
- /**
-
- * Default constructor.
-
- */
-
- public URLCodec() {
-
- super();
-
- }
-
-
-
- public static final byte[] encodeUrl( byte[] bytes)
-
- {
-
- return encodeUrl(WWW_FORM_URL, bytes);
-
- }
-
- /**
-
- * Encodes an array of bytes into an array of URL safe 7-bit
-
- * characters. Unsafe characters are escaped.
-
- *
-
- * @param urlsafe bitset of characters deemed URL safe
-
- * @param bytes array of bytes to convert to URL safe characters
-
- * @return array of bytes containing URL safe characters
-
- */
-
- public static final byte[] encodeUrl(BitSet urlsafe, byte[] bytes)
-
- {
-
- if (bytes == null) {
-
- return null;
-
- }
-
- if (urlsafe == null) {
-
- urlsafe = WWW_FORM_URL;
-
- }
-
-
-
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-
- for (int i = 0; i < bytes.length; i++) {
-
- int b = bytes[i];
-
- if (b < 0) {
-
- b = 256 + b;
-
- }
-
- if (urlsafe.get(b)) {
-
- if (b == ' ') {
-
- b = '+';
-
- }
-
- buffer.write(b);
-
- } else {
-
- buffer.write('%');
-
- char hex1 = Character.toUpperCase(
-
- Character.forDigit((b >> 4) & 0xF, 16));
-
- char hex2 = Character.toUpperCase(
-
- Character.forDigit(b & 0xF, 16));
-
- buffer.write(hex1);
-
- buffer.write(hex2);
-
- }
-
- }
-
- return buffer.toByteArray();
-
- }
-
-
-
-
-
- /**
-
- * Decodes an array of URL safe 7-bit characters into an array of
-
- * original bytes. Escaped characters are converted back to their
-
- * original representation.
-
- *
-
- * @param bytes array of URL safe characters
-
- * @return array of original bytes
-
- * @throws DecoderException Thrown if URL decoding is unsuccessful
-
- */
-
- public static final byte[] decodeUrl(byte[] bytes)
-
- throws DecoderException
-
- {
-
- if (bytes == null) {
-
- return null;
-
- }
-
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-
- for (int i = 0; i < bytes.length; i++) {
-
- int b = bytes[i];
-
- if (b == '+') {
-
- buffer.write(' ');
-
- } else if (b == '%') {
-
- try {
-
- int u = Character.digit((char)bytes[++i], 16);
-
- int l = Character.digit((char)bytes[++i], 16);
-
- if (u == -1 || l == -1) {
-
- throw new DecoderException("Invalid URL encoding");
-
- }
-
- buffer.write((char)((u << 4) + l));
-
- } catch(ArrayIndexOutOfBoundsException e) {
-
- throw new DecoderException("Invalid URL encoding");
-
- }
-
- } else {
-
- buffer.write(b);
-
- }
-
- }
-
- return buffer.toByteArray();
-
- }
-
-
-
-
-
- /**
-
- * Encodes an array of bytes into an array of URL safe 7-bit
-
- * characters. Unsafe characters are escaped.
-
- *
-
- * @param bytes array of bytes to convert to URL safe characters
-
- * @return array of bytes containing URL safe characters
-
- */
-
- public byte[] encode(byte[] bytes) {
-
- return encodeUrl(WWW_FORM_URL, bytes);
-
- }
-
-
-
-
-
- /**
-
- * Decodes an array of URL safe 7-bit characters into an array of
-
- * original bytes. Escaped characters are converted back to their
-
- * original representation.
-
- *
-
- * @param bytes array of URL safe characters
-
- * @return array of original bytes
-
- * @throws DecoderException Thrown if URL decoding is unsuccessful
-
- */
-
- public byte[] decode(byte[] bytes) throws DecoderException {
-
- return decodeUrl(bytes);
-
- }
-
-
-
-
-
- /**
-
- * Encodes an object into its URL safe form. Unsafe characters are
-
- * escaped.
-
- *
-
- * @param pObject string to convert to a URL safe form
-
- * @return URL safe object
-
- * @throws EncoderException Thrown if URL encoding is not
-
- * applicable to objects of this type or
-
- * if encoding is unsuccessful
-
- */
-
- public Object encode(Object pObject) throws EncoderException {
-
- if (pObject == null) {
-
- return null;
-
- } else if (pObject instanceof byte[]) {
-
- return encode((byte[])pObject);
-
- } else if (pObject instanceof String) {
-
- return encode((String)pObject);
-
- } else {
-
- throw new EncoderException("Objects of type " +
-
- pObject.getClass().getName() + " cannot be URL encoded");
-
-
-
- }
-
- }
-
-
-
- /**
-
- * Decodes a URL safe object into its original form. Escaped
-
- * characters are converted back to their original representation.
-
- *
-
- * @param pObject URL safe object to convert into its original form
-
- * @return original object
-
- * @throws DecoderException Thrown if URL decoding is not
-
- * applicable to objects of this type
-
- * if decoding is unsuccessful
-
- */
-
- public Object decode(Object pObject) throws DecoderException {
-
- if (pObject == null) {
-
- return null;
-
- } else if (pObject instanceof byte[]) {
-
- return decode((byte[])pObject);
-
- } else if (pObject instanceof String) {
-
- return decode((String)pObject);
-
- } else {
-
- throw new DecoderException("Objects of type " +
-
- pObject.getClass().getName() + " cannot be URL decoded");
-
-
-
- }
-
- }
-
-
-
-}
-
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URLCodec.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/base64/URLCodec.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URLCodec.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/base64/URLCodec.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,499 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+
+ * Copyright 2001-2004 The Apache Software Foundation.
+
+ *
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+
+ * you may not use this file except in compliance with the License.
+
+ * You may obtain a copy of the License at
+
+ *
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ *
+
+ * Unless required by applicable law or agreed to in writing, software
+
+ * distributed under the License is distributed on an "AS IS" BASIS,
+
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+ * See the License for the specific language governing permissions and
+
+ * limitations under the License.
+
+ */
+
+
+
+package org.ajax4jsf.util.base64;
+
+
+
+import java.io.ByteArrayOutputStream;
+
+import java.util.BitSet;
+
+
+
+/**
+
+ * <p>Implements the 'www-form-urlencoded' encoding scheme,
+
+ * also misleadingly known as URL encoding.</p>
+
+ *
+
+ * <p>For more detailed information please refer to
+
+ * <a href="http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1">
+
+ * Chapter 17.13.4 'Form content types'</a> of the
+
+ * <a href="http://www.w3.org/TR/html4/">HTML 4.01 Specification<a></p>
+
+ *
+
+ * <p>
+
+ * This codec is meant to be a replacement for standard Java classes
+
+ * {@link java.net.URLEncoder} and {@link java.net.URLDecoder}
+
+ * on older Java platforms, as these classes in Java versions below
+
+ * 1.4 rely on the platform's default charset encoding.
+
+ * </p>
+
+ *
+
+ * @author Apache Software Foundation
+
+ * @since 1.2
+
+ * @version $Id: URLCodec.java,v 1.1.2.1 2007/01/09 18:59:14 alexsmirnov Exp $
+
+ */
+
+public class URLCodec implements BinaryEncoder, BinaryDecoder {
+
+
+
+ protected static byte ESCAPE_CHAR = '%';
+
+ /**
+
+ * BitSet of www-form-url safe characters.
+
+ */
+
+ protected static final BitSet WWW_FORM_URL = new BitSet(256);
+
+
+
+ // Static initializer for www_form_url
+
+ static {
+
+ // alpha characters
+
+ for (int i = 'a'; i <= 'z'; i++) {
+
+ WWW_FORM_URL.set(i);
+
+ }
+
+ for (int i = 'A'; i <= 'Z'; i++) {
+
+ WWW_FORM_URL.set(i);
+
+ }
+
+ // numeric characters
+
+ for (int i = '0'; i <= '9'; i++) {
+
+ WWW_FORM_URL.set(i);
+
+ }
+
+ // special chars
+
+ WWW_FORM_URL.set('-');
+
+ WWW_FORM_URL.set('_');
+
+ WWW_FORM_URL.set('.');
+
+ WWW_FORM_URL.set('*');
+
+ // blank to be replaced with +
+
+ WWW_FORM_URL.set(' ');
+
+ }
+
+
+
+
+
+ /**
+
+ * Default constructor.
+
+ */
+
+ public URLCodec() {
+
+ super();
+
+ }
+
+
+
+ public static final byte[] encodeUrl( byte[] bytes)
+
+ {
+
+ return encodeUrl(WWW_FORM_URL, bytes);
+
+ }
+
+ /**
+
+ * Encodes an array of bytes into an array of URL safe 7-bit
+
+ * characters. Unsafe characters are escaped.
+
+ *
+
+ * @param urlsafe bitset of characters deemed URL safe
+
+ * @param bytes array of bytes to convert to URL safe characters
+
+ * @return array of bytes containing URL safe characters
+
+ */
+
+ public static final byte[] encodeUrl(BitSet urlsafe, byte[] bytes)
+
+ {
+
+ if (bytes == null) {
+
+ return null;
+
+ }
+
+ if (urlsafe == null) {
+
+ urlsafe = WWW_FORM_URL;
+
+ }
+
+
+
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+
+ for (int i = 0; i < bytes.length; i++) {
+
+ int b = bytes[i];
+
+ if (b < 0) {
+
+ b = 256 + b;
+
+ }
+
+ if (urlsafe.get(b)) {
+
+ if (b == ' ') {
+
+ b = '+';
+
+ }
+
+ buffer.write(b);
+
+ } else {
+
+ buffer.write('%');
+
+ char hex1 = Character.toUpperCase(
+
+ Character.forDigit((b >> 4) & 0xF, 16));
+
+ char hex2 = Character.toUpperCase(
+
+ Character.forDigit(b & 0xF, 16));
+
+ buffer.write(hex1);
+
+ buffer.write(hex2);
+
+ }
+
+ }
+
+ return buffer.toByteArray();
+
+ }
+
+
+
+
+
+ /**
+
+ * Decodes an array of URL safe 7-bit characters into an array of
+
+ * original bytes. Escaped characters are converted back to their
+
+ * original representation.
+
+ *
+
+ * @param bytes array of URL safe characters
+
+ * @return array of original bytes
+
+ * @throws DecoderException Thrown if URL decoding is unsuccessful
+
+ */
+
+ public static final byte[] decodeUrl(byte[] bytes)
+
+ throws DecoderException
+
+ {
+
+ if (bytes == null) {
+
+ return null;
+
+ }
+
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+
+ for (int i = 0; i < bytes.length; i++) {
+
+ int b = bytes[i];
+
+ if (b == '+') {
+
+ buffer.write(' ');
+
+ } else if (b == '%') {
+
+ try {
+
+ int u = Character.digit((char)bytes[++i], 16);
+
+ int l = Character.digit((char)bytes[++i], 16);
+
+ if (u == -1 || l == -1) {
+
+ throw new DecoderException("Invalid URL encoding");
+
+ }
+
+ buffer.write((char)((u << 4) + l));
+
+ } catch(ArrayIndexOutOfBoundsException e) {
+
+ throw new DecoderException("Invalid URL encoding");
+
+ }
+
+ } else {
+
+ buffer.write(b);
+
+ }
+
+ }
+
+ return buffer.toByteArray();
+
+ }
+
+
+
+
+
+ /**
+
+ * Encodes an array of bytes into an array of URL safe 7-bit
+
+ * characters. Unsafe characters are escaped.
+
+ *
+
+ * @param bytes array of bytes to convert to URL safe characters
+
+ * @return array of bytes containing URL safe characters
+
+ */
+
+ public byte[] encode(byte[] bytes) {
+
+ return encodeUrl(WWW_FORM_URL, bytes);
+
+ }
+
+
+
+
+
+ /**
+
+ * Decodes an array of URL safe 7-bit characters into an array of
+
+ * original bytes. Escaped characters are converted back to their
+
+ * original representation.
+
+ *
+
+ * @param bytes array of URL safe characters
+
+ * @return array of original bytes
+
+ * @throws DecoderException Thrown if URL decoding is unsuccessful
+
+ */
+
+ public byte[] decode(byte[] bytes) throws DecoderException {
+
+ return decodeUrl(bytes);
+
+ }
+
+
+
+
+
+ /**
+
+ * Encodes an object into its URL safe form. Unsafe characters are
+
+ * escaped.
+
+ *
+
+ * @param pObject string to convert to a URL safe form
+
+ * @return URL safe object
+
+ * @throws EncoderException Thrown if URL encoding is not
+
+ * applicable to objects of this type or
+
+ * if encoding is unsuccessful
+
+ */
+
+ public Object encode(Object pObject) throws EncoderException {
+
+ if (pObject == null) {
+
+ return null;
+
+ } else if (pObject instanceof byte[]) {
+
+ return encode((byte[])pObject);
+
+ } else if (pObject instanceof String) {
+
+ return encode((String)pObject);
+
+ } else {
+
+ throw new EncoderException("Objects of type " +
+
+ pObject.getClass().getName() + " cannot be URL encoded");
+
+
+
+ }
+
+ }
+
+
+
+ /**
+
+ * Decodes a URL safe object into its original form. Escaped
+
+ * characters are converted back to their original representation.
+
+ *
+
+ * @param pObject URL safe object to convert into its original form
+
+ * @return original object
+
+ * @throws DecoderException Thrown if URL decoding is not
+
+ * applicable to objects of this type
+
+ * if decoding is unsuccessful
+
+ */
+
+ public Object decode(Object pObject) throws DecoderException {
+
+ if (pObject == null) {
+
+ return null;
+
+ } else if (pObject instanceof byte[]) {
+
+ return decode((byte[])pObject);
+
+ } else if (pObject instanceof String) {
+
+ return decode((String)pObject);
+
+ } else {
+
+ throw new DecoderException("Objects of type " +
+
+ pObject.getClass().getName() + " cannot be URL decoded");
+
+
+
+ }
+
+ }
+
+
+
+}
+
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/config (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/config)
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/config/FilterBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/config/FilterBean.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/config/FilterBean.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,109 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.config;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:58 $
- *
- */
-public class FilterBean {
- private String _filterName;
- private String _filterClass;
- private String _displayName;
- private String _description;
- private Set _filterMappings = new HashSet();
- private Set _servlets = new HashSet();
-
- /**
- * @return Returns the description.
- */
- public String getDescription() {
- return _description;
- }
- /**
- * @param description The description to set.
- */
- public void setDescription(String description) {
- _description = description;
- }
- /**
- * @return Returns the displayName.
- */
- public String getDisplayName() {
- return _displayName;
- }
- /**
- * @param displayName The displayName to set.
- */
- public void setDisplayName(String displayName) {
- _displayName = displayName;
- }
- /**
- * @return Returns the servletClass.
- */
- public String getFilterClass() {
- return _filterClass;
- }
- /**
- * @param servletClass The servletClass to set.
- */
- public void setFilterClass(String servletClass) {
- _filterClass = servletClass;
- }
- /**
- * @return Returns the servletName.
- */
- public String getFilterName() {
- return _filterName;
- }
- /**
- * @param servletName The servletName to set.
- */
- public void setFilterName(String servletName) {
- _filterName = servletName.trim();
- }
- /* (non-Javadoc)
- * @see java.util.Map#keySet()
- */
- public Set getMappings() {
- return _filterMappings;
- }
- /* (non-Javadoc)
- * @see java.util.Map#put(java.lang.Object, java.lang.Object)
- */
- void addMapping(String mapping) {
- _filterMappings.add(mapping);
- }
-
- public void addServlet(String servlet) {
- _servlets.add(servlet.trim());
-
- }
- public Set getServlets() {
- return _servlets;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/config/ServletBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/config/ServletBean.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/config/ServletBean.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,100 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.config;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:59 $
- *
- */
-public class ServletBean {
- private String _servletName;
- private String _servletClass;
- private String _displayName;
- private String _description;
- private Set _servletMappings = new HashSet();
- /**
- * @return Returns the description.
- */
- public String getDescription() {
- return _description;
- }
- /**
- * @param description The description to set.
- */
- public void setDescription(String description) {
- _description = description;
- }
- /**
- * @return Returns the displayName.
- */
- public String getDisplayName() {
- return _displayName;
- }
- /**
- * @param displayName The displayName to set.
- */
- public void setDisplayName(String displayName) {
- _displayName = displayName;
- }
- /**
- * @return Returns the servletClass.
- */
- public String getServletClass() {
- return _servletClass;
- }
- /**
- * @param servletClass The servletClass to set.
- */
- public void setServletClass(String servletClass) {
- _servletClass = servletClass;
- }
- /**
- * @return Returns the servletName.
- */
- public String getServletName() {
- return _servletName;
- }
- /**
- * @param servletName The servletName to set.
- */
- public void setServletName(String servletName) {
- _servletName = servletName.trim();
- }
- /* (non-Javadoc)
- * @see java.util.Map#keySet()
- */
- public Set getMappings() {
- return _servletMappings;
- }
- /* (non-Javadoc)
- * @see java.util.Map#put(java.lang.Object, java.lang.Object)
- */
- void addMapping(String mapping) {
- _servletMappings.add(mapping);
- }
-
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/config/WebXml.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/config/WebXml.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/config/WebXml.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,433 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.config;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.context.FacesContext;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.digester.Digester;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.LocatorImpl;
-
-/**
- * Parse at startup application web.xml and store servlet and filter mappings.
- * at runtime, used for convert resource key to uri, and vice versa.
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:59 $
- *
- */
-public class WebXml implements Serializable {
-
- public static final String CONTEXT_ATTRIBUTE = WebXml.class.getName();
-
- /**
- *
- */
- private static final long serialVersionUID = -9042908418843695017L;
-
- private static final Log _log = LogFactory.getLog(WebXml.class);
-
- static final String WEB_XML = "/WEB-INF/web.xml";
-
-
- public static final String RESOURCE_URI_PREFIX = "a4j.res/";
-
- static final String RESOURCE_URI_PREFIX_WITH_SLASH = "/"
- + RESOURCE_URI_PREFIX;
-
- /**
- * Prefix for Resourse-Ajax filter, in common must be same as for
- * {@link javax.faces.webapp.FacesServlet}
- */
- private String _facesFilterPrefix = null;
-
- /**
- * Suffix for Resource-Ajax filter , in common must be same as for
- * {@link javax.faces.webapp.FacesServlet}
- */
- private String _facesFilterSuffix = null;
-
- private boolean _prefixMapping = false;
-
- private String _filterName;
-
- private Map _servlets = new HashMap();
-
- private Map _filters = new HashMap();
-
- /**
- * Prefix for resources handled by Chameleon framework.
- */
- private String _resourcePrefix = RESOURCE_URI_PREFIX_WITH_SLASH;
-
-
- /**
- * Parse application web.xml configuration and detect mapping for resources
- * and logs.
- * @param context
- * @param filterName
- * @throws ServletException
- */
- public void init(ServletContext context, String filterName) throws ServletException {
- InputStream webXml = context.getResourceAsStream(WEB_XML);
- if (null == webXml) {
- throw new ServletException(Messages.getMessage(
- Messages.GET_RESOURCE_AS_STREAM_ERROR, WEB_XML));
- }
- Digester dig = new Digester();
- dig.setDocumentLocator(new LocatorImpl());
- // Disable xml validations at all - web.xml already validated by
- // container
- dig.setValidating(false);
- dig.setEntityResolver(new EntityResolver() {
- // Dummi resolver - alvays do nothing
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
- return new InputSource(new StringReader(""));
- }
-
- });
- dig.setNamespaceAware(false);
- // dig.setUseContextClassLoader(true);
- dig.setClassLoader(this.getClass().getClassLoader());
- // Parsing rules.
- // Servlets.
- String path = "web-app/servlet";
- dig.addObjectCreate(path, ServletBean.class);
- dig.addBeanPropertySetter(path + "/servlet-name", "servletName");
- dig.addBeanPropertySetter(path + "/servlet-class", "servletClass");
- dig.addBeanPropertySetter(path + "/display-name", "displayName");
- dig.addBeanPropertySetter(path + "/description");
- dig.addSetNext(path, "addServlet");
- // Filters
- path = "web-app/filter";
- dig.addObjectCreate(path, FilterBean.class);
- dig.addBeanPropertySetter(path + "/filter-name", "filterName");
- dig.addBeanPropertySetter(path + "/filter-class", "filterClass");
- dig.addBeanPropertySetter(path + "/display-name", "displayName");
- dig.addBeanPropertySetter(path + "/description");
- dig.addSetNext(path, "addFilter");
- // Servlet mappings
- path = "web-app/servlet-mapping";
- dig.addCallMethod(path, "addServletMapping", 2);
- dig.addCallParam(path + "/servlet-name", 0);
- dig.addCallParam(path + "/url-pattern", 1);
- // Filter mappings
- // TODO - parse dispatcher.
- path = "web-app/filter-mapping";
- dig.addCallMethod(path, "addFilterMapping", 3);
- dig.addCallParam(path + "/filter-name", 0);
- dig.addCallParam(path + "/url-pattern", 1);
- dig.addCallParam(path + "/servlet-name", 2);
- dig.push(this);
- try {
- dig.parse(webXml);
- this.setFilterName(filterName);
- // Store Instance to context attribute.
- context.setAttribute(CONTEXT_ATTRIBUTE,this);
- } catch (IOException e) {
- String message = Messages
- .getMessage(Messages.PARSING_WEB_XML_IO_ERROR);
- _log.error(message, e);
- throw new ServletException(message, e);
- } catch (SAXException e) {
- String message = Messages
- .getMessage(Messages.PARSING_WEB_XML_SAX_ERROR);
- _log.error(message, e);
- throw new ServletException(message, e);
- } finally {
- try {
- webXml.close();
- } catch (IOException e) {
- // this exception don't affect any aspects of work and can be
- // ignored.
- }
- }
- }
-
- public void addServlet(ServletBean bean) {
- String name = bean.getServletName();
- if (null != name) {
- _servlets.put(name, bean);
- }
- }
-
- public void addFilter(FilterBean bean) {
- String name = bean.getFilterName();
- if (null != name) {
- _filters.put(name, bean);
- }
-
- }
-
- public void addServletMapping(String servletName, String mapping) {
- ServletBean servletBean = (ServletBean) _servlets.get(servletName);
- if (null != servletBean) {
- (servletBean).addMapping(mapping);
- }
- }
-
- public void addFilterMapping(String filterName, String mapping,
- String servlet) {
- FilterBean filterBean = (FilterBean) _filters.get(filterName);
- if (null != filterBean) {
- if (null != mapping) {
- (filterBean).addMapping(mapping);
- }
- if (null != servlet) {
- (filterBean).addServlet(servlet);
- }
- }
- }
-
- /**
- * Convert {@link org.ajax4jsf.resource.InternetResource } key to
- * real URL for handle by chameleon filter, depend of mapping in WEB.XML .
- * For prefix or * mapping, prepend servlet prefix and default Resource
- * prefix to key. For suffix mapping, prepend with resource prefix and
- * append default faces suffix to URL ( before request param ). After
- * conversion, call
- * {@link javax.faces.application.ViewHandler#getResourceURL(javax.faces.context.FacesContext, java.lang.String)}
- * and
- * {@link javax.faces.context.ExternalContext#encodeResourceURL(java.lang.String)} .
- *
- * @param context
- * @param Url
- * @return
- */
- public String getFacesResourceURL(FacesContext context, String Url) {
- StringBuffer buf = new StringBuffer();
- buf.append(getResourcePrefix()).append(Url);
- // Insert suffix mapping
- if (isPrefixMapping()) {
- buf.insert(0, getFacesFilterPrefix());
- } else {
- int index;
- if ((index = buf.indexOf("?")) >= 0) {
- buf.insert(index, getFacesFilterSuffix());
- } else {
- buf.append(getFacesFilterSuffix());
- }
- }
- String resourceURL = context.getApplication().getViewHandler()
- .getResourceURL(context, buf.toString());
- return resourceURL;
-
- }
-
- /**
- * Detect request to resource and extract key from request
- *
- * @param request
- * current http request
- * @return resource key, or null for ordinary faces request.
- */
- public String getFacesResourceKey(HttpServletRequest request) {
- String resourcePath = request.getRequestURI().substring(
- request.getContextPath().length());// isPrefixMapping()?request.getPathInfo():request.getServletPath();
- // Remove JSESSIONID - for expired sessions it will merged to path.
- int jsesionidStart;
- if ((jsesionidStart = resourcePath.lastIndexOf(";jsessionid")) >= 0) {
- resourcePath = resourcePath.substring(0, jsesionidStart);
- }
- if (isPrefixMapping()) {
- if (resourcePath.startsWith(getFacesFilterPrefix()
- + getResourcePrefix())) {
- return resourcePath.substring(getFacesFilterPrefix().length()
- + getResourcePrefix().length());
- }
- } else if (resourcePath.startsWith(getResourcePrefix())) {
- return resourcePath.substring(getResourcePrefix().length(),
- resourcePath.length() - getFacesFilterSuffix().length());
- }
- return null;
- }
-
- /**
- * Detect request to {@link javax.faces.webapp.FacesServlet}
- *
- * @param request
- * @return true if request parsed to JSF.
- */
- public boolean isFacesRequest(HttpServletRequest request) {
- // String resourcePath =
- // request.getRequestURI().substring(request.getContextPath().length());//isPrefixMapping()?request.getPathInfo():request.getServletPath();
- // if(isPrefixMapping() ) {
- // if (resourcePath.startsWith(getFacesFilterPrefix())) {
- // return true;
- // }
- // } else if (resourcePath.endsWith(getFacesFilterSuffix())) {
- // return true;
- // }
- // return false;
- return true;
- }
-
- /**
- * @return Returns the facesFilterPrefix.
- */
- public String getFacesFilterPrefix() {
- return _facesFilterPrefix;
- }
-
- /**
- * @param facesFilterPrefix
- * The facesFilterPrefix to set.
- */
- void setFacesFilterPrefix(String facesFilterPrefix) {
- _facesFilterPrefix = facesFilterPrefix;
- }
-
- /**
- * @return Returns the facesFilterSuffix.
- */
- public String getFacesFilterSuffix() {
- return _facesFilterSuffix;
- }
-
- /**
- * @param facesFilterSuffix
- * The facesFilterSuffix to set.
- */
- void setFacesFilterSuffix(String facesFilterSuffix) {
- _facesFilterSuffix = facesFilterSuffix;
- }
-
- /**
- * @return Returns the resourcePrefix.
- */
- public String getResourcePrefix() {
- return _resourcePrefix;
- }
-
- /**
- * @param resourcePrefix
- * The resourcePrefix to set.
- */
- void setResourcePrefix(String resourcePrefix) {
- _resourcePrefix = resourcePrefix;
- }
-
- /**
- * @return Returns the filterName.
- */
- public String getFilterName() {
- return _filterName;
- }
-
- /**
- * After parsing web.xml set chameleon filter name, for wich we must
- * calculate mappings for resources, logs etc.
- *
- * @param filterName
- * The filterName to set.
- */
- void setFilterName(String filterName) {
- if (null == filterName) {
- _log.warn(Messages.getMessage(Messages.NULL_FILTER_NAME_WARNING));
- return;
- }
- _filterName = filterName.trim();
- // get config for this filter
- FilterBean filter = (FilterBean) _filters.get(_filterName);
- if (null == filter) {
- _log.warn(Messages.getMessage(Messages.FILTER_NOT_FOUND_ERROR,
- _filterName));
- throw new IllegalStateException(Messages.getMessage(
- Messages.FILTER_NOT_FOUND_ERROR, filterName));
- }
- // find faces servlet
- checkMapping(filter.getMappings());
- // Filter mapped only to servlet.
- if (_facesFilterPrefix == null && _facesFilterSuffix == null) {
- for (Iterator sevlets = filter.getServlets().iterator(); sevlets
- .hasNext()
- && _facesFilterPrefix == null && _facesFilterSuffix == null;) {
- String servletname = (String) sevlets.next();
- ServletBean servlet = (ServletBean) _servlets.get(servletname);
- if (null != servlet) {
- checkMapping(servlet.getMappings());
- }
- }
- }
- if (null != _facesFilterPrefix) {
- _prefixMapping = true;
- if (_facesFilterPrefix.endsWith("/")) {
- setResourcePrefix(RESOURCE_URI_PREFIX);
- } else {
- setResourcePrefix(RESOURCE_URI_PREFIX_WITH_SLASH);
- }
- } else if (null != _facesFilterSuffix) {
- _prefixMapping = false;
- setResourcePrefix(RESOURCE_URI_PREFIX_WITH_SLASH);
- } else {
- throw new IllegalStateException(Messages.getMessage(
- Messages.NO_PREFIX_OR_SUFFIX_IN_FILTER_MAPPING_ERROR,
- filterName));
- }
- }
-
- private void checkMapping(Set mappings) {
- if (null != mappings) {
- for (Iterator iter = mappings.iterator(); iter.hasNext();) {
- String mapping = (String) iter.next();
- // first test - for prefix, like /xxx/*
- // TODO - select correct dispatcher.
- if (mapping.endsWith("*")) {
- setFacesFilterPrefix(mapping.substring(0,
- mapping.length() - 1));
- break;
- } else
- // test for suffix mapping, eg *.xxx
- if (mapping.startsWith("*")) {
- setFacesFilterSuffix(mapping.substring(1));
- } else {
- // Fixed mapping - do not use it.
- }
- }
- }
- }
-
- /**
- * @return Returns the prefixMapping.
- */
- public boolean isPrefixMapping() {
- return _prefixMapping;
- }
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/image/imageio (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/imageio)
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/image/imageio/ImageIOGenerator.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/imageio/ImageIOGenerator.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/image/imageio/ImageIOGenerator.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,175 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Helma License Notice
- *
- * The contents of this file are subject to the Helma License
- * Version 2.0 (the "License"). You may not use this file except in
- * compliance with the License. A copy of the License is available at
- * http://adele.helma.org/download/helma/license.txt
- *
- * Copyright 1998-2003 Helma Software. All Rights Reserved.
- *
- * $RCSfile: ImageIOGenerator.java,v $
- * $Author: alexsmirnov $
- * $Revision: 1.1.2.1 $
- * $Date: 2007/01/09 19:00:17 $
- */
-
-/*
- * ImageIOGenerator defines it's own functions for reading from various
- * resources. These return BufferedImages, therefore all the images
- * are from the beginning in that format when working with ImageIO
- */
-
-package org.ajax4jsf.framework.util.image.imageio;
-
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.awt.image.DirectColorModel;
-import java.awt.image.WritableRaster;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Iterator;
-
-import javax.imageio.IIOImage;
-import javax.imageio.ImageIO;
-import javax.imageio.ImageWriteParam;
-import javax.imageio.ImageWriter;
-import javax.imageio.stream.ImageOutputStream;
-
-import org.ajax4jsf.framework.util.image.ImageGenerator;
-import org.ajax4jsf.framework.util.image.ImageWrapper;
-
-
-
-/**
- * A wrapper for an image that uses the ImageIO Framework.
- */
-public class ImageIOGenerator extends ImageGenerator {
- /**
- * @param filename the filename of the image to create
- *
- * @return the newly created image
- * @throws IOException
- */
- public Image read(String filename)
- throws IOException {
- return ImageIO.read(new File(filename));
- }
-
- /**
- * @param url the URL the filename of the image to create
- *
- * @return the newly created image
- * @throws IOException
- */
- public Image read(URL url)
- throws IOException {
- return ImageIO.read(url);
- }
-
- /**
- * @param src the data of the image to create
- *
- * @return the newly created image
- * @throws IOException
- */
- public Image read(byte[] src)
- throws IOException {
- return ImageIO.read(new ByteArrayInputStream(src));
- }
-
- /**
- * Saves the image. Image format is deduced from filename.
- *
- * @param filename ...
- * @param quality ...
- * @param alpha ...
- * @throws IOException
- * @see helma.image.ImageGenerator#write(helma.image.ImageWrapper, java.lang.String, float, boolean)
- */
- public void write(ImageWrapper wrapper, String filename, float quality, boolean alpha) throws IOException {
- int pos = filename.lastIndexOf('.');
- if (pos != -1) {
- String extension = filename.substring(pos + 1,
- filename.length()).toLowerCase();
-
- // Find a writer for that file extensions
- ImageWriter writer = null;
- Iterator iter = ImageIO.getImageWritersByFormatName(extension);
- if (iter.hasNext())
- writer = (ImageWriter) iter.next();
- if (writer != null) {
- ImageOutputStream ios = null;
- try {
- BufferedImage bi = wrapper.getBufferedImage();
- // Prepare output file
- File file = new File(filename);
- if (file.exists())
- file.delete();
- ios = ImageIO.createImageOutputStream(file);
- writer.setOutput(ios);
- // Set some parameters
- ImageWriteParam param = writer.getDefaultWriteParam();
- if (param.canWriteCompressed() &&
- quality >= 0.0 && quality <= 1.0) {
- param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
- param.setCompressionQuality(quality);
- }
- if (param.canWriteProgressive())
- param.setProgressiveMode(ImageWriteParam.MODE_DISABLED);
- // if bi has type ARGB and alpha is false, we have to tell the writer to not use the alpha channel:
- // this is especially needed for jpeg files where imageio seems to produce wrong jpeg files right now...
- if (bi.getType() == BufferedImage.TYPE_INT_ARGB
- && !alpha) {
- // create a new BufferedImage that uses a WritableRaster of bi, with all the bands except the alpha band:
- WritableRaster raster = bi.getRaster();
- WritableRaster newRaster = raster.createWritableChild(
- 0, 0, wrapper.getWidth(), wrapper.getHeight(),
- 0, 0, new int[] {0, 1, 2 }
- );
- // create a ColorModel that represents the one of the ARGB except the alpha channel:
- DirectColorModel cm = (DirectColorModel) bi.getColorModel();
- DirectColorModel newCM = new DirectColorModel(
- cm.getPixelSize(), cm.getRedMask(),
- cm.getGreenMask(), cm.getBlueMask());
- // now create the new buffer that is used ot write the image:
- BufferedImage rgbBuffer = new BufferedImage(newCM,
- newRaster, false, null);
- writer.write(null, new IIOImage(rgbBuffer, null,
- null), param);
- } else {
- writer.write(null, new IIOImage(bi, null, null),
- param);
- }
- } finally {
- if (ios != null)
- ios.close();
- writer.dispose();
- }
- }
- }
-}
-}
\ No newline at end of file
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/style (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/style)
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSFormat.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/style/CSSFormat.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSFormat.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,134 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.style;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-/**
- * Simple utility class for CSS style formatting
- * Current version isn't thread-safe and doesn't provide any validation
- *
- * Usage is simle
- * <code>
- * CSSFormat format = new CSSFormat();
- * format.add("background-position", "top left");
- * format.addURL("background-image", "/images/corner.gif");
- * responseWriter.writeAttribute("style", format, null);
- * </code>
- *
- * @author Maksim Kaszynski
- *
- */
-public class CSSFormat {
-
-
- /**
- * Surrounds given URL with <code>url()</code>
- * @param url
- * @return
- */
- public static String url(String url){
- StringBuffer buf = new StringBuffer(url.length() + 7);
- //escape url according to http://www.w3.org/TR/REC-CSS1#url
- buf.append("url(").append(url.replaceAll("([\\)\\(\\s,\'\"])", "\\\\$1")).append(")");
- return buf.toString();
- }
- /**
- * Formats property-value pair in CSS fashion
- * @param property
- * @param value
- * @return
- */
- public static String propertyValue(String property, String value){
- return formatPropertyValue(property, value);
- }
-
- private static String formatPropertyValue(Object property, Object value){
- StringBuffer buf = new StringBuffer();
- buf.append(property).append(": ").append(value).append(";");
- return buf.toString();
- }
-
- private Map properties;
- /**
- * Constructs an empty CSSFormat object
- */
- public CSSFormat() {
- properties = new HashMap();
- }
- /**
- * Constructs CSSFormat object
- * and fills it with given parameters
- * @param property
- * @param value
- */
- public CSSFormat(String property, String value){
- properties = new HashMap(3);
- add(property, value);
-
- }
- /**
- * Adds property. If such property already exists,
- * its value is replaced with new one
- * @param property
- * @param value
- * @return itself
- */
- public CSSFormat add(String property, String value){
- properties.put(property, value);
- return this;
- }
- /**
- * adds a property with URL value
- * given value is wrapped in <code>url()</code> clause
- * @param property
- * @param url
- * @return itself
- */
- public CSSFormat addURL(String property, String url){
- properties.put(property, url(url));
- return this;
- }
- /**
- * Concatenates all properties with their values to produce single-line CSS output
- */
- public String toString() {
- return concatenate(null);
- }
- /**
- * Concatenates all properties with their values to produce CSS output
- * @param separator - custom string to be inserted between properties
- * @return
- */
- public String concatenate(String separator){
- StringBuffer output = new StringBuffer();
- for(Iterator iter = properties.entrySet().iterator(); iter.hasNext();){
- Map.Entry entry = (Map.Entry) iter.next();
- output.append(formatPropertyValue(entry.getKey(), entry.getValue()));
- if(separator != null && iter.hasNext()){
- output.append(separator);
- }
- }
- return output.toString();
- }
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSFormat.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/style/CSSFormat.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSFormat.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSFormat.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,134 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.util.style;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+/**
+ * Simple utility class for CSS style formatting
+ * Current version isn't thread-safe and doesn't provide any validation
+ *
+ * Usage is simle
+ * <code>
+ * CSSFormat format = new CSSFormat();
+ * format.add("background-position", "top left");
+ * format.addURL("background-image", "/images/corner.gif");
+ * responseWriter.writeAttribute("style", format, null);
+ * </code>
+ *
+ * @author Maksim Kaszynski
+ *
+ */
+public class CSSFormat {
+
+
+ /**
+ * Surrounds given URL with <code>url()</code>
+ * @param url
+ * @return
+ */
+ public static String url(String url){
+ StringBuffer buf = new StringBuffer(url.length() + 7);
+ //escape url according to http://www.w3.org/TR/REC-CSS1#url
+ buf.append("url(").append(url.replaceAll("([\\)\\(\\s,\'\"])", "\\\\$1")).append(")");
+ return buf.toString();
+ }
+ /**
+ * Formats property-value pair in CSS fashion
+ * @param property
+ * @param value
+ * @return
+ */
+ public static String propertyValue(String property, String value){
+ return formatPropertyValue(property, value);
+ }
+
+ private static String formatPropertyValue(Object property, Object value){
+ StringBuffer buf = new StringBuffer();
+ buf.append(property).append(": ").append(value).append(";");
+ return buf.toString();
+ }
+
+ private Map properties;
+ /**
+ * Constructs an empty CSSFormat object
+ */
+ public CSSFormat() {
+ properties = new HashMap();
+ }
+ /**
+ * Constructs CSSFormat object
+ * and fills it with given parameters
+ * @param property
+ * @param value
+ */
+ public CSSFormat(String property, String value){
+ properties = new HashMap(3);
+ add(property, value);
+
+ }
+ /**
+ * Adds property. If such property already exists,
+ * its value is replaced with new one
+ * @param property
+ * @param value
+ * @return itself
+ */
+ public CSSFormat add(String property, String value){
+ properties.put(property, value);
+ return this;
+ }
+ /**
+ * adds a property with URL value
+ * given value is wrapped in <code>url()</code> clause
+ * @param property
+ * @param url
+ * @return itself
+ */
+ public CSSFormat addURL(String property, String url){
+ properties.put(property, url(url));
+ return this;
+ }
+ /**
+ * Concatenates all properties with their values to produce single-line CSS output
+ */
+ public String toString() {
+ return concatenate(null);
+ }
+ /**
+ * Concatenates all properties with their values to produce CSS output
+ * @param separator - custom string to be inserted between properties
+ * @return
+ */
+ public String concatenate(String separator){
+ StringBuffer output = new StringBuffer();
+ for(Iterator iter = properties.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry) iter.next();
+ output.append(formatPropertyValue(entry.getKey(), entry.getValue()));
+ if(separator != null && iter.hasNext()){
+ output.append(separator);
+ }
+ }
+ return output.toString();
+ }
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSSelector.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/style/CSSSelector.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSSelector.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,50 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.style;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class CSSSelector {
- private StringBuffer selectorBuffer;
- public CSSSelector() {
- selectorBuffer = new StringBuffer();
- }
- public CSSSelector(String selector){
- this();
- selectorBuffer.append(selector);
- }
-
- public CSSSelector addSelector(String selector){
- if(selector != null){
- if(selectorBuffer.length() > 0){
- selectorBuffer.append(' ');
- }
- selectorBuffer.append(selector);
- }
- return this;
- }
- public String toString() {
- return selectorBuffer.toString();
- }
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSSelector.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/style/CSSSelector.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSSelector.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/CSSSelector.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,50 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.util.style;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class CSSSelector {
+ private StringBuffer selectorBuffer;
+ public CSSSelector() {
+ selectorBuffer = new StringBuffer();
+ }
+ public CSSSelector(String selector){
+ this();
+ selectorBuffer.append(selector);
+ }
+
+ public CSSSelector addSelector(String selector){
+ if(selector != null){
+ if(selectorBuffer.length() > 0){
+ selectorBuffer.append(' ');
+ }
+ selectorBuffer.append(selector);
+ }
+ return this;
+ }
+ public String toString() {
+ return selectorBuffer.toString();
+ }
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/FontFamily.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/style/FontFamily.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/FontFamily.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,69 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.style;
-
-import java.awt.Font;
-import java.awt.GraphicsEnvironment;
-import java.util.Arrays;
-import java.util.StringTokenizer;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class FontFamily {
- public static final String CSS_SANS_SERIF = "SANS-SERIF";
- public static final String JAVA_SANS_SERIF = "SANSSERIF";
- public static final String CSS_MONOSPACED = "MONOSPACE";
- public static final String JAVA_MONOSPACED = "MONOSPACED";
-
- private static final String[] fontFamilies = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
- static{
- for (int i = 0; i < fontFamilies.length; i++) {
- fontFamilies[i] = fontFamilies[i].toUpperCase();
- //System.out.println(fontFamilies[i]);
- }
- Arrays.sort(fontFamilies);
- }
-
- public static Font getFont(String fontFamily, int style, int size){
- String fontUsed = null;
- StringTokenizer tokenizer = new StringTokenizer(fontFamily, ",");
- while(tokenizer.hasMoreElements()){
- String fontName = tokenizer.nextToken().trim().toUpperCase();
- if(fontName.equals(CSS_SANS_SERIF)){
- fontName = JAVA_SANS_SERIF;
- } else if(fontName.equals(CSS_MONOSPACED)){
- fontName = JAVA_MONOSPACED;
- }
-
- if(Arrays.binarySearch(fontFamilies, fontName) >= 0){
- fontUsed = fontName;
- }
- }
- if(fontUsed == null){
- fontUsed = JAVA_SANS_SERIF;
- }
- Font f = new Font(fontUsed, style, size);
- return f;
- }
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/FontFamily.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/style/FontFamily.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/FontFamily.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/style/FontFamily.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,69 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.util.style;
+
+import java.awt.Font;
+import java.awt.GraphicsEnvironment;
+import java.util.Arrays;
+import java.util.StringTokenizer;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class FontFamily {
+ public static final String CSS_SANS_SERIF = "SANS-SERIF";
+ public static final String JAVA_SANS_SERIF = "SANSSERIF";
+ public static final String CSS_MONOSPACED = "MONOSPACE";
+ public static final String JAVA_MONOSPACED = "MONOSPACED";
+
+ private static final String[] fontFamilies = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
+ static{
+ for (int i = 0; i < fontFamilies.length; i++) {
+ fontFamilies[i] = fontFamilies[i].toUpperCase();
+ //System.out.println(fontFamilies[i]);
+ }
+ Arrays.sort(fontFamilies);
+ }
+
+ public static Font getFont(String fontFamily, int style, int size){
+ String fontUsed = null;
+ StringTokenizer tokenizer = new StringTokenizer(fontFamily, ",");
+ while(tokenizer.hasMoreElements()){
+ String fontName = tokenizer.nextToken().trim().toUpperCase();
+ if(fontName.equals(CSS_SANS_SERIF)){
+ fontName = JAVA_SANS_SERIF;
+ } else if(fontName.equals(CSS_MONOSPACED)){
+ fontName = JAVA_MONOSPACED;
+ }
+
+ if(Arrays.binarySearch(fontFamilies, fontName) >= 0){
+ fontUsed = fontName;
+ }
+ }
+ if(fontUsed == null){
+ fontUsed = JAVA_SANS_SERIF;
+ }
+ Font f = new Font(fontUsed, style, size);
+ return f;
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/FilterBean.java (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/config/FilterBean.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/FilterBean.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/FilterBean.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,109 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:58 $
+ *
+ */
+public class FilterBean {
+ private String _filterName;
+ private String _filterClass;
+ private String _displayName;
+ private String _description;
+ private Set _filterMappings = new HashSet();
+ private Set _servlets = new HashSet();
+
+ /**
+ * @return Returns the description.
+ */
+ public String getDescription() {
+ return _description;
+ }
+ /**
+ * @param description The description to set.
+ */
+ public void setDescription(String description) {
+ _description = description;
+ }
+ /**
+ * @return Returns the displayName.
+ */
+ public String getDisplayName() {
+ return _displayName;
+ }
+ /**
+ * @param displayName The displayName to set.
+ */
+ public void setDisplayName(String displayName) {
+ _displayName = displayName;
+ }
+ /**
+ * @return Returns the servletClass.
+ */
+ public String getFilterClass() {
+ return _filterClass;
+ }
+ /**
+ * @param servletClass The servletClass to set.
+ */
+ public void setFilterClass(String servletClass) {
+ _filterClass = servletClass;
+ }
+ /**
+ * @return Returns the servletName.
+ */
+ public String getFilterName() {
+ return _filterName;
+ }
+ /**
+ * @param servletName The servletName to set.
+ */
+ public void setFilterName(String servletName) {
+ _filterName = servletName.trim();
+ }
+ /* (non-Javadoc)
+ * @see java.util.Map#keySet()
+ */
+ public Set getMappings() {
+ return _filterMappings;
+ }
+ /* (non-Javadoc)
+ * @see java.util.Map#put(java.lang.Object, java.lang.Object)
+ */
+ void addMapping(String mapping) {
+ _filterMappings.add(mapping);
+ }
+
+ public void addServlet(String servlet) {
+ _servlets.add(servlet.trim());
+
+ }
+ public Set getServlets() {
+ return _servlets;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ServletBean.java (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/config/ServletBean.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ServletBean.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ServletBean.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,100 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:59 $
+ *
+ */
+public class ServletBean {
+ private String _servletName;
+ private String _servletClass;
+ private String _displayName;
+ private String _description;
+ private Set _servletMappings = new HashSet();
+ /**
+ * @return Returns the description.
+ */
+ public String getDescription() {
+ return _description;
+ }
+ /**
+ * @param description The description to set.
+ */
+ public void setDescription(String description) {
+ _description = description;
+ }
+ /**
+ * @return Returns the displayName.
+ */
+ public String getDisplayName() {
+ return _displayName;
+ }
+ /**
+ * @param displayName The displayName to set.
+ */
+ public void setDisplayName(String displayName) {
+ _displayName = displayName;
+ }
+ /**
+ * @return Returns the servletClass.
+ */
+ public String getServletClass() {
+ return _servletClass;
+ }
+ /**
+ * @param servletClass The servletClass to set.
+ */
+ public void setServletClass(String servletClass) {
+ _servletClass = servletClass;
+ }
+ /**
+ * @return Returns the servletName.
+ */
+ public String getServletName() {
+ return _servletName;
+ }
+ /**
+ * @param servletName The servletName to set.
+ */
+ public void setServletName(String servletName) {
+ _servletName = servletName.trim();
+ }
+ /* (non-Javadoc)
+ * @see java.util.Map#keySet()
+ */
+ public Set getMappings() {
+ return _servletMappings;
+ }
+ /* (non-Javadoc)
+ * @see java.util.Map#put(java.lang.Object, java.lang.Object)
+ */
+ void addMapping(String mapping) {
+ _servletMappings.add(mapping);
+ }
+
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/WebXml.java (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/config/WebXml.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/WebXml.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/WebXml.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,433 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.context.FacesContext;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.digester.Digester;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.LocatorImpl;
+
+/**
+ * Parse at startup application web.xml and store servlet and filter mappings.
+ * at runtime, used for convert resource key to uri, and vice versa.
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:59 $
+ *
+ */
+public class WebXml implements Serializable {
+
+ public static final String CONTEXT_ATTRIBUTE = WebXml.class.getName();
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -9042908418843695017L;
+
+ private static final Log _log = LogFactory.getLog(WebXml.class);
+
+ static final String WEB_XML = "/WEB-INF/web.xml";
+
+
+ public static final String RESOURCE_URI_PREFIX = "a4j.res/";
+
+ static final String RESOURCE_URI_PREFIX_WITH_SLASH = "/"
+ + RESOURCE_URI_PREFIX;
+
+ /**
+ * Prefix for Resourse-Ajax filter, in common must be same as for
+ * {@link javax.faces.webapp.FacesServlet}
+ */
+ private String _facesFilterPrefix = null;
+
+ /**
+ * Suffix for Resource-Ajax filter , in common must be same as for
+ * {@link javax.faces.webapp.FacesServlet}
+ */
+ private String _facesFilterSuffix = null;
+
+ private boolean _prefixMapping = false;
+
+ private String _filterName;
+
+ private Map _servlets = new HashMap();
+
+ private Map _filters = new HashMap();
+
+ /**
+ * Prefix for resources handled by Chameleon framework.
+ */
+ private String _resourcePrefix = RESOURCE_URI_PREFIX_WITH_SLASH;
+
+
+ /**
+ * Parse application web.xml configuration and detect mapping for resources
+ * and logs.
+ * @param context
+ * @param filterName
+ * @throws ServletException
+ */
+ public void init(ServletContext context, String filterName) throws ServletException {
+ InputStream webXml = context.getResourceAsStream(WEB_XML);
+ if (null == webXml) {
+ throw new ServletException(Messages.getMessage(
+ Messages.GET_RESOURCE_AS_STREAM_ERROR, WEB_XML));
+ }
+ Digester dig = new Digester();
+ dig.setDocumentLocator(new LocatorImpl());
+ // Disable xml validations at all - web.xml already validated by
+ // container
+ dig.setValidating(false);
+ dig.setEntityResolver(new EntityResolver() {
+ // Dummi resolver - alvays do nothing
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
+ return new InputSource(new StringReader(""));
+ }
+
+ });
+ dig.setNamespaceAware(false);
+ // dig.setUseContextClassLoader(true);
+ dig.setClassLoader(this.getClass().getClassLoader());
+ // Parsing rules.
+ // Servlets.
+ String path = "web-app/servlet";
+ dig.addObjectCreate(path, ServletBean.class);
+ dig.addBeanPropertySetter(path + "/servlet-name", "servletName");
+ dig.addBeanPropertySetter(path + "/servlet-class", "servletClass");
+ dig.addBeanPropertySetter(path + "/display-name", "displayName");
+ dig.addBeanPropertySetter(path + "/description");
+ dig.addSetNext(path, "addServlet");
+ // Filters
+ path = "web-app/filter";
+ dig.addObjectCreate(path, FilterBean.class);
+ dig.addBeanPropertySetter(path + "/filter-name", "filterName");
+ dig.addBeanPropertySetter(path + "/filter-class", "filterClass");
+ dig.addBeanPropertySetter(path + "/display-name", "displayName");
+ dig.addBeanPropertySetter(path + "/description");
+ dig.addSetNext(path, "addFilter");
+ // Servlet mappings
+ path = "web-app/servlet-mapping";
+ dig.addCallMethod(path, "addServletMapping", 2);
+ dig.addCallParam(path + "/servlet-name", 0);
+ dig.addCallParam(path + "/url-pattern", 1);
+ // Filter mappings
+ // TODO - parse dispatcher.
+ path = "web-app/filter-mapping";
+ dig.addCallMethod(path, "addFilterMapping", 3);
+ dig.addCallParam(path + "/filter-name", 0);
+ dig.addCallParam(path + "/url-pattern", 1);
+ dig.addCallParam(path + "/servlet-name", 2);
+ dig.push(this);
+ try {
+ dig.parse(webXml);
+ this.setFilterName(filterName);
+ // Store Instance to context attribute.
+ context.setAttribute(CONTEXT_ATTRIBUTE,this);
+ } catch (IOException e) {
+ String message = Messages
+ .getMessage(Messages.PARSING_WEB_XML_IO_ERROR);
+ _log.error(message, e);
+ throw new ServletException(message, e);
+ } catch (SAXException e) {
+ String message = Messages
+ .getMessage(Messages.PARSING_WEB_XML_SAX_ERROR);
+ _log.error(message, e);
+ throw new ServletException(message, e);
+ } finally {
+ try {
+ webXml.close();
+ } catch (IOException e) {
+ // this exception don't affect any aspects of work and can be
+ // ignored.
+ }
+ }
+ }
+
+ public void addServlet(ServletBean bean) {
+ String name = bean.getServletName();
+ if (null != name) {
+ _servlets.put(name, bean);
+ }
+ }
+
+ public void addFilter(FilterBean bean) {
+ String name = bean.getFilterName();
+ if (null != name) {
+ _filters.put(name, bean);
+ }
+
+ }
+
+ public void addServletMapping(String servletName, String mapping) {
+ ServletBean servletBean = (ServletBean) _servlets.get(servletName);
+ if (null != servletBean) {
+ (servletBean).addMapping(mapping);
+ }
+ }
+
+ public void addFilterMapping(String filterName, String mapping,
+ String servlet) {
+ FilterBean filterBean = (FilterBean) _filters.get(filterName);
+ if (null != filterBean) {
+ if (null != mapping) {
+ (filterBean).addMapping(mapping);
+ }
+ if (null != servlet) {
+ (filterBean).addServlet(servlet);
+ }
+ }
+ }
+
+ /**
+ * Convert {@link org.ajax4jsf.resource.InternetResource } key to
+ * real URL for handle by chameleon filter, depend of mapping in WEB.XML .
+ * For prefix or * mapping, prepend servlet prefix and default Resource
+ * prefix to key. For suffix mapping, prepend with resource prefix and
+ * append default faces suffix to URL ( before request param ). After
+ * conversion, call
+ * {@link javax.faces.application.ViewHandler#getResourceURL(javax.faces.context.FacesContext, java.lang.String)}
+ * and
+ * {@link javax.faces.context.ExternalContext#encodeResourceURL(java.lang.String)} .
+ *
+ * @param context
+ * @param Url
+ * @return
+ */
+ public String getFacesResourceURL(FacesContext context, String Url) {
+ StringBuffer buf = new StringBuffer();
+ buf.append(getResourcePrefix()).append(Url);
+ // Insert suffix mapping
+ if (isPrefixMapping()) {
+ buf.insert(0, getFacesFilterPrefix());
+ } else {
+ int index;
+ if ((index = buf.indexOf("?")) >= 0) {
+ buf.insert(index, getFacesFilterSuffix());
+ } else {
+ buf.append(getFacesFilterSuffix());
+ }
+ }
+ String resourceURL = context.getApplication().getViewHandler()
+ .getResourceURL(context, buf.toString());
+ return resourceURL;
+
+ }
+
+ /**
+ * Detect request to resource and extract key from request
+ *
+ * @param request
+ * current http request
+ * @return resource key, or null for ordinary faces request.
+ */
+ public String getFacesResourceKey(HttpServletRequest request) {
+ String resourcePath = request.getRequestURI().substring(
+ request.getContextPath().length());// isPrefixMapping()?request.getPathInfo():request.getServletPath();
+ // Remove JSESSIONID - for expired sessions it will merged to path.
+ int jsesionidStart;
+ if ((jsesionidStart = resourcePath.lastIndexOf(";jsessionid")) >= 0) {
+ resourcePath = resourcePath.substring(0, jsesionidStart);
+ }
+ if (isPrefixMapping()) {
+ if (resourcePath.startsWith(getFacesFilterPrefix()
+ + getResourcePrefix())) {
+ return resourcePath.substring(getFacesFilterPrefix().length()
+ + getResourcePrefix().length());
+ }
+ } else if (resourcePath.startsWith(getResourcePrefix())) {
+ return resourcePath.substring(getResourcePrefix().length(),
+ resourcePath.length() - getFacesFilterSuffix().length());
+ }
+ return null;
+ }
+
+ /**
+ * Detect request to {@link javax.faces.webapp.FacesServlet}
+ *
+ * @param request
+ * @return true if request parsed to JSF.
+ */
+ public boolean isFacesRequest(HttpServletRequest request) {
+ // String resourcePath =
+ // request.getRequestURI().substring(request.getContextPath().length());//isPrefixMapping()?request.getPathInfo():request.getServletPath();
+ // if(isPrefixMapping() ) {
+ // if (resourcePath.startsWith(getFacesFilterPrefix())) {
+ // return true;
+ // }
+ // } else if (resourcePath.endsWith(getFacesFilterSuffix())) {
+ // return true;
+ // }
+ // return false;
+ return true;
+ }
+
+ /**
+ * @return Returns the facesFilterPrefix.
+ */
+ public String getFacesFilterPrefix() {
+ return _facesFilterPrefix;
+ }
+
+ /**
+ * @param facesFilterPrefix
+ * The facesFilterPrefix to set.
+ */
+ void setFacesFilterPrefix(String facesFilterPrefix) {
+ _facesFilterPrefix = facesFilterPrefix;
+ }
+
+ /**
+ * @return Returns the facesFilterSuffix.
+ */
+ public String getFacesFilterSuffix() {
+ return _facesFilterSuffix;
+ }
+
+ /**
+ * @param facesFilterSuffix
+ * The facesFilterSuffix to set.
+ */
+ void setFacesFilterSuffix(String facesFilterSuffix) {
+ _facesFilterSuffix = facesFilterSuffix;
+ }
+
+ /**
+ * @return Returns the resourcePrefix.
+ */
+ public String getResourcePrefix() {
+ return _resourcePrefix;
+ }
+
+ /**
+ * @param resourcePrefix
+ * The resourcePrefix to set.
+ */
+ void setResourcePrefix(String resourcePrefix) {
+ _resourcePrefix = resourcePrefix;
+ }
+
+ /**
+ * @return Returns the filterName.
+ */
+ public String getFilterName() {
+ return _filterName;
+ }
+
+ /**
+ * After parsing web.xml set chameleon filter name, for wich we must
+ * calculate mappings for resources, logs etc.
+ *
+ * @param filterName
+ * The filterName to set.
+ */
+ void setFilterName(String filterName) {
+ if (null == filterName) {
+ _log.warn(Messages.getMessage(Messages.NULL_FILTER_NAME_WARNING));
+ return;
+ }
+ _filterName = filterName.trim();
+ // get config for this filter
+ FilterBean filter = (FilterBean) _filters.get(_filterName);
+ if (null == filter) {
+ _log.warn(Messages.getMessage(Messages.FILTER_NOT_FOUND_ERROR,
+ _filterName));
+ throw new IllegalStateException(Messages.getMessage(
+ Messages.FILTER_NOT_FOUND_ERROR, filterName));
+ }
+ // find faces servlet
+ checkMapping(filter.getMappings());
+ // Filter mapped only to servlet.
+ if (_facesFilterPrefix == null && _facesFilterSuffix == null) {
+ for (Iterator sevlets = filter.getServlets().iterator(); sevlets
+ .hasNext()
+ && _facesFilterPrefix == null && _facesFilterSuffix == null;) {
+ String servletname = (String) sevlets.next();
+ ServletBean servlet = (ServletBean) _servlets.get(servletname);
+ if (null != servlet) {
+ checkMapping(servlet.getMappings());
+ }
+ }
+ }
+ if (null != _facesFilterPrefix) {
+ _prefixMapping = true;
+ if (_facesFilterPrefix.endsWith("/")) {
+ setResourcePrefix(RESOURCE_URI_PREFIX);
+ } else {
+ setResourcePrefix(RESOURCE_URI_PREFIX_WITH_SLASH);
+ }
+ } else if (null != _facesFilterSuffix) {
+ _prefixMapping = false;
+ setResourcePrefix(RESOURCE_URI_PREFIX_WITH_SLASH);
+ } else {
+ throw new IllegalStateException(Messages.getMessage(
+ Messages.NO_PREFIX_OR_SUFFIX_IN_FILTER_MAPPING_ERROR,
+ filterName));
+ }
+ }
+
+ private void checkMapping(Set mappings) {
+ if (null != mappings) {
+ for (Iterator iter = mappings.iterator(); iter.hasNext();) {
+ String mapping = (String) iter.next();
+ // first test - for prefix, like /xxx/*
+ // TODO - select correct dispatcher.
+ if (mapping.endsWith("*")) {
+ setFacesFilterPrefix(mapping.substring(0,
+ mapping.length() - 1));
+ break;
+ } else
+ // test for suffix mapping, eg *.xxx
+ if (mapping.startsWith("*")) {
+ setFacesFilterSuffix(mapping.substring(1));
+ } else {
+ // Fixed mapping - do not use it.
+ }
+ }
+ }
+ }
+
+ /**
+ * @return Returns the prefixMapping.
+ */
+ public boolean isPrefixMapping() {
+ return _prefixMapping;
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib (from rev 1587, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib)
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/HtmlComponentTagBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/HtmlComponentTagBase.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/HtmlComponentTagBase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,171 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.taglib;
-
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-
-
-/**
- * Base tag for all components with common Html attributes.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:55 $
- *
- */
-public abstract class HtmlComponentTagBase extends UIComponentTagBase {
- //HTML universal attributes
- private String _dir;
- private String _lang;
- private String _style;
- private String _styleClass;
- private String _title;
-
- //HTML event handler attributes
- private String _onclick;
- private String _ondblclick;
- private String _onkeydown;
- private String _onkeypress;
- private String _onkeyup;
- private String _onmousedown;
- private String _onmousemove;
- private String _onmouseout;
- private String _onmouseover;
- private String _onmouseup;
-
- public void release() {
- super.release();
-
- _dir=null;
- _lang=null;
- _style=null;
- _styleClass=null;
- _title=null;
- _onclick=null;
- _ondblclick=null;
- _onkeydown=null;
- _onkeypress=null;
- _onkeyup=null;
- _onmousedown=null;
- _onmousemove=null;
- _onmouseout=null;
- _onmouseover=null;
- _onmouseup=null;
-
- }
-
- protected void setProperties(UIComponent component)
- {
- super.setProperties(component);
- setStringProperty(component, HTML.dir_ATTRIBUTE, _dir);
- setStringProperty(component, HTML.lang_ATTRIBUTE, _lang);
- setStringProperty(component, HTML.style_ATTRIBUTE, _style);
- setStringProperty(component, HTML.title_ATTRIBUTE, _title);
- setStringProperty(component, HTML.STYLE_CLASS_ATTR, _styleClass);
- setStringProperty(component, HTML.onclick_ATTRIBUTE, _onclick);
- setStringProperty(component, HTML.ondblclick_ATTRIBUTE, _ondblclick);
- setStringProperty(component, HTML.onmousedown_ATTRIBUTE, _onmousedown);
- setStringProperty(component, HTML.onmouseup_ATTRIBUTE, _onmouseup);
- setStringProperty(component, HTML.onmouseover_ATTRIBUTE, _onmouseover);
- setStringProperty(component, HTML.onmousemove_ATTRIBUTE, _onmousemove);
- setStringProperty(component, HTML.onmouseout_ATTRIBUTE, _onmouseout);
- setStringProperty(component, HTML.onkeypress_ATTRIBUTE, _onkeypress);
- setStringProperty(component, HTML.onkeydown_ATTRIBUTE, _onkeydown);
- setStringProperty(component, HTML.onkeyup_ATTRIBUTE, _onkeyup);
- }
-
- public void setStyleClass(String styleClass)
- {
- _styleClass = styleClass;
- }
-
- public void setDir(String dir)
- {
- _dir = dir;
- }
-
- public void setLang(String lang)
- {
- _lang = lang;
- }
-
- public void setStyle(String style)
- {
- _style = style;
- }
-
- public void setTitle(String title)
- {
- _title = title;
- }
-
- public void setOnclick(String onclick)
- {
- _onclick = onclick;
- }
-
- public void setOndblclick(String ondblclick)
- {
- _ondblclick = ondblclick;
- }
-
- public void setOnmousedown(String onmousedown)
- {
- _onmousedown = onmousedown;
- }
-
- public void setOnmouseup(String onmouseup)
- {
- _onmouseup = onmouseup;
- }
-
- public void setOnmouseover(String onmouseover)
- {
- _onmouseover = onmouseover;
- }
-
- public void setOnmousemove(String onmousemove)
- {
- _onmousemove = onmousemove;
- }
-
- public void setOnmouseout(String onmouseout)
- {
- _onmouseout = onmouseout;
- }
-
- public void setOnkeypress(String onkeypress)
- {
- _onkeypress = onkeypress;
- }
-
- public void setOnkeydown(String onkeydown)
- {
- _onkeydown = onkeydown;
- }
-
- public void setOnkeyup(String onkeyup)
- {
- _onkeyup = onkeyup;
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/HtmlComponentTagBase.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/HtmlComponentTagBase.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/HtmlComponentTagBase.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/HtmlComponentTagBase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,171 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp.taglib;
+
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+
+
+/**
+ * Base tag for all components with common Html attributes.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:55 $
+ *
+ */
+public abstract class HtmlComponentTagBase extends UIComponentTagBase {
+ //HTML universal attributes
+ private String _dir;
+ private String _lang;
+ private String _style;
+ private String _styleClass;
+ private String _title;
+
+ //HTML event handler attributes
+ private String _onclick;
+ private String _ondblclick;
+ private String _onkeydown;
+ private String _onkeypress;
+ private String _onkeyup;
+ private String _onmousedown;
+ private String _onmousemove;
+ private String _onmouseout;
+ private String _onmouseover;
+ private String _onmouseup;
+
+ public void release() {
+ super.release();
+
+ _dir=null;
+ _lang=null;
+ _style=null;
+ _styleClass=null;
+ _title=null;
+ _onclick=null;
+ _ondblclick=null;
+ _onkeydown=null;
+ _onkeypress=null;
+ _onkeyup=null;
+ _onmousedown=null;
+ _onmousemove=null;
+ _onmouseout=null;
+ _onmouseover=null;
+ _onmouseup=null;
+
+ }
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setStringProperty(component, HTML.dir_ATTRIBUTE, _dir);
+ setStringProperty(component, HTML.lang_ATTRIBUTE, _lang);
+ setStringProperty(component, HTML.style_ATTRIBUTE, _style);
+ setStringProperty(component, HTML.title_ATTRIBUTE, _title);
+ setStringProperty(component, HTML.STYLE_CLASS_ATTR, _styleClass);
+ setStringProperty(component, HTML.onclick_ATTRIBUTE, _onclick);
+ setStringProperty(component, HTML.ondblclick_ATTRIBUTE, _ondblclick);
+ setStringProperty(component, HTML.onmousedown_ATTRIBUTE, _onmousedown);
+ setStringProperty(component, HTML.onmouseup_ATTRIBUTE, _onmouseup);
+ setStringProperty(component, HTML.onmouseover_ATTRIBUTE, _onmouseover);
+ setStringProperty(component, HTML.onmousemove_ATTRIBUTE, _onmousemove);
+ setStringProperty(component, HTML.onmouseout_ATTRIBUTE, _onmouseout);
+ setStringProperty(component, HTML.onkeypress_ATTRIBUTE, _onkeypress);
+ setStringProperty(component, HTML.onkeydown_ATTRIBUTE, _onkeydown);
+ setStringProperty(component, HTML.onkeyup_ATTRIBUTE, _onkeyup);
+ }
+
+ public void setStyleClass(String styleClass)
+ {
+ _styleClass = styleClass;
+ }
+
+ public void setDir(String dir)
+ {
+ _dir = dir;
+ }
+
+ public void setLang(String lang)
+ {
+ _lang = lang;
+ }
+
+ public void setStyle(String style)
+ {
+ _style = style;
+ }
+
+ public void setTitle(String title)
+ {
+ _title = title;
+ }
+
+ public void setOnclick(String onclick)
+ {
+ _onclick = onclick;
+ }
+
+ public void setOndblclick(String ondblclick)
+ {
+ _ondblclick = ondblclick;
+ }
+
+ public void setOnmousedown(String onmousedown)
+ {
+ _onmousedown = onmousedown;
+ }
+
+ public void setOnmouseup(String onmouseup)
+ {
+ _onmouseup = onmouseup;
+ }
+
+ public void setOnmouseover(String onmouseover)
+ {
+ _onmouseover = onmouseover;
+ }
+
+ public void setOnmousemove(String onmousemove)
+ {
+ _onmousemove = onmousemove;
+ }
+
+ public void setOnmouseout(String onmouseout)
+ {
+ _onmouseout = onmouseout;
+ }
+
+ public void setOnkeypress(String onkeypress)
+ {
+ _onkeypress = onkeypress;
+ }
+
+ public void setOnkeydown(String onkeydown)
+ {
+ _onkeydown = onkeydown;
+ }
+
+ public void setOnkeyup(String onkeyup)
+ {
+ _onkeyup = onkeyup;
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/SimpleActionMethodBinding.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/SimpleActionMethodBinding.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/SimpleActionMethodBinding.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,93 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.taglib;
-
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.MethodNotFoundException;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:56 $
- *
- */
-/**
- * Simple method binding for constant action outcome.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:56 $
- *
- */
-public class SimpleActionMethodBinding extends MethodBinding implements StateHolder {
- // private static final Log log =
- // LogFactory.getLog(SimpleActionMethodBinding.class);
-
- private String _outcome;
-
- public SimpleActionMethodBinding(String outcome) {
- _outcome = outcome;
- }
-
- public Object invoke(FacesContext facescontext, Object aobj[])
- throws EvaluationException, MethodNotFoundException {
- return _outcome;
- }
-
- public Class getType(FacesContext facescontext)
- throws MethodNotFoundException {
- return String.class;
- }
-
- // ~ StateHolder support
- // ----------------------------------------------------------------------------
-
- private boolean _transient = false;
-
- /**
- * Empty constructor, so that new instances can be created when restoring
- * state.
- */
- public SimpleActionMethodBinding() {
- _outcome = null;
- }
-
- public Object saveState(FacesContext facescontext) {
- return _outcome;
- }
-
- public void restoreState(FacesContext facescontext, Object obj) {
- _outcome = (String) obj;
- }
-
- public boolean isTransient() {
- return _transient;
- }
-
- public void setTransient(boolean flag) {
- _transient = flag;
- }
-
- public String toString() {
- return _outcome;
- }
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/SimpleActionMethodBinding.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/SimpleActionMethodBinding.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/SimpleActionMethodBinding.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/SimpleActionMethodBinding.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,93 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp.taglib;
+
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.MethodNotFoundException;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:56 $
+ *
+ */
+/**
+ * Simple method binding for constant action outcome.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:56 $
+ *
+ */
+public class SimpleActionMethodBinding extends MethodBinding implements StateHolder {
+ // private static final Log log =
+ // LogFactory.getLog(SimpleActionMethodBinding.class);
+
+ private String _outcome;
+
+ public SimpleActionMethodBinding(String outcome) {
+ _outcome = outcome;
+ }
+
+ public Object invoke(FacesContext facescontext, Object aobj[])
+ throws EvaluationException, MethodNotFoundException {
+ return _outcome;
+ }
+
+ public Class getType(FacesContext facescontext)
+ throws MethodNotFoundException {
+ return String.class;
+ }
+
+ // ~ StateHolder support
+ // ----------------------------------------------------------------------------
+
+ private boolean _transient = false;
+
+ /**
+ * Empty constructor, so that new instances can be created when restoring
+ * state.
+ */
+ public SimpleActionMethodBinding() {
+ _outcome = null;
+ }
+
+ public Object saveState(FacesContext facescontext) {
+ return _outcome;
+ }
+
+ public void restoreState(FacesContext facescontext, Object obj) {
+ _outcome = (String) obj;
+ }
+
+ public boolean isTransient() {
+ return _transient;
+ }
+
+ public void setTransient(boolean flag) {
+ _transient = flag;
+ }
+
+ public String toString() {
+ return _outcome;
+ }
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentBodyTagBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/UIComponentBodyTagBase.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentBodyTagBase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,382 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.taglib;
-
-import javax.faces.component.ActionSource;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIGraphic;
-import javax.faces.component.UIParameter;
-import javax.faces.component.UISelectBoolean;
-import javax.faces.component.ValueHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.ValueChangeEvent;
-import javax.faces.webapp.UIComponentBodyTag;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base class with utility functions for all JSF tags. Get from apache MyFaces
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:55 $
- *
- */
-public abstract class UIComponentBodyTagBase extends UIComponentBodyTag {
-
- //Special UIComponent attributes (ValueHolder, ConvertibleValueHolder)
- private String _value;
- private String _converter;
- //attributes id, rendered and binding are handled by UIComponentTag
-
- /**
- * @param converter The converter to set.
- */
- public void setConverter(String converter) {
- _converter = converter;
- }
-
- /**
- * @param value The value to set.
- */
- public void setValue(String value) {
- _value = value;
- }
-
- public void release() {
- super.release();
-
- _value=null;
- _converter=null;
- }
-
- protected void setProperties(UIComponent component)
- {
- super.setProperties(component);
-
-
- //rendererType already handled by UIComponentTag
-
- setValueProperty(component, _value);
- setConverterProperty(component, _converter);
- }
-
- // sub class helpers
- private static final Log log = LogFactory.getLog(UIComponentBodyTagBase.class);
-
- private static final Class[] VALIDATOR_ARGS = {FacesContext.class,
- UIComponent.class,
- Object.class};
- private static final Class[] ACTION_LISTENER_ARGS = {ActionEvent.class};
- private static final Class[] VALUE_LISTENER_ARGS = {ValueChangeEvent.class};
-
- protected void setCharterProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //FIXME: should use converter maybe?
- component.getAttributes().put(propName, new Character(value.charAt(0)));
- }
- }
- }
- protected void setIntegerProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //FIXME: should use converter maybe?
- component.getAttributes().put(propName, Integer.valueOf(value));
- }
- }
- }
-
- protected void setLongProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //FIXME: should use converter maybe?
- component.getAttributes().put(propName, Long.valueOf(value));
- }
- }
- }
-
- protected void setFloatProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //FIXME: should use converter maybe?
- component.getAttributes().put(propName, Float.valueOf(value));
- }
- }
- }
- protected void setDoubleProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //FIXME: should use converter maybe?
- component.getAttributes().put(propName, Double.valueOf(value));
- }
- }
- }
-
- protected void setStringProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //TODO: Warning if component has no such property (with reflection)
- component.getAttributes().put(propName, value);
- }
- }
- }
-
- protected void setBooleanProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //TODO: More sophisticated way to convert boolean value (yes/no, 1/0, on/off, etc.)
- component.getAttributes().put(propName, Boolean.valueOf(value));
- }
- }
- }
-
- protected void setValueProperty(UIComponent component, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding("value", vb);
- }
- else if (component instanceof UICommand)
- {
- ((UICommand)component).setValue(value);
- }
- else if (component instanceof UIParameter)
- {
- ((UIParameter)component).setValue(value);
- }
- else if (component instanceof UISelectBoolean)
- {
- ((UISelectBoolean)component).setValue(Boolean.valueOf(value));
- }
- else if (component instanceof UIGraphic)
- {
- ((UIGraphic)component).setValue(value);
- }
- //Since many input components are ValueHolders the special components
- //must come first, ValueHolder is the last resort.
- else if (component instanceof ValueHolder)
- {
- ((ValueHolder)component).setValue(value);
- }
- else
- {
- log.error(Messages.getMessage(Messages.NO_VALUE_HOLDER_ERROR, component.getClass().getName()));
- }
- }
- }
-
- protected void setConverterProperty(UIComponent component, String value)
- {
- if (value != null)
- {
- if (component instanceof ValueHolder)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding("converter", vb);
- }
- else
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- Converter converter = facesContext.getApplication().createConverter(value);
- ((ValueHolder)component).setConverter(converter);
- }
- }
- else
- {
- log.error(Messages.getMessage(Messages.NO_VALUE_HOLDER_ERROR, component.getClass().getName()));
- }
- }
- }
-
- protected void setValidatorProperty(UIComponent component, String validator)
- {
- if (validator != null)
- {
- if (!(component instanceof EditableValueHolder))
- {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_EDITABLE_VALUE_HOLDER_ERROR, component.getId()));
- }
- if (isValueReference(validator))
- {
- MethodBinding mb = getFacesContext().getApplication().createMethodBinding(validator,
- VALIDATOR_ARGS);
- ((EditableValueHolder)component).setValidator(mb);
- }
- else
- {
- log.error(Messages.getMessage(Messages.INVALID_VALIDATION_EXPRESSION, component.getId(), validator));
- }
- }
- }
-
- protected void setActionProperty(UIComponent component, String action)
- {
- if (action != null)
- {
- if (!(component instanceof ActionSource))
- {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_ACTION_SOURCE_ERROR, component.getClientId(getFacesContext())));
- }
- MethodBinding mb;
- if (isValueReference(action))
- {
- mb = getFacesContext().getApplication().createMethodBinding(action, null);
- }
- else
- {
- mb = new SimpleActionMethodBinding(action);
- }
- ((ActionSource)component).setAction(mb);
- }
- }
-
- protected void setActionListenerProperty(UIComponent component, String actionListener)
- {
- if (actionListener != null)
- {
- if (!(component instanceof ActionSource))
- {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_ACTION_SOURCE_ERROR, component.getClientId(getFacesContext())));
- }
- if (isValueReference(actionListener))
- {
- MethodBinding mb = getFacesContext().getApplication().createMethodBinding(actionListener,
- ACTION_LISTENER_ARGS);
- ((ActionSource)component).setActionListener(mb);
- }
- else
- {
- log.error(Messages.getMessage(Messages.INVALID_ACTION_LISTENER, component.getClientId(getFacesContext()), actionListener));
- }
- }
- }
-
- protected void setValueChangedListenerProperty(UIComponent component, String valueChangedListener)
- {
- if (valueChangedListener != null)
- {
- if (!(component instanceof EditableValueHolder))
- {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_EDITABLE_VALUE_HOLDER_ERROR, component.getClientId(getFacesContext())));
- }
- if (isValueReference(valueChangedListener))
- {
- MethodBinding mb = getFacesContext().getApplication().createMethodBinding(valueChangedListener,
- VALUE_LISTENER_ARGS);
- ((EditableValueHolder)component).setValueChangeListener(mb);
- }
- else
- {
- log.error(Messages.getMessage(Messages.INVALID_VALUE_CHANGE_LISTENER, component.getClientId(getFacesContext()), valueChangedListener));
- }
- }
- }
-
- protected void setValueBinding(UIComponent component,
- String propName,
- String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_VALUE_REFERENCE_ERROR, new Object[]{component.getId(), propName, value}));
- }
- }
- }
-
-
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentBodyTagBase.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/UIComponentBodyTagBase.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentBodyTagBase.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentBodyTagBase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,382 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp.taglib;
+
+import javax.faces.component.ActionSource;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIGraphic;
+import javax.faces.component.UIParameter;
+import javax.faces.component.UISelectBoolean;
+import javax.faces.component.ValueHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.webapp.UIComponentBodyTag;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base class with utility functions for all JSF tags. Get from apache MyFaces
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:55 $
+ *
+ */
+public abstract class UIComponentBodyTagBase extends UIComponentBodyTag {
+
+ //Special UIComponent attributes (ValueHolder, ConvertibleValueHolder)
+ private String _value;
+ private String _converter;
+ //attributes id, rendered and binding are handled by UIComponentTag
+
+ /**
+ * @param converter The converter to set.
+ */
+ public void setConverter(String converter) {
+ _converter = converter;
+ }
+
+ /**
+ * @param value The value to set.
+ */
+ public void setValue(String value) {
+ _value = value;
+ }
+
+ public void release() {
+ super.release();
+
+ _value=null;
+ _converter=null;
+ }
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+
+
+ //rendererType already handled by UIComponentTag
+
+ setValueProperty(component, _value);
+ setConverterProperty(component, _converter);
+ }
+
+ // sub class helpers
+ private static final Log log = LogFactory.getLog(UIComponentBodyTagBase.class);
+
+ private static final Class[] VALIDATOR_ARGS = {FacesContext.class,
+ UIComponent.class,
+ Object.class};
+ private static final Class[] ACTION_LISTENER_ARGS = {ActionEvent.class};
+ private static final Class[] VALUE_LISTENER_ARGS = {ValueChangeEvent.class};
+
+ protected void setCharterProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //FIXME: should use converter maybe?
+ component.getAttributes().put(propName, new Character(value.charAt(0)));
+ }
+ }
+ }
+ protected void setIntegerProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //FIXME: should use converter maybe?
+ component.getAttributes().put(propName, Integer.valueOf(value));
+ }
+ }
+ }
+
+ protected void setLongProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //FIXME: should use converter maybe?
+ component.getAttributes().put(propName, Long.valueOf(value));
+ }
+ }
+ }
+
+ protected void setFloatProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //FIXME: should use converter maybe?
+ component.getAttributes().put(propName, Float.valueOf(value));
+ }
+ }
+ }
+ protected void setDoubleProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //FIXME: should use converter maybe?
+ component.getAttributes().put(propName, Double.valueOf(value));
+ }
+ }
+ }
+
+ protected void setStringProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //TODO: Warning if component has no such property (with reflection)
+ component.getAttributes().put(propName, value);
+ }
+ }
+ }
+
+ protected void setBooleanProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //TODO: More sophisticated way to convert boolean value (yes/no, 1/0, on/off, etc.)
+ component.getAttributes().put(propName, Boolean.valueOf(value));
+ }
+ }
+ }
+
+ protected void setValueProperty(UIComponent component, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding("value", vb);
+ }
+ else if (component instanceof UICommand)
+ {
+ ((UICommand)component).setValue(value);
+ }
+ else if (component instanceof UIParameter)
+ {
+ ((UIParameter)component).setValue(value);
+ }
+ else if (component instanceof UISelectBoolean)
+ {
+ ((UISelectBoolean)component).setValue(Boolean.valueOf(value));
+ }
+ else if (component instanceof UIGraphic)
+ {
+ ((UIGraphic)component).setValue(value);
+ }
+ //Since many input components are ValueHolders the special components
+ //must come first, ValueHolder is the last resort.
+ else if (component instanceof ValueHolder)
+ {
+ ((ValueHolder)component).setValue(value);
+ }
+ else
+ {
+ log.error(Messages.getMessage(Messages.NO_VALUE_HOLDER_ERROR, component.getClass().getName()));
+ }
+ }
+ }
+
+ protected void setConverterProperty(UIComponent component, String value)
+ {
+ if (value != null)
+ {
+ if (component instanceof ValueHolder)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding("converter", vb);
+ }
+ else
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Converter converter = facesContext.getApplication().createConverter(value);
+ ((ValueHolder)component).setConverter(converter);
+ }
+ }
+ else
+ {
+ log.error(Messages.getMessage(Messages.NO_VALUE_HOLDER_ERROR, component.getClass().getName()));
+ }
+ }
+ }
+
+ protected void setValidatorProperty(UIComponent component, String validator)
+ {
+ if (validator != null)
+ {
+ if (!(component instanceof EditableValueHolder))
+ {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.NO_EDITABLE_VALUE_HOLDER_ERROR, component.getId()));
+ }
+ if (isValueReference(validator))
+ {
+ MethodBinding mb = getFacesContext().getApplication().createMethodBinding(validator,
+ VALIDATOR_ARGS);
+ ((EditableValueHolder)component).setValidator(mb);
+ }
+ else
+ {
+ log.error(Messages.getMessage(Messages.INVALID_VALIDATION_EXPRESSION, component.getId(), validator));
+ }
+ }
+ }
+
+ protected void setActionProperty(UIComponent component, String action)
+ {
+ if (action != null)
+ {
+ if (!(component instanceof ActionSource))
+ {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.NO_ACTION_SOURCE_ERROR, component.getClientId(getFacesContext())));
+ }
+ MethodBinding mb;
+ if (isValueReference(action))
+ {
+ mb = getFacesContext().getApplication().createMethodBinding(action, null);
+ }
+ else
+ {
+ mb = new SimpleActionMethodBinding(action);
+ }
+ ((ActionSource)component).setAction(mb);
+ }
+ }
+
+ protected void setActionListenerProperty(UIComponent component, String actionListener)
+ {
+ if (actionListener != null)
+ {
+ if (!(component instanceof ActionSource))
+ {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.NO_ACTION_SOURCE_ERROR, component.getClientId(getFacesContext())));
+ }
+ if (isValueReference(actionListener))
+ {
+ MethodBinding mb = getFacesContext().getApplication().createMethodBinding(actionListener,
+ ACTION_LISTENER_ARGS);
+ ((ActionSource)component).setActionListener(mb);
+ }
+ else
+ {
+ log.error(Messages.getMessage(Messages.INVALID_ACTION_LISTENER, component.getClientId(getFacesContext()), actionListener));
+ }
+ }
+ }
+
+ protected void setValueChangedListenerProperty(UIComponent component, String valueChangedListener)
+ {
+ if (valueChangedListener != null)
+ {
+ if (!(component instanceof EditableValueHolder))
+ {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.NO_EDITABLE_VALUE_HOLDER_ERROR, component.getClientId(getFacesContext())));
+ }
+ if (isValueReference(valueChangedListener))
+ {
+ MethodBinding mb = getFacesContext().getApplication().createMethodBinding(valueChangedListener,
+ VALUE_LISTENER_ARGS);
+ ((EditableValueHolder)component).setValueChangeListener(mb);
+ }
+ else
+ {
+ log.error(Messages.getMessage(Messages.INVALID_VALUE_CHANGE_LISTENER, component.getClientId(getFacesContext()), valueChangedListener));
+ }
+ }
+ }
+
+ protected void setValueBinding(UIComponent component,
+ String propName,
+ String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.NO_VALUE_REFERENCE_ERROR, new Object[]{component.getId(), propName, value}));
+ }
+ }
+ }
+
+
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentTagBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/UIComponentTagBase.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentTagBase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,383 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.taglib;
-
-import javax.faces.component.ActionSource;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIGraphic;
-import javax.faces.component.UIParameter;
-import javax.faces.component.UISelectBoolean;
-import javax.faces.component.ValueHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.ValueChangeEvent;
-import javax.faces.webapp.UIComponentTag;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base class with utility functions for all JSF tags. Get from apache MyFaces
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:55 $
- *
- */
-public abstract class UIComponentTagBase extends UIComponentTag {
-
- //Special UIComponent attributes (ValueHolder, ConvertibleValueHolder)
- private String _value;
- private String _converter;
- //attributes id, rendered and binding are handled by UIComponentTag
-
- /**
- * @param converter The converter to set.
- */
- public void setConverter(String converter) {
- _converter = converter;
- }
-
- /**
- * @param value The value to set.
- */
- public void setValue(String value) {
- _value = value;
- }
-
- public void release() {
- super.release();
-
- _value=null;
- _converter=null;
- }
-
- protected void setProperties(UIComponent component)
- {
- super.setProperties(component);
-
-
- //rendererType already handled by UIComponentTag
-
- setValueProperty(component, _value);
- setConverterProperty(component, _converter);
- }
-
- // sub class helpers
- private static final Log log = LogFactory.getLog(UIComponentTagBase.class);
-
- private static final Class[] VALIDATOR_ARGS = {FacesContext.class,
- UIComponent.class,
- Object.class};
- private static final Class[] ACTION_LISTENER_ARGS = {ActionEvent.class};
- private static final Class[] VALUE_LISTENER_ARGS = {ValueChangeEvent.class};
-
- protected void setCharterProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //FIXME: should use converter maybe?
- component.getAttributes().put(propName, new Character(value.charAt(0)));
- }
- }
- }
- protected void setIntegerProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //FIXME: should use converter maybe?
- component.getAttributes().put(propName, Integer.valueOf(value));
- }
- }
- }
-
- protected void setLongProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //FIXME: should use converter maybe?
- component.getAttributes().put(propName, Long.valueOf(value));
- }
- }
- }
-
- protected void setFloatProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //FIXME: should use converter maybe?
- component.getAttributes().put(propName, Float.valueOf(value));
- }
- }
- }
- protected void setDoubleProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //FIXME: should use converter maybe?
- component.getAttributes().put(propName, Double.valueOf(value));
- }
- }
- }
-
- protected void setStringProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //TODO: Warning if component has no such property (with reflection)
- component.getAttributes().put(propName, value);
- }
- }
- }
-
- protected void setBooleanProperty(UIComponent component, String propName, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- //TODO: More sophisticated way to convert boolean value (yes/no, 1/0, on/off, etc.)
- component.getAttributes().put(propName, Boolean.valueOf(value));
- }
- }
- }
-
- protected void setValueProperty(UIComponent component, String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding("value", vb);
- }
- else if (component instanceof UICommand)
- {
- ((UICommand)component).setValue(value);
- }
- else if (component instanceof UIParameter)
- {
- ((UIParameter)component).setValue(value);
- }
- else if (component instanceof UISelectBoolean)
- {
- ((UISelectBoolean)component).setValue(Boolean.valueOf(value));
- }
- else if (component instanceof UIGraphic)
- {
- ((UIGraphic)component).setValue(value);
- }
- //Since many input components are ValueHolders the special components
- //must come first, ValueHolder is the last resort.
- else if (component instanceof ValueHolder)
- {
- ((ValueHolder)component).setValue(value);
- }
- else
- {
- component.getAttributes().put("value", value);
- }
- }
- }
-
- protected void setConverterProperty(UIComponent component, String value)
- {
- if (value != null)
- {
- if (component instanceof ValueHolder)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding("converter", vb);
- }
- else
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- Converter converter = facesContext.getApplication().createConverter(value);
- ((ValueHolder)component).setConverter(converter);
- }
- }
- else
- {
- log.error(Messages.getMessage(Messages.NO_VALUE_HOLDER_ERROR, component.getClass().getName()));
- }
- }
- }
-
- protected void setValidatorProperty(UIComponent component, String validator)
- {
- if (validator != null)
- {
- if (!(component instanceof EditableValueHolder))
- {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_EDITABLE_VALUE_HOLDER_ERROR, component.getId()));
- }
- if (isValueReference(validator))
- {
- MethodBinding mb = getFacesContext().getApplication().createMethodBinding(validator,
- VALIDATOR_ARGS);
- ((EditableValueHolder)component).setValidator(mb);
- }
- else
- {
- log.error(Messages.getMessage(Messages.INVALID_VALIDATION_EXPRESSION, component.getId(), validator));
- }
- }
- }
-
- protected void setActionProperty(UIComponent component, String action)
- {
- if (action != null)
- {
- if (!(component instanceof ActionSource))
- {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_ACTION_SOURCE_ERROR, component.getClientId(getFacesContext())));
- }
- MethodBinding mb;
- if (isValueReference(action))
- {
- mb = getFacesContext().getApplication().createMethodBinding(action, null);
- }
- else
- {
- mb = new SimpleActionMethodBinding(action);
- }
- ((ActionSource)component).setAction(mb);
- }
- }
-
- protected void setActionListenerProperty(UIComponent component, String actionListener)
- {
- if (actionListener != null)
- {
- if (!(component instanceof ActionSource))
- {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_ACTION_SOURCE_ERROR, component.getClientId(getFacesContext())));
- }
- if (isValueReference(actionListener))
- {
- MethodBinding mb = getFacesContext().getApplication().createMethodBinding(actionListener,
- ACTION_LISTENER_ARGS);
- ((ActionSource)component).setActionListener(mb);
- }
- else
- {
- log.error(Messages.getMessage(Messages.INVALID_ACTION_LISTENER, component.getClientId(getFacesContext()), actionListener));
- }
- }
- }
-
- protected void setValueChangedListenerProperty(UIComponent component, String valueChangedListener)
- {
- if (valueChangedListener != null)
- {
- if (!(component instanceof EditableValueHolder))
- {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_EDITABLE_VALUE_HOLDER_ERROR, component.getClientId(getFacesContext())));
- }
- if (isValueReference(valueChangedListener))
- {
- MethodBinding mb = getFacesContext().getApplication().createMethodBinding(valueChangedListener,
- VALUE_LISTENER_ARGS);
- ((EditableValueHolder)component).setValueChangeListener(mb);
- }
- else
- {
- log.error(Messages.getMessage(Messages.INVALID_VALUE_CHANGE_LISTENER, component.getClientId(getFacesContext()), valueChangedListener));
- }
- }
- }
-
- protected void setValueBinding(UIComponent component,
- String propName,
- String value)
- {
- if (value != null)
- {
- if (isValueReference(value))
- {
- ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
- component.setValueBinding(propName, vb);
- }
- else
- {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_VALUE_REFERENCE_ERROR, new Object[]{component.getId(), propName, value}));
- }
- }
- }
-
-
-
-}
-
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentTagBase.java (from rev 1588, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/UIComponentTagBase.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentTagBase.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/UIComponentTagBase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,383 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp.taglib;
+
+import javax.faces.component.ActionSource;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIGraphic;
+import javax.faces.component.UIParameter;
+import javax.faces.component.UISelectBoolean;
+import javax.faces.component.ValueHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.webapp.UIComponentTag;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base class with utility functions for all JSF tags. Get from apache MyFaces
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:55 $
+ *
+ */
+public abstract class UIComponentTagBase extends UIComponentTag {
+
+ //Special UIComponent attributes (ValueHolder, ConvertibleValueHolder)
+ private String _value;
+ private String _converter;
+ //attributes id, rendered and binding are handled by UIComponentTag
+
+ /**
+ * @param converter The converter to set.
+ */
+ public void setConverter(String converter) {
+ _converter = converter;
+ }
+
+ /**
+ * @param value The value to set.
+ */
+ public void setValue(String value) {
+ _value = value;
+ }
+
+ public void release() {
+ super.release();
+
+ _value=null;
+ _converter=null;
+ }
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+
+
+ //rendererType already handled by UIComponentTag
+
+ setValueProperty(component, _value);
+ setConverterProperty(component, _converter);
+ }
+
+ // sub class helpers
+ private static final Log log = LogFactory.getLog(UIComponentTagBase.class);
+
+ private static final Class[] VALIDATOR_ARGS = {FacesContext.class,
+ UIComponent.class,
+ Object.class};
+ private static final Class[] ACTION_LISTENER_ARGS = {ActionEvent.class};
+ private static final Class[] VALUE_LISTENER_ARGS = {ValueChangeEvent.class};
+
+ protected void setCharterProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //FIXME: should use converter maybe?
+ component.getAttributes().put(propName, new Character(value.charAt(0)));
+ }
+ }
+ }
+ protected void setIntegerProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //FIXME: should use converter maybe?
+ component.getAttributes().put(propName, Integer.valueOf(value));
+ }
+ }
+ }
+
+ protected void setLongProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //FIXME: should use converter maybe?
+ component.getAttributes().put(propName, Long.valueOf(value));
+ }
+ }
+ }
+
+ protected void setFloatProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //FIXME: should use converter maybe?
+ component.getAttributes().put(propName, Float.valueOf(value));
+ }
+ }
+ }
+ protected void setDoubleProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //FIXME: should use converter maybe?
+ component.getAttributes().put(propName, Double.valueOf(value));
+ }
+ }
+ }
+
+ protected void setStringProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //TODO: Warning if component has no such property (with reflection)
+ component.getAttributes().put(propName, value);
+ }
+ }
+ }
+
+ protected void setBooleanProperty(UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //TODO: More sophisticated way to convert boolean value (yes/no, 1/0, on/off, etc.)
+ component.getAttributes().put(propName, Boolean.valueOf(value));
+ }
+ }
+ }
+
+ protected void setValueProperty(UIComponent component, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding("value", vb);
+ }
+ else if (component instanceof UICommand)
+ {
+ ((UICommand)component).setValue(value);
+ }
+ else if (component instanceof UIParameter)
+ {
+ ((UIParameter)component).setValue(value);
+ }
+ else if (component instanceof UISelectBoolean)
+ {
+ ((UISelectBoolean)component).setValue(Boolean.valueOf(value));
+ }
+ else if (component instanceof UIGraphic)
+ {
+ ((UIGraphic)component).setValue(value);
+ }
+ //Since many input components are ValueHolders the special components
+ //must come first, ValueHolder is the last resort.
+ else if (component instanceof ValueHolder)
+ {
+ ((ValueHolder)component).setValue(value);
+ }
+ else
+ {
+ component.getAttributes().put("value", value);
+ }
+ }
+ }
+
+ protected void setConverterProperty(UIComponent component, String value)
+ {
+ if (value != null)
+ {
+ if (component instanceof ValueHolder)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding("converter", vb);
+ }
+ else
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Converter converter = facesContext.getApplication().createConverter(value);
+ ((ValueHolder)component).setConverter(converter);
+ }
+ }
+ else
+ {
+ log.error(Messages.getMessage(Messages.NO_VALUE_HOLDER_ERROR, component.getClass().getName()));
+ }
+ }
+ }
+
+ protected void setValidatorProperty(UIComponent component, String validator)
+ {
+ if (validator != null)
+ {
+ if (!(component instanceof EditableValueHolder))
+ {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.NO_EDITABLE_VALUE_HOLDER_ERROR, component.getId()));
+ }
+ if (isValueReference(validator))
+ {
+ MethodBinding mb = getFacesContext().getApplication().createMethodBinding(validator,
+ VALIDATOR_ARGS);
+ ((EditableValueHolder)component).setValidator(mb);
+ }
+ else
+ {
+ log.error(Messages.getMessage(Messages.INVALID_VALIDATION_EXPRESSION, component.getId(), validator));
+ }
+ }
+ }
+
+ protected void setActionProperty(UIComponent component, String action)
+ {
+ if (action != null)
+ {
+ if (!(component instanceof ActionSource))
+ {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.NO_ACTION_SOURCE_ERROR, component.getClientId(getFacesContext())));
+ }
+ MethodBinding mb;
+ if (isValueReference(action))
+ {
+ mb = getFacesContext().getApplication().createMethodBinding(action, null);
+ }
+ else
+ {
+ mb = new SimpleActionMethodBinding(action);
+ }
+ ((ActionSource)component).setAction(mb);
+ }
+ }
+
+ protected void setActionListenerProperty(UIComponent component, String actionListener)
+ {
+ if (actionListener != null)
+ {
+ if (!(component instanceof ActionSource))
+ {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.NO_ACTION_SOURCE_ERROR, component.getClientId(getFacesContext())));
+ }
+ if (isValueReference(actionListener))
+ {
+ MethodBinding mb = getFacesContext().getApplication().createMethodBinding(actionListener,
+ ACTION_LISTENER_ARGS);
+ ((ActionSource)component).setActionListener(mb);
+ }
+ else
+ {
+ log.error(Messages.getMessage(Messages.INVALID_ACTION_LISTENER, component.getClientId(getFacesContext()), actionListener));
+ }
+ }
+ }
+
+ protected void setValueChangedListenerProperty(UIComponent component, String valueChangedListener)
+ {
+ if (valueChangedListener != null)
+ {
+ if (!(component instanceof EditableValueHolder))
+ {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.NO_EDITABLE_VALUE_HOLDER_ERROR, component.getClientId(getFacesContext())));
+ }
+ if (isValueReference(valueChangedListener))
+ {
+ MethodBinding mb = getFacesContext().getApplication().createMethodBinding(valueChangedListener,
+ VALUE_LISTENER_ARGS);
+ ((EditableValueHolder)component).setValueChangeListener(mb);
+ }
+ else
+ {
+ log.error(Messages.getMessage(Messages.INVALID_VALUE_CHANGE_LISTENER, component.getClientId(getFacesContext()), valueChangedListener));
+ }
+ }
+ }
+
+ protected void setValueBinding(UIComponent component,
+ String propName,
+ String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = getFacesContext().getApplication().createValueBinding(value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.NO_VALUE_REFERENCE_ERROR, new Object[]{component.getId(), propName, value}));
+ }
+ }
+ }
+
+
+
+}
+
Modified: trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -21,7 +21,7 @@
package org.richfaces.component.util;
-import org.ajax4jsf.framework.util.HtmlDimensions;
+import org.ajax4jsf.util.HtmlDimensions;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -29,8 +29,8 @@
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
-import org.ajax4jsf.framework.util.SelectUtils;
import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
+import org.ajax4jsf.util.SelectUtils;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -32,11 +32,11 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.util.HtmlColor;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowImage.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowImage.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowImage.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -23,7 +23,7 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.util.HtmlColor;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -46,12 +46,12 @@
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.context.AjaxContextImpl;
-import org.ajax4jsf.framework.util.config.WebXml;
import org.ajax4jsf.renderkit.AjaxViewRootRenderer;
import org.ajax4jsf.renderkit.ChameleonRenderKitImpl;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.tests.org.apache.shale.test.config.ConfigParser;
+import org.ajax4jsf.webapp.WebXml;
import org.apache.shale.test.base.AbstractJsfTestCase;
import org.apache.shale.test.mock.MockPrintWriter;
import org.apache.shale.test.mock.MockResponseWriter;
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/codec/CodecTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/codec/CodecTest.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/codec/CodecTest.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -23,8 +23,8 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.util.base64.Codec;
import org.ajax4jsf.tests.AbstractThreadedAjax4JsfTestCase;
+import org.ajax4jsf.util.base64.Codec;
public class CodecTest extends AbstractThreadedAjax4JsfTestCase {
Codec c;
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -24,9 +24,9 @@
import java.io.IOException;
import java.io.InputStream;
-import org.ajax4jsf.framework.util.config.WebXml;
import org.ajax4jsf.renderkit.compiler.TemplateContext;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.ajax4jsf.webapp.WebXml;
import org.apache.shale.test.mock.MockPrintWriter;
/**
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/util/config (from rev 1587, trunk/framework/test/src/test/java/org/ajax4jsf/framework/util/config)
Deleted: trunk/framework/test/src/test/java/org/ajax4jsf/util/config/AllTests.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/util/config/AllTests.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/util/config/AllTests.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,38 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.config;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for org.ajax4jsf.framework.util.config");
- //$JUnit-BEGIN$
- suite.addTestSuite(WebXmlTest.class);
- //$JUnit-END$
- return suite;
- }
-
-}
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/util/config/AllTests.java (from rev 1588, trunk/framework/test/src/test/java/org/ajax4jsf/framework/util/config/AllTests.java)
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/util/config/AllTests.java (rev 0)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/util/config/AllTests.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,38 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.util.config;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.ajax4jsf.util.config");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(WebXmlTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
Deleted: trunk/framework/test/src/test/java/org/ajax4jsf/util/config/WebXmlTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/util/config/WebXmlTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/util/config/WebXmlTest.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -1,120 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.config;
-
-import java.io.InputStream;
-
-import javax.servlet.ServletException;
-
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.apache.shale.test.mock.MockServletContext;
-
-public class WebXmlTest extends AbstractAjax4JsfTestCase {
-
- MockServletContext context;
-
- public WebXmlTest(String arg0) {
- super(arg0);
- }
-
- public void setUp() throws Exception {
- super.setUp();
- context = new MockServletContext(){
-
- /* (non-Javadoc)
- * @see org.apache.shale.test.mock.MockServletContext#getResourceAsStream(java.lang.String)
- */
- public InputStream getResourceAsStream(String uri) {
- if(uri.equals(WebXml.WEB_XML)){
- return this.getClass().getResourceAsStream("/WEB-INF/complex-web.xml");
- } else {
- return super.getResourceAsStream(uri);
- }
- }
-
- };
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- /*
- * Test method for 'org.ajax4jsf.framework.util.config.WebXml.reset()'
- */
- public void testReset() {
-
- }
-
- /*
- * Test method for 'org.ajax4jsf.framework.util.config.WebXml.init(ServletContext, String)'
- */
- public void testInit() throws ServletException {
- WebXml webXml = new WebXml();
- webXml.init(context,"ajax4jsf");
- assertFalse(webXml.isPrefixMapping());
- assertNull(webXml.getFacesFilterPrefix());
- assertNotNull(webXml.getFacesFilterSuffix());
- assertEquals(".jsf",webXml.getFacesFilterSuffix());
- }
-
- /*
- * Test method for 'org.ajax4jsf.framework.util.config.WebXml.getInstance()'
- */
- public void testGetInstance() {
-
- }
-
- /*
- * Test method for 'org.ajax4jsf.framework.util.config.WebXml.getFacesResourceURL(FacesContext, String)'
- */
- public void testGetFacesResourceURL() throws ServletException {
- WebXml webXml = new WebXml();
- webXml.init(context,"ajax4jsf");
- String resourceURL = webXml.getFacesResourceURL(facesContext,"foo.Bar");
- System.out.println(resourceURL);
- assertEquals("/testContext/"+WebXml.RESOURCE_URI_PREFIX+"foo.Bar.jsf",resourceURL);
-
- }
-
- /*
- * Test method for 'org.ajax4jsf.framework.util.config.WebXml.getFacesResourceKey(HttpServletRequest)'
- */
- public void testGetFacesResourceKey() {
-
- }
-
- /*
- * Test method for 'org.ajax4jsf.framework.util.config.WebXml.isFacesRequest(HttpServletRequest)'
- */
- public void testIsFacesRequest() {
-
- }
-
- /*
- * Test method for 'org.ajax4jsf.framework.util.config.WebXml.setFilterName(String)'
- */
- public void testSetFilterName() {
-
- }
-
-}
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/util/config/WebXmlTest.java (from rev 1588, trunk/framework/test/src/test/java/org/ajax4jsf/framework/util/config/WebXmlTest.java)
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/util/config/WebXmlTest.java (rev 0)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/util/config/WebXmlTest.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -0,0 +1,121 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.util.config;
+
+import java.io.InputStream;
+
+import javax.servlet.ServletException;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.ajax4jsf.webapp.WebXml;
+import org.apache.shale.test.mock.MockServletContext;
+
+public class WebXmlTest extends AbstractAjax4JsfTestCase {
+
+ MockServletContext context;
+
+ public WebXmlTest(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ context = new MockServletContext(){
+
+ /* (non-Javadoc)
+ * @see org.apache.shale.test.mock.MockServletContext#getResourceAsStream(java.lang.String)
+ */
+ public InputStream getResourceAsStream(String uri) {
+ if(uri.equals(WebXml.WEB_XML)){
+ return this.getClass().getResourceAsStream("/WEB-INF/complex-web.xml");
+ } else {
+ return super.getResourceAsStream(uri);
+ }
+ }
+
+ };
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * Test method for 'org.ajax4jsf.util.config.WebXml.reset()'
+ */
+ public void testReset() {
+
+ }
+
+ /*
+ * Test method for 'org.ajax4jsf.util.config.WebXml.init(ServletContext, String)'
+ */
+ public void testInit() throws ServletException {
+ WebXml webXml = new WebXml();
+ webXml.init(context,"ajax4jsf");
+ assertFalse(webXml.isPrefixMapping());
+ assertNull(webXml.getFacesFilterPrefix());
+ assertNotNull(webXml.getFacesFilterSuffix());
+ assertEquals(".jsf",webXml.getFacesFilterSuffix());
+ }
+
+ /*
+ * Test method for 'org.ajax4jsf.util.config.WebXml.getInstance()'
+ */
+ public void testGetInstance() {
+
+ }
+
+ /*
+ * Test method for 'org.ajax4jsf.util.config.WebXml.getFacesResourceURL(FacesContext, String)'
+ */
+ public void testGetFacesResourceURL() throws ServletException {
+ WebXml webXml = new WebXml();
+ webXml.init(context,"ajax4jsf");
+ String resourceURL = webXml.getFacesResourceURL(facesContext,"foo.Bar");
+ System.out.println(resourceURL);
+ assertEquals("/testContext/"+WebXml.RESOURCE_URI_PREFIX+"foo.Bar.jsf",resourceURL);
+
+ }
+
+ /*
+ * Test method for 'org.ajax4jsf.util.config.WebXml.getFacesResourceKey(HttpServletRequest)'
+ */
+ public void testGetFacesResourceKey() {
+
+ }
+
+ /*
+ * Test method for 'org.ajax4jsf.util.config.WebXml.isFacesRequest(HttpServletRequest)'
+ */
+ public void testIsFacesRequest() {
+
+ }
+
+ /*
+ * Test method for 'org.ajax4jsf.util.config.WebXml.setFilterName(String)'
+ */
+ public void testSetFilterName() {
+
+ }
+
+}
Modified: trunk/ui/core/src/main/config/component/commandButton.xml
===================================================================
--- trunk/ui/core/src/main/config/component/commandButton.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/commandButton.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -58,7 +58,7 @@
org.ajax4jsf.taglib.html.jsp.AjaxCommandButton
</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<displayname>Ajax CommandButton</displayname>
<icon>icon</icon>
Modified: trunk/ui/core/src/main/config/component/commandLink.xml
===================================================================
--- trunk/ui/core/src/main/config/component/commandLink.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/commandLink.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -57,7 +57,7 @@
org.ajax4jsf.taglib.html.jsp.AjaxCommandLink
</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<displayname>Ajax commandLink</displayname>
<icon>icon</icon>
Modified: trunk/ui/core/src/main/config/component/form.xml
===================================================================
--- trunk/ui/core/src/main/config/component/form.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/form.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -27,7 +27,7 @@
<name>form</name>
<classname>org.ajax4jsf.taglib.html.jsp.FormTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<displayname>Ajax-related version of html form</displayname>
<icon>icon</icon>
@@ -89,7 +89,7 @@
org.ajax4jsf.taglib.html.jsp.HtmlCommandLinkTag
</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<displayname>
Ajax-related version of html command link
Modified: trunk/ui/core/src/main/config/component/function.xml
===================================================================
--- trunk/ui/core/src/main/config/component/function.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/function.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -35,10 +35,10 @@
<name>jsFunction</name>
<classname>org.ajax4jsf.taglib.html.jsp.AjaxFunction</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<!-- <superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
-->
<displayname>Ajax Function</displayname>
Modified: trunk/ui/core/src/main/config/component/loadBundle.xml
===================================================================
--- trunk/ui/core/src/main/config/component/loadBundle.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/loadBundle.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -20,7 +20,7 @@
<name>loadBundle</name>
<classname>org.ajax4jsf.taglib.html.jsp.LoadBundle</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<displayname>
Ajax-compatible version of f:loadBundle
Modified: trunk/ui/core/src/main/config/component/loadScript.xml
===================================================================
--- trunk/ui/core/src/main/config/component/loadScript.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/loadScript.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -18,7 +18,7 @@
<name>loadScript</name>
<classname>org.ajax4jsf.taglib.html.jsp.LoadScriptTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<!--
Modified: trunk/ui/core/src/main/config/component/loadStyle.xml
===================================================================
--- trunk/ui/core/src/main/config/component/loadStyle.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/loadStyle.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -18,7 +18,7 @@
<name>loadStyle</name>
<classname>org.ajax4jsf.taglib.html.jsp.LoadStyleTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<!--
Modified: trunk/ui/core/src/main/config/component/log.xml
===================================================================
--- trunk/ui/core/src/main/config/component/log.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/log.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -24,7 +24,7 @@
<name>log</name>
<classname>org.ajax4jsf.taglib.html.jsp.LogTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<displayname>pop-up window with request log</displayname>
<icon>icon</icon>
Modified: trunk/ui/core/src/main/config/component/mediaOutput.xml
===================================================================
--- trunk/ui/core/src/main/config/component/mediaOutput.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/mediaOutput.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -32,7 +32,7 @@
org.ajax4jsf.taglib.html.jsp.MediaOutputTag
</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<displayname>Link to user-generated resource</displayname>
<icon>icon</icon>
Modified: trunk/ui/core/src/main/config/component/outputPanel.xml
===================================================================
--- trunk/ui/core/src/main/config/component/outputPanel.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/outputPanel.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -46,7 +46,7 @@
org.ajax4jsf.taglib.html.jsp.AjaxOutputPanel
</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<displayname>Ajax OutputPanel</displayname>
<icon>icon</icon>
Modified: trunk/ui/core/src/main/config/component/page.xml
===================================================================
--- trunk/ui/core/src/main/config/component/page.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/page.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -54,7 +54,7 @@
<name>page</name>
<classname>org.ajax4jsf.taglib.html.jsp.AjaxPage</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<displayname>Ajax Page</displayname>
<icon>icon</icon>
Modified: trunk/ui/core/src/main/config/component/poll.xml
===================================================================
--- trunk/ui/core/src/main/config/component/poll.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/poll.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -37,7 +37,7 @@
<name>poll</name>
<classname>org.ajax4jsf.taglib.html.jsp.AjaxPollTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<displayname>Ajax Poll</displayname>
<icon>icon</icon>
Modified: trunk/ui/core/src/main/config/component/portlet.xml
===================================================================
--- trunk/ui/core/src/main/config/component/portlet.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/portlet.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -20,7 +20,7 @@
<name>portlet</name>
<classname>org.ajax4jsf.taglib.html.jsp.Portlet</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<description>
<![CDATA[
Modified: trunk/ui/core/src/main/config/component/push.xml
===================================================================
--- trunk/ui/core/src/main/config/component/push.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/push.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -37,7 +37,7 @@
<name>push</name>
<classname>org.ajax4jsf.taglib.html.jsp.AjaxPushTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<displayname>Ajax Push</displayname>
<icon>icon</icon>
Modified: trunk/ui/core/src/main/config/component/region.xml
===================================================================
--- trunk/ui/core/src/main/config/component/region.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/region.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -54,7 +54,7 @@
<name>region</name>
<classname>org.ajax4jsf.taglib.html.jsp.AjaxRegion</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<description>
<![CDATA[This tag defines a part of the JSF Tree that is to be decoded on the
Modified: trunk/ui/core/src/main/config/component/repeat.xml
===================================================================
--- trunk/ui/core/src/main/config/component/repeat.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/repeat.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -35,7 +35,7 @@
<name>repeat</name>
<classname>org.ajax4jsf.taglib.html.jsp.AjaxRepeat</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<displayname>Ajax-enabled repeater</displayname>
<icon>icon</icon>
Modified: trunk/ui/core/src/main/config/component/status.xml
===================================================================
--- trunk/ui/core/src/main/config/component/status.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/status.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -73,7 +73,7 @@
<name>status</name>
<classname>org.ajax4jsf.taglib.html.jsp.AjaxStatus</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
</tag>
&ui_panel_attributes;
Modified: trunk/ui/core/src/main/config/component/support.xml
===================================================================
--- trunk/ui/core/src/main/config/component/support.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/config/component/support.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -63,7 +63,7 @@
org.ajax4jsf.taglib.html.jsp.AjaxSupportTag
</superclass>
<!-- <superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
-->
<displayname>Ajax Support</displayname>
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -30,7 +30,7 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.component.UIActionParameter;
-import org.ajax4jsf.framework.taglib.UIComponentTagBase;
+import org.ajax4jsf.webapp.taglib.UIComponentTagBase;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -22,7 +22,7 @@
package org.ajax4jsf.taglib.html.jsp;
import org.ajax4jsf.component.UIAjaxForm;
-import org.ajax4jsf.framework.taglib.UIComponentTagBase;
+import org.ajax4jsf.webapp.taglib.UIComponentTagBase;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -28,8 +28,8 @@
import org.ajax4jsf.component.AjaxContainer;
import org.ajax4jsf.component.UIAjaxRegion;
import org.ajax4jsf.event.AjaxListener;
-import org.ajax4jsf.framework.taglib.UIComponentTagBase;
import org.ajax4jsf.renderkit.html.AjaxRegionRenderer;
+import org.ajax4jsf.webapp.taglib.UIComponentTagBase;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -24,8 +24,8 @@
import javax.faces.component.UIComponent;
import org.ajax4jsf.component.UIAjaxStatus;
-import org.ajax4jsf.framework.taglib.HtmlComponentTagBase;
import org.ajax4jsf.renderkit.html.AjaxStatusRenderer;
+import org.ajax4jsf.webapp.taglib.HtmlComponentTagBase;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -26,9 +26,9 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.component.UIAjaxSupport;
-import org.ajax4jsf.framework.taglib.UIComponentTagBase;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.webapp.taglib.UIComponentTagBase;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -32,7 +32,7 @@
import javax.servlet.jsp.JspWriter;
import org.ajax4jsf.component.UIInclude;
-import org.ajax4jsf.framework.taglib.UIComponentTagBase;
+import org.ajax4jsf.webapp.taglib.UIComponentTagBase;
/**
* @author shura
@@ -148,7 +148,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.framework.taglib.UIComponentTagBase#release()
+ * @see org.ajax4jsf.webapp.taglib.UIComponentTagBase#release()
*/
public void release() {
super.release();
@@ -158,7 +158,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.framework.taglib.UIComponentTagBase#setProperties(javax.faces.component.UIComponent)
+ * @see org.ajax4jsf.webapp.taglib.UIComponentTagBase#setProperties(javax.faces.component.UIComponent)
*/
protected void setProperties(UIComponent component) {
super.setProperties(component);
Modified: trunk/ui/dataFilterSlider/src/main/config/component/dataFilterSlider.xml
===================================================================
--- trunk/ui/dataFilterSlider/src/main/config/component/dataFilterSlider.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/dataFilterSlider/src/main/config/component/dataFilterSlider.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -22,7 +22,7 @@
<name>dataFilterSlider</name>
<classname>org.richfaces.taglib.DataFilterSliderTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<taghandler generate="true">
Modified: trunk/ui/dataFilterSlider/src/main/java/org/richfaces/renderkit/DataFilterSliderRendererBase.java
===================================================================
--- trunk/ui/dataFilterSlider/src/main/java/org/richfaces/renderkit/DataFilterSliderRendererBase.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/dataFilterSlider/src/main/java/org/richfaces/renderkit/DataFilterSliderRendererBase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -21,7 +21,7 @@
package org.richfaces.renderkit;
-import org.ajax4jsf.framework.util.SelectUtils;
+import org.ajax4jsf.util.SelectUtils;
import org.richfaces.component.UIDataFltrSlider;
import org.richfaces.event.DataFilterSliderEvent;
Modified: trunk/ui/dataTable/src/main/config/component/colgroup.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/colgroup.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/dataTable/src/main/config/component/colgroup.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -18,7 +18,7 @@
<name>columnGroup</name>
<classname>org.richfaces.taglib.ColumnGroupTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<test/>
</tag>
Modified: trunk/ui/dataTable/src/main/config/component/column.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/column.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/dataTable/src/main/config/component/column.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -18,7 +18,7 @@
<name>column</name>
<classname>org.richfaces.taglib.ColumnTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<test/>
</tag>
Modified: trunk/ui/dataTable/src/main/config/component/dataGrid.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/dataGrid.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/dataTable/src/main/config/component/dataGrid.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -18,7 +18,7 @@
<name>dataGrid</name>
<classname>org.richfaces.taglib.DataGridTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<test/>
</tag>
Modified: trunk/ui/dataTable/src/main/config/component/dataList.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/dataList.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/dataTable/src/main/config/component/dataList.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -18,7 +18,7 @@
<name>dataList</name>
<classname>org.richfaces.taglib.DataListTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<test/>
</tag>
@@ -97,7 +97,7 @@
<name>dataOrderedList</name>
<classname>org.richfaces.taglib.DataOrderedListTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<!--
@@ -178,7 +178,7 @@
<name>dataDefinitionList</name>
<classname>org.richfaces.taglib.DataDefinitionListTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<!--
Modified: trunk/ui/dataTable/src/main/config/component/dataTable.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/dataTable.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/dataTable/src/main/config/component/dataTable.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -18,7 +18,7 @@
<name>dataTable</name>
<classname>org.richfaces.taglib.DataTableTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<test/>
</tag>
Modified: trunk/ui/dataTable/src/main/config/component/subTable.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/subTable.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/dataTable/src/main/config/component/subTable.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -19,7 +19,7 @@
<name>subTable</name>
<classname>org.richfaces.taglib.SubTableTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<test/>
</tag>
Modified: trunk/ui/datascroller/src/main/config/component/datascroller.xml
===================================================================
--- trunk/ui/datascroller/src/main/config/component/datascroller.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/datascroller/src/main/config/component/datascroller.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -31,7 +31,7 @@
<name>datascroller</name>
<classname>org.richfaces.taglib.DatascrollerTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
Modified: trunk/ui/drag-drop/src/main/config/component/dndParam.xml
===================================================================
--- trunk/ui/drag-drop/src/main/config/component/dndParam.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/drag-drop/src/main/config/component/dndParam.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -20,7 +20,7 @@
<name>dndParam</name>
<classname>org.richfaces.taglib.DndParamTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<!--
Modified: trunk/ui/drag-drop/src/main/config/component/dragIndicator.xml
===================================================================
--- trunk/ui/drag-drop/src/main/config/component/dragIndicator.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/drag-drop/src/main/config/component/dragIndicator.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -22,7 +22,7 @@
<name>dragIndicator</name>
<classname>org.richfaces.taglib.DragIndicatorTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<!--
Modified: trunk/ui/drag-drop/src/main/config/component/dragSupport.xml
===================================================================
--- trunk/ui/drag-drop/src/main/config/component/dragSupport.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/drag-drop/src/main/config/component/dragSupport.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -21,7 +21,7 @@
<tag>
<name>dragSupport</name>
<classname>org.richfaces.taglib.DragSupportTag</classname>
- <superclass>org.ajax4jsf.framework.taglib.HtmlComponentTagBase</superclass>
+ <superclass>org.ajax4jsf.webapp.taglib.HtmlComponentTagBase</superclass>
</tag>
<taghandler>
<classname>org.richfaces.taglib.DragSupportHandler</classname>
Modified: trunk/ui/drag-drop/src/main/config/component/dropSupport.xml
===================================================================
--- trunk/ui/drag-drop/src/main/config/component/dropSupport.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/drag-drop/src/main/config/component/dropSupport.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -22,7 +22,7 @@
<tag>
<name>dropSupport</name>
<classname>org.richfaces.taglib.DropSupportTag</classname>
- <superclass>org.ajax4jsf.framework.taglib.HtmlComponentTagBase</superclass>
+ <superclass>org.ajax4jsf.webapp.taglib.HtmlComponentTagBase</superclass>
</tag>
<taghandler>
<classname>org.richfaces.taglib.DropSupportHandler</classname>
Modified: trunk/ui/dropdown-menu/src/main/config/component/dropdownmenu.xml
===================================================================
--- trunk/ui/dropdown-menu/src/main/config/component/dropdownmenu.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/dropdown-menu/src/main/config/component/dropdownmenu.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -19,7 +19,7 @@
<name>dropDownMenu</name>
<classname>org.richfaces.taglib.DropDownMenuTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<test/>
</tag>
Modified: trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java
===================================================================
--- trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -52,7 +52,7 @@
static {
javaScripts.add("org.ajax4jsf.resource.PrototypeScript");
javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("org.ajax4jsf.framework.util.command.CommandScript");
+ javaScripts.add("org.ajax4jsf.util.command.CommandScript");
javaScripts.add("scripts/menu.js");
}
Modified: trunk/ui/gmap/src/main/config/component/gmap.xml
===================================================================
--- trunk/ui/gmap/src/main/config/component/gmap.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/gmap/src/main/config/component/gmap.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -20,7 +20,7 @@
<name>gmap</name>
<classname>org.richfaces.taglib.GmapTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
&ui_component_attributes;
Modified: trunk/ui/inputnumber-slider/src/main/config/component/inputNumberSlider.xml
===================================================================
--- trunk/ui/inputnumber-slider/src/main/config/component/inputNumberSlider.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/inputnumber-slider/src/main/config/component/inputNumberSlider.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -33,7 +33,7 @@
org.richfaces.taglib.InputNumberSliderTag
</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<!--
Modified: trunk/ui/inputnumber-slider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowSelectedImage.java
===================================================================
--- trunk/ui/inputnumber-slider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowSelectedImage.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/inputnumber-slider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowSelectedImage.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -23,7 +23,7 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.util.HtmlColor;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/ui/inputnumber-spinner/src/main/config/component/inputNumberSpinner.xml
===================================================================
--- trunk/ui/inputnumber-spinner/src/main/config/component/inputNumberSpinner.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/inputnumber-spinner/src/main/config/component/inputNumberSpinner.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -29,7 +29,7 @@
<name>inputNumberSpinner</name>
<classname>org.richfaces.taglib.InputNumberSpinnerTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<test>
<classname>org.richfaces.taglib.HtmlInputNumberSpinnerTagTest</classname>
Modified: trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/buttons/SpinnerButtonImage.java
===================================================================
--- trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/buttons/SpinnerButtonImage.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/buttons/SpinnerButtonImage.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -25,10 +25,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.util.HtmlColor;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/ui/menu-components/src/main/config/component/menucomponents.xml
===================================================================
--- trunk/ui/menu-components/src/main/config/component/menucomponents.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/menu-components/src/main/config/component/menucomponents.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -21,7 +21,7 @@
<name>menuGroup</name>
<classname>org.richfaces.taglib.MenuGroupTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<test/>
</tag>
@@ -169,7 +169,7 @@
<name>menuItem</name>
<classname>org.richfaces.taglib.MenuItemTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
@@ -294,7 +294,7 @@
<name>menuSeparator</name>
<classname>org.richfaces.taglib.MenuSeparatorTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase</superclass>
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase</superclass>
</tag>
&ui_component_attributes;
Modified: trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/MenuNodeImage.java
===================================================================
--- trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/MenuNodeImage.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/MenuNodeImage.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -9,11 +9,11 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.util.HtmlColor;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuSeparatorComponentTest.java
===================================================================
--- trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuSeparatorComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuSeparatorComponentTest.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -42,7 +42,7 @@
static {
javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript()");
javaScripts.add("org.ajax4jsf.resource.PrototypeScript()");
- javaScripts.add("org.ajax4jsf.framework.util.command.CommandScript()");
+ javaScripts.add("org.ajax4jsf.util.command.CommandScript()");
}
*/
private UIMenuSeparator menuSeparator;
Modified: trunk/ui/modal-panel/src/main/config/component/modalPanel.xml
===================================================================
--- trunk/ui/modal-panel/src/main/config/component/modalPanel.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/modal-panel/src/main/config/component/modalPanel.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -22,7 +22,7 @@
<name>modalPanel</name>
<classname>org.richfaces.taglib.ModalPanelTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<!--
Modified: trunk/ui/paint2D/src/main/config/component/paint2D.xml
===================================================================
--- trunk/ui/paint2D/src/main/config/component/paint2D.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/paint2D/src/main/config/component/paint2D.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -25,7 +25,7 @@
<name>paint2D</name>
<classname>org.richfaces.taglib.Paint2DTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<taghandler generate="true">
Modified: trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DResource.java
===================================================================
--- trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DResource.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DResource.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -34,7 +34,6 @@
import javax.faces.context.FacesContext;
import javax.faces.el.MethodBinding;
-import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.ImageRenderer;
import org.ajax4jsf.resource.InternetResourceBase;
@@ -42,6 +41,7 @@
import org.ajax4jsf.resource.PngRenderer;
import org.ajax4jsf.resource.ResourceContext;
import org.ajax4jsf.resource.ResourceRenderer;
+import org.ajax4jsf.util.HtmlColor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.richfaces.component.UIPaint2D;
Modified: trunk/ui/panel/src/main/config/component/panel.xml
===================================================================
--- trunk/ui/panel/src/main/config/component/panel.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/panel/src/main/config/component/panel.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -23,7 +23,7 @@
<name>panel</name>
<classname>org.richfaces.taglib.PanelTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<test>
<classname>org.richfaces.taglib.HtmlPanelTagTest</classname>
Modified: trunk/ui/panelbar/src/main/config/component/panelbar.xml
===================================================================
--- trunk/ui/panelbar/src/main/config/component/panelbar.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/panelbar/src/main/config/component/panelbar.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -26,7 +26,7 @@
<name>panelBar</name>
<classname>org.richfaces.taglib.PanelBarTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<property>
@@ -146,7 +146,7 @@
<tag>
<name>panelBarItem</name>
<classname>org.richfaces.taglib.PanelBarItemTag</classname>
- <superclass>org.ajax4jsf.framework.taglib.HtmlComponentTagBase</superclass>
+ <superclass>org.ajax4jsf.webapp.taglib.HtmlComponentTagBase</superclass>
<description>A child component of a slide panel component</description>
</tag>
Modified: trunk/ui/separator/src/main/config/component/separator.xml
===================================================================
--- trunk/ui/separator/src/main/config/component/separator.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/separator/src/main/config/component/separator.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -23,7 +23,7 @@
<name>separator</name>
<classname>org.richfaces.taglib.SeparatorTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<test>
<classname>org.richfaces.taglib.HtmlSeparatorTagTest</classname>
Modified: trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java
===================================================================
--- trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -22,9 +22,9 @@
package org.richfaces.renderkit.html;
-import org.ajax4jsf.framework.util.HtmlDimensions;
-import org.ajax4jsf.framework.util.style.CSSFormat;
+import org.ajax4jsf.framework.util.CSSFormat;
import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.util.HtmlDimensions;
import org.richfaces.component.UISeparator;
import org.richfaces.renderkit.html.images.BevelSeparatorImage;
import org.richfaces.renderkit.html.images.SimpleSeparatorImage;
Modified: trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java
===================================================================
--- trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -33,12 +33,12 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.util.HtmlColor;
-import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.HtmlDimensions;
import org.richfaces.component.UISeparator;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java
===================================================================
--- trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -31,12 +31,12 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.util.HtmlColor;
-import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.HtmlDimensions;
import org.richfaces.component.UISeparator;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/ui/simpleTogglePanel/src/main/config/component/simpleTogglePanel.xml
===================================================================
--- trunk/ui/simpleTogglePanel/src/main/config/component/simpleTogglePanel.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/simpleTogglePanel/src/main/config/component/simpleTogglePanel.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -23,7 +23,7 @@
<name>simpleTogglePanel</name>
<classname>org.richfaces.taglib.SimpleTogglePanelTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
Modified: trunk/ui/spacer/src/main/config/component/spacer.xml
===================================================================
--- trunk/ui/spacer/src/main/config/component/spacer.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/spacer/src/main/config/component/spacer.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -24,7 +24,7 @@
<name>spacer</name>
<classname>org.richfaces.taglib.SpacerTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
Modified: trunk/ui/suggestionbox/src/main/config/component/suggestionbox.xml
===================================================================
--- trunk/ui/suggestionbox/src/main/config/component/suggestionbox.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/suggestionbox/src/main/config/component/suggestionbox.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -36,7 +36,7 @@
<name>suggestionbox</name>
<classname>org.richfaces.taglib.SuggestionBoxTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
Modified: trunk/ui/tabPanel/src/main/config/component/tabPanel.xml
===================================================================
--- trunk/ui/tabPanel/src/main/config/component/tabPanel.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/tabPanel/src/main/config/component/tabPanel.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -25,7 +25,7 @@
<name>tabPanel</name>
<classname>org.richfaces.taglib.TabPanelTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<property>
@@ -149,7 +149,7 @@
<name>tab</name>
<classname>org.richfaces.taglib.TabTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
Modified: trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java
===================================================================
--- trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -21,10 +21,10 @@
package org.richfaces.renderkit;
-import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.util.HtmlDimensions;
import org.richfaces.component.UISwitchablePanel;
import org.richfaces.component.UITab;
import org.richfaces.component.UITabPanel;
Modified: trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
===================================================================
--- trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -22,12 +22,12 @@
package org.richfaces.renderkit;
import org.ajax4jsf.event.AjaxEvent;
-import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.ComponentVariables;
import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.util.HtmlDimensions;
import org.richfaces.component.UISwitchablePanel;
import org.richfaces.component.UITab;
import org.richfaces.component.UITabPanel;
Modified: trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java
===================================================================
--- trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -30,11 +30,11 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.util.HtmlColor;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/ui/togglePanel/src/main/config/component/togglePanel.xml
===================================================================
--- trunk/ui/togglePanel/src/main/config/component/togglePanel.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/togglePanel/src/main/config/component/togglePanel.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -29,7 +29,7 @@
<name>togglePanel</name>
<classname>org.richfaces.taglib.TogglePanelTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
<description>
<![CDATA[A wrapper component with named facets. Every facet is shown after activation corresponding toggleControl(the other is hidden).
@@ -138,7 +138,7 @@
org.richfaces.taglib.ToggleControlTag
</classname>
<superclass>
- org.ajax4jsf.framework.taglib.UIComponentTagBase
+ org.ajax4jsf.webapp.taglib.UIComponentTagBase
</superclass>
<description>
<![CDATA[A link type control for switching betwen togglePanel's facets. The Target Panel is specified with the "for" attribute. It can be located even inside or outside the togglePanel.
Modified: trunk/ui/toolBar/src/main/config/component/toolBar.xml
===================================================================
--- trunk/ui/toolBar/src/main/config/component/toolBar.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/toolBar/src/main/config/component/toolBar.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -23,7 +23,7 @@
<tag>
<name>toolBar</name>
<classname>org.richfaces.taglib.ToolBarTag</classname>
- <superclass>org.ajax4jsf.framework.taglib.HtmlComponentTagBase</superclass>
+ <superclass>org.ajax4jsf.webapp.taglib.HtmlComponentTagBase</superclass>
<description>
<![CDATA[A horizontal bar with items on it.
If you want to use it as a standard top tool bar, point to each item with a ch:menu "for" attribute
@@ -118,7 +118,7 @@
<tag>
<name>toolBarGroup</name>
<classname>org.richfaces.taglib.ToolBarGroupTag</classname>
- <superclass>org.ajax4jsf.framework.taglib.UIComponentTagBase</superclass>
+ <superclass>org.ajax4jsf.webapp.taglib.UIComponentTagBase</superclass>
</tag>
<property>
Modified: trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/images/ToolBarSeparatorImage.java
===================================================================
--- trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/images/ToolBarSeparatorImage.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/images/ToolBarSeparatorImage.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -26,11 +26,11 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.util.HtmlColor;
-import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.HtmlDimensions;
import org.richfaces.component.UIToolBar;
import org.richfaces.component.UIToolBarGroup;
import org.richfaces.skin.Skin;
Modified: trunk/ui/tree/src/main/config/component/tree.xml
===================================================================
--- trunk/ui/tree/src/main/config/component/tree.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/tree/src/main/config/component/tree.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -29,7 +29,7 @@
<name>tree</name>
<classname>org.richfaces.taglib.TreeTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<taghandler generate="true">
Modified: trunk/ui/tree/src/main/config/component/treeNode.xml
===================================================================
--- trunk/ui/tree/src/main/config/component/treeNode.xml 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/tree/src/main/config/component/treeNode.xml 2007-07-10 19:14:51 UTC (rev 1589)
@@ -29,7 +29,7 @@
<name>treeNode</name>
<classname>org.richfaces.taglib.TreeNodeTag</classname>
<superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<taghandler generate="true">
Modified: trunk/ui/tree/src/main/java/org/richfaces/renderkit/html/images/TreeImageBase.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/renderkit/html/images/TreeImageBase.java 2007-07-10 19:07:38 UTC (rev 1588)
+++ trunk/ui/tree/src/main/java/org/richfaces/renderkit/html/images/TreeImageBase.java 2007-07-10 19:14:51 UTC (rev 1589)
@@ -26,10 +26,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.util.HtmlColor;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
18 years, 2 months
JBoss Rich Faces SVN: r1588 - in trunk: framework/impl/src/main/java/org/ajax4jsf/framework/util/image/imageio and 25 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-10 15:07:38 -0400 (Tue, 10 Jul 2007)
New Revision: 1588
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/DiffusionFilterOp.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/GIFEncoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/ImageInfo.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/Quantize.java
trunk/framework/test/src/test/java/org/richfaces/skin/
trunk/framework/test/src/test/java/org/richfaces/skin/Bean.java
trunk/framework/test/src/test/java/org/richfaces/skin/SkinTestCase.java
trunk/framework/test/src/test/java/org/richfaces/skin/SkinTests.java
trunk/framework/test/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java
trunk/framework/test/src/test/java/org/richfaces/skin/TestApplicationFactory.java
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/DiffusionFilterOp.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/GIFEncoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageFilterOp.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageGenerator.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageInfo.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageWaiter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageWrapper.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/IndexImage.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/Quantize.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/RoundGradientContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/RoundGradientPaint.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/SimpleGIFEncoder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/imageio/ImageIOGenerator.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/imageio/gif/
trunk/framework/impl/src/main/resources/META-INF/services/javax.imageio.spi.ImageWriterSpi
trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/
trunk/framework/test/src/test/java/org/richfaces/skin/Bean.java
trunk/framework/test/src/test/java/org/richfaces/skin/SkinTestCase.java
trunk/framework/test/src/test/java/org/richfaces/skin/SkinTests.java
trunk/framework/test/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java
trunk/framework/test/src/test/java/org/richfaces/skin/TestApplicationFactory.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/InternetResourceServiceTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockCacheableResource.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/ParametersEncodingTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java
trunk/samples/useCases/src/main/java/control/test/ControlBackingBean.java
trunk/samples/useCases/src/test/java/org/ajax4jsf/BeanTest.java
trunk/ui/dataFilterSlider/src/main/java/org/richfaces/component/UIDataFltrSlider.java
trunk/ui/dataFilterSlider/src/main/java/org/richfaces/taglib/DataFilterSliderListenerTagHandler.java
trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/background/SpinnerButtonGradient.java
trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/background/SpinnerFieldGradient.java
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuSeparatorComponentTest.java
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java
trunk/ui/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java
trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
trunk/ui/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java
trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
trunk/ui/tree/src/test/java/org/richfaces/component/state/events/CollapseAllCommandEventTest.java
trunk/ui/tree/src/test/java/org/richfaces/component/state/events/CollapseNodeCommandEventTest.java
trunk/ui/tree/src/test/java/org/richfaces/component/state/events/ExpandAllCommandEventTest.java
trunk/ui/tree/src/test/java/org/richfaces/component/state/events/ExpandNodeCommandEventTest.java
Log:
packages and classes refactor in the "impl" project
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/DiffusionFilterOp.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/DiffusionFilterOp.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/DiffusionFilterOp.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,268 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Helma License Notice
- *
- * The contents of this file are subject to the Helma License
- * Version 2.0 (the "License"). You may not use this file except in
- * compliance with the License. A copy of the License is available at
- * http://adele.helma.org/download/helma/license.txt
- *
- * Copyright 1998-2003 Helma Software. All Rights Reserved.
- *
- * $RCSfile: DiffusionFilterOp.java,v $
- * $Author: alexsmirnov $
- * $Revision: 1.1.2.1 $
- * $Date: 2007/01/09 18:59:06 $
- */
-
-/*
- * Code from com.jhlabs.image.DiffusionFilter, Java Image Processing
- * Copyright (C) Jerry Huxtable 1998
- * http://www.jhlabs.com/ip/
- *
- * Conversion to a BufferedImageOp inspired by:
- * http://www.peter-cockerell.net:8080/java/FloydSteinberg/FloydSteinbergFil...
- *
- */
-
-package org.ajax4jsf.framework.util.image;
-
-import java.awt.RenderingHints;
-import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-import java.awt.image.BufferedImageOp;
-import java.awt.image.ColorModel;
-import java.awt.image.DataBufferByte;
-import java.awt.image.DataBufferInt;
-import java.awt.image.IndexColorModel;
-
-import org.ajax4jsf.Messages;
-
-public class DiffusionFilterOp implements BufferedImageOp {
-
- protected final static int[] diffusionMatrix = {
- 0, 0, 0,
- 0, 0, 7,
- 3, 5, 1,
- };
-
- private int[] matrix;
- private int sum;
- private boolean serpentine = true;
- private int[] colorMap;
-
- /**
- * Construct a DiffusionFilter
- */
- public DiffusionFilterOp() {
- setMatrix(diffusionMatrix);
- }
-
- /**
- * Set whether to use a serpentine pattern for return or not. This can reduce 'avalanche' artifacts in the output.
- * @param serpentine true to use serpentine pattern
- */
- public void setSerpentine(boolean serpentine) {
- this.serpentine = serpentine;
- }
-
- /**
- * Return the serpentine setting
- * @return the current setting
- */
- public boolean getSerpentine() {
- return serpentine;
- }
-
- public void setMatrix(int[] matrix) {
- this.matrix = matrix;
- sum = 0;
- for (int i = 0; i < matrix.length; i++)
- sum += matrix[i];
- }
-
- public int[] getMatrix() {
- return matrix;
- }
-
- /**
- * Do the filter operation
- *
- * @param src The source BufferedImage. Can be any type.
- * @param dst The destination image. If not null, must be of type TYPE_BYTE_INDEXED
- * @return A dithered version of src in a BufferedImage of type TYPE_BYTE_INDEXED
- */
- public BufferedImage filter(BufferedImage src, BufferedImage dst) {
-
- // If there's no dest. create one
- if (dst == null)
- dst = createCompatibleDestImage(src, null);
-
- // Otherwise check that the provided dest is an indexed image
- else if (dst.getType() != BufferedImage.TYPE_BYTE_INDEXED) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.BUFFER_TYPE_ERROR));
- }
-
- DataBufferByte dstBuffer = (DataBufferByte) dst.getRaster().getDataBuffer();
- byte dstData[] = dstBuffer.getData();
-
- // Other things to test are pixel bit strides, scanline stride and transfer type
- // Same goes for the source image
-
- IndexColorModel icm = (IndexColorModel) dst.getColorModel();
- colorMap = new int[icm.getMapSize()];
- icm.getRGBs(colorMap);
-
- int width = src.getWidth();
- int height = src.getHeight();
-
- DataBufferInt srcBuffer = (DataBufferInt) src.getRaster().getDataBuffer();
- int srcData[] = srcBuffer.getData();
-
- // This is the offset into the buffer of the current source pixel
- int index = 0;
-
- // Loop through each pixel
- for (int y = 0; y < height; y++) {
- boolean reverse = serpentine && (y & 1) == 1;
- int direction;
- if (reverse) {
- index = y * width + width - 1;
- direction = -1;
- } else {
- index = y * width;
- direction = 1;
- }
- for (int x = 0; x < width; x++) {
- int rgb1 = srcData[index];
- int a1 = (rgb1 >> 24) & 0xff;
- int r1 = (rgb1 >> 16) & 0xff;
- int g1 = (rgb1 >> 8) & 0xff;
- int b1 = rgb1 & 0xff;
-
- int idx = findIndex(r1, g1, b1, a1);
- dstData[index] = (byte) idx;
-
- int rgb2 = colorMap[idx];
- int a2 = (rgb2 >> 24) & 0xff;
- int r2 = (rgb2 >> 16) & 0xff;
- int g2 = (rgb2 >> 8) & 0xff;
- int b2 = rgb2 & 0xff;
-
- int er = r1 - r2;
- int eg = g1 - g2;
- int eb = b1 - b2;
- int ea = a1 - a2;
-
- for (int i = -1; i <= 1; i++) {
- int iy = i + y;
- if (0 <= iy && iy < height) {
- for (int j = -1; j <= 1; j++) {
- int jx = j + x;
- if (0 <= jx && jx < width) {
- int w;
- if (reverse)
- w = matrix[(i + 1) * 3 - j + 1];
- else
- w = matrix[(i + 1) * 3 + j + 1];
- if (w != 0) {
- int k = reverse ? index - j : index + j;
- rgb1 = srcData[k];
- a1 = ((rgb1 >> 24) & 0xff) + ea * w / sum;
- r1 = ((rgb1 >> 16) & 0xff) + er * w / sum;
- g1 = ((rgb1 >> 8) & 0xff) + eg * w / sum;
- b1 = (rgb1 & 0xff) + eb * w / sum;
-
- srcData[k] = ((clamp(a1) << 24) | clamp(r1) << 16)
- | (clamp(g1) << 8) | clamp(b1);
- }
- }
- }
- }
- }
- index += direction;
- }
- }
-
- return dst;
- }
-
- private static int clamp(int c) {
- if (c < 0)
- return 0;
- if (c > 255)
- return 255;
- return c;
- }
-
- int findIndex(int r1, int g1, int b1, int a1)
- throws ArrayIndexOutOfBoundsException {
- int idx = 0;
- long dist = Long.MAX_VALUE;
- for (int i = 0; i < colorMap.length; i++) {
- int rgb2 = colorMap[i];
- int a2 = (rgb2 >> 24) & 0xff;
- int r2 = (rgb2 >> 16) & 0xff;
- int g2 = (rgb2 >> 8) & 0xff;
- int b2 = rgb2 & 0xff;
-
- int da = a1 - a2;
- int dr = r1 - r2;
- int dg = g1 - g2;
- int db = b1 - b2;
-
- long newdist = da * da + dr * dr + dg * dg + db * db;
- if (newdist < dist) {
- idx = i;
- dist = newdist;
- }
- }
- return idx;
- }
-
- // This always returns an indexed image
- public BufferedImage createCompatibleDestImage(BufferedImage src,
- ColorModel destCM) {
- return new BufferedImage(src.getWidth(), src.getHeight(),
- BufferedImage.TYPE_BYTE_INDEXED);
- }
-
- // There are no rendering hints
- public RenderingHints getRenderingHints() {
- return null;
- }
-
- // No transformation, so return the source point
- public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
- if (dstPt == null)
- dstPt = new Point2D.Float();
- dstPt.setLocation(srcPt.getX(), srcPt.getY());
- return dstPt;
- }
-
- // No transformation, so return the source bounds
- public Rectangle2D getBounds2D(BufferedImage src) {
- return src.getRaster().getBounds();
- }
-}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/GIFEncoder.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/GIFEncoder.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/GIFEncoder.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,554 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Helma License Notice
- *
- * The contents of this file are subject to the Helma License
- * Version 2.0 (the "License"). You may not use this file except in
- * compliance with the License. A copy of the License is available at
- * http://adele.helma.org/download/helma/license.txt
- *
- * Copyright 1998-2003 Helma Software. All Rights Reserved.
- *
- * $RCSfile: GIFEncoder.java,v $
- * $Author: alexsmirnov $
- * $Revision: 1.1.2.1 $
- * $Date: 2007/01/09 18:59:03 $
- */
-
-/*
- * The GIF encoding routines are based on the Acme libary
- *
- * The following addaptions and extensions were added by Joerg Lehni:
- *
- * - encode now directly works on BufferedImage objects, the ImageEncoder
- * and ImageConsumer oriented frameworks has been removed.
- * - Only BufferedImages with IndexColorModel are taken, so no more
- * palette optimization with IntHashtable objects are necessary. If the
- * BufferedImage is in wrong format, helma.image.Quantizie is used to
- * convert it into a index based image.
- * - This version is much less space consuming as it only takes one sample
- * row of the rastered image at a time into memory during compression.
- * - The overall time for color reduction and gif compression should
- * therefore be greatly reduced.
- *
- * Acme Disclaimer:
- *
- * Transparency handling and variable bit size courtesy of Jack Palevich.
- *
- * Copyright (C)1996,1998 by Jef Poskanzer <jef(a)acme.com>. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Visit the ACME Labs Java page for up-to-date versions of this and other
- * fine Java utilities: http://www.acme.com/java/
- *
- * GifEncoder is adapted from ppmtogif, which is based on GIFENCOD by David
- * Rowley <mgardi(a)watdscu.waterloo.edu>. Lempel-Zim compression
- * based on "compress".
- *
- */
-
-package org.ajax4jsf.framework.util.image;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.IndexColorModel;
-import java.awt.image.Raster;
-import java.io.DataOutput;
-import java.io.IOException;
-
-public class GIFEncoder {
- private boolean interlace = false;
-
- private int width, height;
- private Raster raster;
- // DataOutput is used for compatibility with ImageIO (see helma.image.imageio.gif.GIFImageWriter)
- // otherwise, OutputStream would make much more sense here:
- private DataOutput out;
-
- private int curx, cury;
- private int countdown;
- private int pass;
- private int[] row;
-
- public void encode(BufferedImage bi, DataOutput out) throws IOException {
- encode(bi, out, false, null);
- }
-
- public void encode(BufferedImage bi, DataOutput out, boolean interlace,
- String comment) throws IOException {
- this.out = out;
- this.interlace = interlace;
-
- // make sure it's index colors:
- if (bi.getType() != BufferedImage.TYPE_BYTE_INDEXED)
- bi = Quantize.process(bi, 256, false, true);
-
- raster = bi.getRaster();
-
- width = bi.getWidth();
- height = bi.getHeight();
-
- int numPixels = width * height;
-
- IndexColorModel icm = (IndexColorModel) bi.getColorModel();
- int transparentIndex = icm.getTransparentPixel();
- int numColors = icm.getMapSize();
-
- // Figure out how many bits to use.
- int bitsPerPixel;
- if (numColors <= 2)
- bitsPerPixel = 1;
- else if (numColors <= 4)
- bitsPerPixel = 2;
- else if (numColors <= 16)
- bitsPerPixel = 4;
- else
- bitsPerPixel = 8;
-
- int initCodeSize;
-
- // Calculate number of bits we are expecting
- countdown = numPixels;
-
- // Indicate which pass we are on (if interlace)
- pass = 0;
-
- // The initial code size
- if (bitsPerPixel <= 1)
- initCodeSize = 2;
- else
- initCodeSize = bitsPerPixel;
-
- // Set up the current x and y position
- curx = 0;
- cury = 0;
- row = new int[width];
-
- // Write the Magic header
- writeString("GIF89a");
-
- // Write out the screen width and height
- writeWord(width);
- writeWord(height);
-
- // Indicate that there is a global colour map
- byte flags = (byte) 0x80; // Yes, there is a color map
- // OR in the resolution
- flags |= (byte) ((8 - 1) << 4);
- // Not sorted
- // OR in the Bits per Pixel
- flags |= (byte) ((bitsPerPixel - 1));
- // Write it out
- out.write(flags);
-
- // Write out the Background colour
- out.write((byte) 0);
-
- // Pixel aspect ratio - 1:1.
- //out.write((byte) 49);
- // Java's GIF reader currently has a bug, if the aspect ratio byte is
- // not zero it throws an ImageFormatException. It doesn't know that
- // 49 means a 1:1 aspect ratio. Well, whatever, zero works with all
- // the other decoders I've tried so it probably doesn't hurt.
- out.write((byte) 0);
-
- // Write out the Global Colour Map
- // Turn colors into colormap entries.
- int mapSize = 1 << bitsPerPixel;
- byte[] reds = new byte[mapSize], greens = new byte[mapSize], blues = new byte[mapSize];
- icm.getReds(reds);
- icm.getGreens(greens);
- icm.getBlues(blues);
-
- for (int i = 0; i < mapSize; ++i) {
- out.write(reds[i]);
- out.write(greens[i]);
- out.write(blues[i]);
- }
-
- // Write out extension for transparent colour index, if necessary.
- if (transparentIndex != -1) {
- out.write((byte) '!');
- out.write((byte) 0xf9);
- out.write((byte) 4);
- out.write((byte) 1);
- out.write((byte) 0);
- out.write((byte) 0);
- out.write((byte) transparentIndex);
- out.write((byte) 0);
- }
-
- // Write an Image separator
- out.write((byte) ',');
-
- // Write the Image header
- writeWord(0); // leftOfs
- writeWord(0); // topOfs
- writeWord(width);
- writeWord(height);
-
- // Write out whether or not the image is interlaced
- if (interlace)
- out.write((byte) 0x40);
- else
- out.write((byte) 0x00);
-
- // Write out the initial code size
- out.write((byte) initCodeSize);
-
- // Go and actually compress the data
- compress(initCodeSize + 1);
-
- // Write out a Zero-length packet (to end the series)
- out.write((byte) 0);
-
- // Write out the comment
- if (comment != null && comment.length() > 0) {
- out.write((byte) 0x21);
- out.write((byte) 0xFE);
- out.write((byte) comment.length());
- writeString(comment);
- out.write((byte) 0);
- }
-
- // Write the GIF file terminator
- out.write((byte) ';');
- }
-
- // Return the next pixel from the image
- int getNextPixel() throws IOException {
- if (countdown == 0)
- return -1;
-
- --countdown;
-
- if (curx == 0)
- row = raster.getSamples(0, cury, width, 1, 0, row);
- int index = row[curx];
-
- // Bump the current X position
- ++curx;
-
- // If we are at the end of a scan line, set curx back to the beginning
- // If we are interlaced, bump the cury to the appropriate spot,
- // otherwise, just increment it.
- if (curx == width) {
- curx = 0;
-
- if (!interlace) {
- ++cury;
- } else {
- switch (pass) {
- case 0:
- cury += 8;
- if (cury >= height) {
- ++pass;
- cury = 4;
- }
- break;
-
- case 1:
- cury += 8;
- if (cury >= height) {
- ++pass;
- cury = 2;
- }
- break;
-
- case 2:
- cury += 4;
- if (cury >= height) {
- ++pass;
- cury = 1;
- }
- break;
-
- case 3:
- cury += 2;
- break;
- }
- }
- }
- return index;
- }
-
- void writeString(String str) throws IOException {
- byte[] buf = str.getBytes();
- out.write(buf);
- }
-
- // Write out a word to the GIF file
- void writeWord(int w) throws IOException {
- out.write((byte) (w & 0xff));
- out.write((byte) ((w >> 8) & 0xff));
- }
-
- // GIFCOMPR.C - GIF Image compression routines
- //
- // Lempel-Ziv compression based on 'compress'. GIF modifications by
- // David Rowley (mgardi(a)watdcsu.waterloo.edu)
-
- // General DEFINEs
-
- static final int BITS = 12;
-
- static final int HASH_SIZE = 5003; // 80% occupancy
-
- // GIF Image compression - modified 'compress'
- //
- // Based on: compress.c - File compression ala IEEE Computer, June 1984.
- //
- // By Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
- // Jim McKie (decvax!mcvax!jim)
- // Steve Davies (decvax!vax135!petsd!peora!srd)
- // Ken Turkowski (decvax!decwrl!turtlevax!ken)
- // James A. Woods (decvax!ihnp4!ames!jaw)
- // Joe Orost (decvax!vax135!petsd!joe)
-
- private int numBits; // number of bits/code
- private int maxBits = BITS; // user settable max # bits/code
- private int maxCode; // maximum code, given numBits
- private int maxMaxCode = 1 << BITS; // should NEVER generate this code
-
- final int getMaxCode(int numBits) {
- return (1 << numBits) - 1;
- }
-
- private int[] hashTable = new int[HASH_SIZE];
- private int[] codeTable = new int[HASH_SIZE];
-
- private int freeEntry = 0; // first unused entry
-
- // block compression parameters -- after all codes are used up,
- // and compression rate changes, start over.
- private boolean clearFlag = false;
-
- // Algorithm: use open addressing double hashing (no chaining) on the
- // prefix code / next character combination. We do a variant of Knuth's
- // algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
- // secondary probe. Here, the modular division first probe is gives way
- // to a faster exclusive-or manipulation. Also do block compression with
- // an adaptive reset, whereby the code table is cleared when the compression
- // ratio decreases, but after the table fills. The variable-length output
- // codes are re-sized at this point, and a special CLEAR code is generated
- // for the decompressor. Late addition: construct the table according to
- // file size for noticeable speed improvement on small files. Please direct
- // questions about this implementation to ames!jaw.
-
- private int initBits;
-
- private int clearCode;
- private int EOFCode;
-
- void compress(int initBits) throws IOException {
- // Set up the globals: initBits - initial number of bits
- this.initBits = initBits;
-
- // Set up the necessary values
- clearFlag = false;
- numBits = initBits;
- maxCode = getMaxCode(numBits);
-
- clearCode = 1 << (initBits - 1);
- EOFCode = clearCode + 1;
- freeEntry = clearCode + 2;
-
- charInit();
-
- int ent = getNextPixel();
-
- int hashShift = 0;
- for (int fcode = HASH_SIZE; fcode < 65536; fcode *= 2)
- ++hashShift;
- hashShift = 8 - hashShift; // set hash code range bound
-
- clearHash(); // clear hash table
-
- output(clearCode);
-
- int c;
- outerLoop: while ((c = getNextPixel()) != -1) {
- int fcode = (c << maxBits) + ent;
- int i = (c << hashShift) ^ ent; // xor hashing
-
- if (hashTable[i] == fcode) {
- ent = codeTable[i];
- continue;
- } else if (hashTable[i] >= 0) { // non-empty slot
- int disp = HASH_SIZE - i; // secondary hash (after G. Knott)
- if (i == 0)
- disp = 1;
- do {
- if ((i -= disp) < 0)
- i += HASH_SIZE;
-
- if (hashTable[i] == fcode) {
- ent = codeTable[i];
- continue outerLoop;
- }
- } while (hashTable[i] >= 0);
- }
- output(ent);
- ent = c;
- if (freeEntry < maxMaxCode) {
- codeTable[i] = freeEntry++; // code -> hashtable
- hashTable[i] = fcode;
- } else
- clearBlock();
- }
- // Put out the final code.
- output(ent);
- output(EOFCode);
- }
-
- // output
- //
- // Output the given code.
- // Inputs:
- // code: A numBits-bit integer. If == -1, then EOF. This assumes
- // that numBits =< wordsize - 1.
- // Outputs:
- // Outputs code to the file.
- // Assumptions:
- // Chars are 8 bits long.
- // Algorithm:
- // Maintain a BITS character long buffer (so that 8 codes will
- // fit in it exactly). Use the VAX insv instruction to insert each
- // code in turn. When the buffer fills up empty it and start over.
-
- int curAccum = 0;
- int curBits = 0;
-
- int masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F,
- 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF,
- 0x7FFF, 0xFFFF };
-
- void output(int code) throws IOException {
- curAccum &= masks[curBits];
-
- if (curBits > 0)
- curAccum |= (code << curBits);
- else
- curAccum = code;
-
- curBits += numBits;
-
- while (curBits >= 8) {
- charOut((byte) (curAccum & 0xff));
- curAccum >>= 8;
- curBits -= 8;
- }
-
- // If the next entry is going to be too big for the code size,
- // then increase it, if possible.
- if (freeEntry > maxCode || clearFlag) {
- if (clearFlag) {
- maxCode = getMaxCode(numBits = initBits);
- clearFlag = false;
- } else {
- ++numBits;
- if (numBits == maxBits)
- maxCode = maxMaxCode;
- else
- maxCode = getMaxCode(numBits);
- }
- }
-
- if (code == EOFCode) {
- // At EOF, write the rest of the buffer.
- while (curBits > 0) {
- charOut((byte) (curAccum & 0xff));
- curAccum >>= 8;
- curBits -= 8;
- }
-
- charFlush();
- }
- }
-
- // Clear out the hash table
-
- // table clear for block compress
- void clearBlock() throws IOException {
- clearHash();
- freeEntry = clearCode + 2;
- clearFlag = true;
-
- output(clearCode);
- }
-
- // reset code table
- void clearHash() {
- for (int i = 0; i < HASH_SIZE; ++i)
- hashTable[i] = -1;
- }
-
- // GIF Specific routines
-
- // Number of characters so far in this 'packet'
- private int a_count;
-
- // Set up the 'byte output' routine
- void charInit() {
- a_count = 0;
- }
-
- // Define the storage for the packet accumulator
- private byte[] accum = new byte[256];
-
- // Add a character to the end of the current packet, and if it is 254
- // characters, flush the packet to disk.
- void charOut(byte c) throws IOException {
- accum[a_count++] = c;
- if (a_count >= 254)
- charFlush();
- }
-
- // Flush the packet to disk, and reset the accumulator
- void charFlush() throws IOException {
- if (a_count > 0) {
- out.write(a_count);
- out.write(accum, 0, a_count);
- a_count = 0;
- }
- }
-}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageFilterOp.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageFilterOp.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageFilterOp.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,287 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Helma License Notice
- *
- * The contents of this file are subject to the Helma License Version 2.0 (the
- * "License"). You may not use this file except in compliance with the License.
- * A copy of the License is available at
- * http://adele.helma.org/download/helma/license.txt
- *
- * Copyright 1998-2003 Helma Software. All Rights Reserved.
- *
- * $RCSfile: ImageFilterOp.java,v $
- * $Author: alexsmirnov $
- * $Revision: 1.1.2.1 $
- * $Date: 2007/01/09 18:59:04 $
- */
-
-/**
- * This class does pretty much the opposite of java.awt.image.BufferedImageFilter:
- * It wraps an ImageFilter in a BufferedImageOp
- * Optimizations have been added, like the ignoring of color models
- * and the assumption of INT_RGB type for destination buffers in
- * order to speed things up by almost a factor of 4.
- */
-
-package org.ajax4jsf.framework.util.image;
-
-import java.awt.AlphaComposite;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-import java.awt.image.BufferedImageOp;
-import java.awt.image.ColorModel;
-import java.awt.image.DataBufferInt;
-import java.awt.image.ImageConsumer;
-import java.awt.image.ImageFilter;
-import java.util.Hashtable;
-
-public class ImageFilterOp implements BufferedImageOp {
- ImageFilter filter;
-
- /**
- * Construct a ImageFilterOp
- */
- public ImageFilterOp(ImageFilter filter) {
- this.filter = filter;
- }
-
- /**
- * Do the filter operation
- *
- * @param src The source BufferedImage. Can be any type.
- * @param dst The destination image. If not null, must be of type
- * TYPE_INT_RGB, TYPE_INT_ARGB or TYPE_INT_ARGB_PRE
- * @return the filtered image
- */
- public BufferedImage filter(BufferedImage src, BufferedImage dst) {
- int width = src.getWidth();
- int height = src.getHeight();
-
- BufferedImageConsumer consumer = new BufferedImageConsumer(dst);
-
- ImageFilter fltr = filter.getFilterInstance(consumer);
- fltr.setDimensions(width, height);
-
- /*
- ColorModel cm = src.getColorModel();
- if (cm.getPixelSize() == 8) {
- // byte. indexed or gray:
- WritableRaster raster = src.getRaster();
- byte pixels[] = new byte[width];
- // calculate scanline by scanline in order to safe memory.
- // It also seems to run faster like that
- for (int y = 0; y < height; y++) {
- raster.getDataElements(0, y, width, 1, pixels);
- fltr.setPixels(0, y, width, 1, cm, pixels, 0, width);
- }
- } else {
- // integer, use the simple rgb mode:
- WritableRaster raster = src.getRaster();
- int pixels[] = new int[width];
- // calculate scanline by scanline in order to safe memory.
- // It also seems to run faster like that
- for (int y = 0; y < height; y++) {
- raster.getDataElements(0, y, width, 1, pixels);
- fltr.setPixels(0, y, width, 1, cm, pixels, 0, width);
- }
- }
- */
-
- // allways work in integer mode. this is more effective, and most
- // filters convert to integer internally anyhow
- ColorModel cm = new SimpleColorModel();
-
- // create a BufferedImage of only 1 pixel height for fetching the rows of the image in the correct format (ARGB)
- // This speeds up things by more than factor 2, compared to the standard BufferedImage.getRGB solution,
- // which is supposed to be fast too. This is probably the case because drawing to BufferedImages uses
- // very optimized code which may even be hardware accelerated.
- BufferedImage row = new BufferedImage(width, 1, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g2d = row.createGraphics();
- int pixels[] = ((DataBufferInt)row.getRaster().getDataBuffer()).getData();
-
- // make sure alpha values do not add up for each row:
- g2d.setComposite(AlphaComposite.Src);
- // calculate scanline by scanline in order to safe memory.
- // It also seems to run faster like that
- for (int y = 0; y < height; y++) {
- g2d.drawImage(src, null, 0, -y);
- // now pixels contains the rgb values of the row y!
- // filter this row now:
- fltr.setPixels(0, y, width, 1, cm, pixels, 0, width);
- }
- g2d.dispose();
-
- // the consumer now contains the filtered image, return it.
- return consumer.getImage();
- }
-
- public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM) {
- return null;
- }
-
- public RenderingHints getRenderingHints() {
- return null;
- }
-
- public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
- return null;
- }
-
- public Rectangle2D getBounds2D(BufferedImage src) {
- return null;
- }
-
- /**
- * This is a dummy ColorModel that does nothing else than returning an
- * unchanged rgb value in getRGB, getRed, getGreen, getBlue, getAlpha.
- * This speeds up things for BufferedImages by at least a factor 1.5!
- */
- class SimpleColorModel extends ColorModel {
- public SimpleColorModel() {
- this(32);
- }
-
- public SimpleColorModel(int bits) {
- super(bits);
- }
-
- public int getRGB(int rgb) {
- // this is the part that speeds up most.
- // java.awt.image.ColorModel would return the same value, but with
- // 4 function calls and a lot of shifts and ors per color!
- return rgb;
- }
-
- public int getAlpha(int pixel) {
- return pixel >> 24;
- }
-
- public int getRed(int pixel) {
- return (pixel >> 16) & 0xff;
- }
-
- public int getGreen(int pixel) {
- return (pixel >> 8) & 0xff;
- }
-
- public int getBlue(int pixel) {
- return pixel & 0xff;
- }
- }
-
- /**
- * This is a dummy ImageConsumser that does nothing else than writing
- * The resulting rows from the ImageFilter into the image
- * If the image was not specified in the constructor, setDimensions
- * creates it with the given dimensions.
- */
- class BufferedImageConsumer implements ImageConsumer {
- BufferedImage image;
- BufferedImage compatible;
- int width;
- int height;
- boolean first = true;
-
- /*
- * Constructor with no compatible image. if image is null, setDimensions
- * will create a default INT_ARGB image of the size defined by the filter.
- */
- public BufferedImageConsumer(BufferedImage image) {
- this(image, null);
- }
-
- /*
- * Constructor with a compatible image. if image is null, setDimensions
- * will create a compatible image of the size defined by the filter.
- */
- public BufferedImageConsumer(BufferedImage image, BufferedImage compatible) {
- this.image = image;
- this.compatible = compatible;
- }
-
- public BufferedImage getImage() {
- return image;
- }
-
- public void setDimensions(int w, int h) {
- if (image == null) {
- if (compatible != null) {
- // create a compatible image with the new dimensions:
- image = new BufferedImage(
- compatible.getColorModel(),
- compatible.getRaster().createCompatibleWritableRaster(w, h),
- compatible.isAlphaPremultiplied(),
- null
- );
- } else {
- // assume standard format:
- image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
- }
- }
- width = image.getWidth();
- height = image.getHeight();
- }
-
- public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize) {
- // Cropping may be necessary: It's possible that the size of the
- // specified destination image is not the same as the size the
- // ImageFilter would produce!
- if (x < width && y < height) {
- if (x + w > width)
- w = width - x;
- if (y + h > height)
- h = height - y;
-
- if (w > 0 && h > 0)
- image.setRGB(x, y, w, h, pixels, off, scansize);
- }
- }
-
- public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize) {
- if (x < width && y < height) {
- if (x + w > width)
- w = width - x;
- if (y + h > height)
- h = height - y;
-
- if (w > 0 && h > 0)
- image.getRaster().setDataElements(x, y, w, h, pixels);
- }
- }
-
- public void setProperties(Hashtable props) {
- }
-
- public void setColorModel(ColorModel model) {
- }
-
- public void setHints(int hintflags) {
- }
-
- public void imageComplete(int status) {
- }
- }
-}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageGenerator.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageGenerator.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageGenerator.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,232 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Helma License Notice
- *
- * The contents of this file are subject to the Helma License
- * Version 2.0 (the "License"). You may not use this file except in
- * compliance with the License. A copy of the License is available at
- * http://adele.helma.org/download/helma/license.txt
- *
- * Copyright 1998-2003 Helma Software. All Rights Reserved.
- *
- * $RCSfile: ImageGenerator.java,v $
- * $Author: alexsmirnov $
- * $Revision: 1.1.2.1 $
- * $Date: 2007/01/09 18:59:06 $
- */
-
-package org.ajax4jsf.framework.util.image;
-
-import java.awt.Image;
-import java.awt.Toolkit;
-import java.awt.image.BufferedImage;
-import java.awt.image.BufferedImageOp;
-import java.awt.image.ImageFilter;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.ajax4jsf.Messages;
-
-/**
- * Factory class for generating Image objects from various sources.
- *
- */
-public abstract class ImageGenerator {
- protected static ImageGenerator generator = null;
-
- /**
- * Returns an ImageGenerator singleton, creating it if necessary. If the JIMI
- * package is installed, an instance of {@link helma.image.jimi.JimiGenerator JimiGenerator}
- * will be returned. Otherwise, if the javax.imageio package is available,
- * an instance of {@link helma.image.imageio.ImageIOGenerator ImageIOGenerator}
- * is returned. Additionally, the class of the ImageGenerator implementation
- * to be used can be set using the <code>imageGenerator</code> property in either
- * the app.properties or server.properties file.
- *
- * @return a new ImageGenerator instance
- */
- public static ImageGenerator getInstance() {
- if (generator == null) {
- // first see wether an image wrapper class was specified in
- // server.properties:
- String className = null;
-// if (Server.getServer() != null) {
-// className = Server.getServer().getProperty("imageGenerator");
-// }
-
- Class generatorClass = null;
- if (className == null) {
- // if no class is defined, try the default ones:
- try {
- Class.forName("com.sun.jimi.core.Jimi");
- // if we're still here, JimiWrapper can be used
- className = "helma.image.jimi.JimiGenerator";
- } catch (ClassNotFoundException e1) {
- try {
- Class.forName("javax.imageio.ImageIO");
- // if we're still here, ImageIOWrapper can be used
- className = "org.ajax4jsf.framework.util.image.imageio.ImageIOGenerator";
- } catch (ClassNotFoundException e2) {
- }
- }
- }
- // now let's get the generator class and create an instance:
- try {
- generatorClass = Class.forName(className);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(Messages.getMessage(Messages.IMAGE_GENERATOR_CLASS_NOT_FOUND, className));
- }
- try {
- generator = (ImageGenerator)generatorClass.newInstance();
- } catch (Exception e) {
- throw new RuntimeException(Messages.getMessage(Messages.CREATING_IMAGE_GENERATOR_ERROR, className));
- }
- }
- return generator;
- }
-
- /**
- * @param w ...
- * @param h ...
- *
- * @return ...
- */
- public ImageWrapper createImage(int w, int h) {
- BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
- return new ImageWrapper(img, w, h, this);
- }
-
- /**
- * @param src ...
- *
- * @return ...
- * @throws IOException
- */
- public ImageWrapper createImage(byte[] src) throws IOException {
- Image img = read(src);
- return img != null ? new ImageWrapper(img, this) : null;
- }
-
- /**
- * @param filenamne ...
- *
- * @return ...
- * @throws IOException
- */
- public ImageWrapper createImage(String filenamne)
- throws IOException {
- Image img = read(filenamne);
- return img != null ? new ImageWrapper(img, this) : null;
- }
-
- /**
- * @param url ...
- *
- * @return ...
- * @throws MalformedURLException
- * @throws IOException
- */
- public ImageWrapper createImage(URL url)
- throws MalformedURLException, IOException {
- Image img = read(url);
- return img != null ? new ImageWrapper(img, this) : null;
- }
-
- /**
- * @param iw ...
- * @param filter ...
- *
- * @return ...
- */
- public ImageWrapper createImage(ImageWrapper iw, ImageFilter filter) {
- // use the ImagFilterOp wrapper for ImageFilters that works directly
- // on BufferedImages. The filtering is much faster like that.
- // Attention: needs testing with all the filters!
-
- return createImage(iw, new ImageFilterOp(filter));
-// Image img = ImageWaiter.waitForImage(
-// Toolkit.getDefaultToolkit().createImage(
-// new FilteredImageSource(iw.getSource(), filter)));
-// return img != null ? new ImageWrapper(img, this) : null;
- }
-
- /**
- * @param iw ...
- * @param imageOp ...
- *
- * @return ...
- */
- public ImageWrapper createImage(ImageWrapper iw, BufferedImageOp imageOp) {
- Image img = imageOp.filter(iw.getBufferedImage(), null);
- return img != null ? new ImageWrapper(img, this) : null;
- }
-
- /**
- * @param filename the filename of the image to create
- *
- * @return the newly created image
- * @throws IOException
- */
- public Image read(String filename) throws IOException {
- return ImageWaiter.waitForImage(
- Toolkit.getDefaultToolkit().createImage(filename)
- );
- }
-
- /**
- * @param url the URL the filename of the image to create
- *
- * @return the newly created image
- * @throws IOException
- */
- public Image read(URL url) throws IOException {
- return ImageWaiter.waitForImage(
- Toolkit.getDefaultToolkit().createImage(url)
- );
- }
-
- /**
- * @param src the data of the image to create
- *
- * @return the newly created image
- * @throws IOException
- */
- public Image read(byte[] src) throws IOException {
- return ImageWaiter.waitForImage(
- Toolkit.getDefaultToolkit().createImage(src)
- );
- }
-
- /**
- * Saves the image. Image format is deduced from filename.
- *
- * @param wrapper
- * @param filename
- * @param quality
- * @param alpha
- * @throws IOException
- */
- public abstract void write(ImageWrapper wrapper, String filename,
- float quality, boolean alpha) throws IOException;
-}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageInfo.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageInfo.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageInfo.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,1309 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * ImageInfo.java
- *
- * Version 1.5
- *
- * A Java class to determine image width, height and color depth for
- * a number of image file formats.
- *
- * Written by Marco Schmidt
- * <http://www.geocities.com/marcoschmidt.geo/contact.html>.
- *
- * Contributed to the Public Domain.
- *
- * Last modification 2004-02-29
- */
-
-package org.ajax4jsf.framework.util.image;
-
-import java.io.DataInput;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Vector;
-
-import org.ajax4jsf.Messages;
-
-/**
- * Get file format, image resolution, number of bits per pixel and optionally
- * number of images, comments and physical resolution from
- * JPEG, GIF, BMP, PCX, PNG, IFF, RAS, PBM, PGM, PPM, PSD and SWF files
- * (or input streams).
- * <p>
- * Use the class like this:
- * <pre>
- * ImageInfo ii = new ImageInfo();
- * ii.setInput(in); // in can be InputStream or RandomAccessFile
- * ii.setDetermineImageNumber(true); // default is false
- * ii.setCollectComments(true); // default is false
- * if (!ii.check()) {
- * System.err.println("Not a supported image file format.");
- * return;
- * }
- * System.out.println(ii.getFormatName() + ", " + ii.getMimeType() +
- * ", " + ii.getWidth() + " x " + ii.getHeight() + " pixels, " +
- * ii.getBitsPerPixel() + " bits per pixel, " + ii.getNumberOfImages() +
- * " image(s), " + ii.getNumberOfComments() + " comment(s).");
- * // there are other properties, check out the API documentation
- * </pre>
- * You can also use this class as a command line program.
- * Call it with a number of image file names and URLs as parameters:
- * <pre>
- * java ImageInfo *.jpg *.png *.gif http://somesite.tld/image.jpg
- * </pre>
- * or call it without parameters and pipe data to it:
- * <pre>
- * java ImageInfo < image.jpg
- * </pre>
- * <p>
- * Known limitations:
- * <ul>
- * <li>When the determination of the number of images is turned off, GIF bits
- * per pixel are only read from the global header.
- * For some GIFs, local palettes change this to a typically larger
- * value. To be certain to get the correct color depth, call
- * setDetermineImageNumber(true) before calling check().
- * The complete scan over the GIF file will take additional time.</li>
- * <li>Transparency information is not included in the bits per pixel count.
- * Actually, it was my decision not to include those bits, so it's a feature! ;-)</li>
- * </ul>
- * <p>
- * Requirements:
- * <ul>
- * <li>Java 1.1 or higher</li>
- * </ul>
- * <p>
- * The latest version can be found at <a href="http://www.geocities.com/marcoschmidt.geo/image-info.html">http://www.geocities.com/marcoschmidt.geo/image-info.html</a>.
- * <p>
- * Written by <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">Marco Schmidt</a>.
- * <p>
- * This class is contributed to the Public Domain.
- * Use it at your own risk.
- * <p>
- * Last modification 2004-02-29.
- * <p>
- * History:
- * <ul>
- * <li><strong>2001-08-24</strong> Initial version.</li>
- * <li><strong>2001-10-13</strong> Added support for the file formats BMP and PCX.</li>
- * <li><strong>2001-10-16</strong> Fixed bug in read(int[], int, int) that returned
- * <li><strong>2002-01-22</strong> Added support for file formats Amiga IFF and Sun Raster (RAS).</li>
- * <li><strong>2002-01-24</strong> Added support for file formats Portable Bitmap / Graymap / Pixmap (PBM, PGM, PPM) and Adobe Photoshop (PSD).
- * Added new method getMimeType() to return the MIME type associated with a particular file format.</li>
- * <li><strong>2002-03-15</strong> Added support to recognize number of images in file. Only works with GIF.
- * Use {@link #setDetermineImageNumber} with <code>true</code> as argument to identify animated GIFs
- * ({@link #getNumberOfImages()} will return a value larger than <code>1</code>).</li>
- * <li><strong>2002-04-10</strong> Fixed a bug in the feature 'determine number of images in animated GIF' introduced with version 1.1.
- * Thanks to Marcelo P. Lima for sending in the bug report.
- * Released as 1.1.1.</li>
- * <li><strong>2002-04-18</strong> Added {@link #setCollectComments(boolean)}.
- * That new method lets the user specify whether textual comments are to be
- * stored in an internal list when encountered in an input image file / stream.
- * Added two methods to return the physical width and height of the image in dpi:
- * {@link #getPhysicalWidthDpi()} and {@link #getPhysicalHeightDpi()}.
- * If the physical resolution could not be retrieved, these methods return <code>-1</code>.
- * </li>
- * <li><strong>2002-04-23</strong> Added support for the new properties physical resolution and
- * comments for some formats. Released as 1.2.</li>
- * <li><strong>2002-06-17</strong> Added support for SWF, sent in by Michael Aird.
- * Changed checkJpeg() so that other APP markers than APP0 will not lead to a failure anymore.
- * Released as 1.3.</li>
- * <li><strong>2003-07-28</strong> Bug fix - skip method now takes return values into consideration.
- * Less bytes than necessary may have been skipped, leading to flaws in the retrieved information in some cases.
- * Thanks to Bernard Bernstein for pointing that out.
- * Released as 1.4.</li>
- * <li><strong>2004-02-29</strong> Added support for recognizing progressive JPEG and
- * interlaced PNG and GIF. A new method {@link #isProgressive()} returns whether ImageInfo
- * has found that the storage type is progressive (or interlaced).
- * Thanks to Joe Germuska for suggesting the feature.
- * Bug fix: BMP physical resolution is now correctly determined.
- * Released as 1.5.</li>
- * </ul>
- */
-public class ImageInfo {
- /**
- * Return value of {@link #getFormat()} for JPEG streams.
- * ImageInfo can extract physical resolution and comments
- * from JPEGs (only from APP0 headers).
- * Only one image can be stored in a file.
- * It is determined whether the JPEG stream is progressive
- * (see {@link #isProgressive()}).
- */
- public static final int FORMAT_JPEG = 0;
-
- /**
- * Return value of {@link #getFormat()} for GIF streams.
- * ImageInfo can extract comments from GIFs and count the number
- * of images (GIFs with more than one image are animations).
- * If you know of a place where GIFs store the physical resolution
- * of an image, please
- * <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">send me a mail</a>!
- * It is determined whether the GIF stream is interlaced (see {@link #isProgressive()}).
- */
- public static final int FORMAT_GIF = 1;
-
- /**
- * Return value of {@link #getFormat()} for PNG streams.
- * PNG only supports one image per file.
- * Both physical resolution and comments can be stored with PNG,
- * but ImageInfo is currently not able to extract those.
- * It is determined whether the PNG stream is interlaced (see {@link #isProgressive()}).
- */
- public static final int FORMAT_PNG = 2;
-
- /**
- * Return value of {@link #getFormat()} for BMP streams.
- * BMP only supports one image per file.
- * BMP does not allow for comments.
- * The physical resolution can be stored.
- */
- public static final int FORMAT_BMP = 3;
-
- /**
- * Return value of {@link #getFormat()} for PCX streams.
- * PCX does not allow for comments or more than one image per file.
- * However, the physical resolution can be stored.
- */
- public static final int FORMAT_PCX = 4;
-
- /**
- * Return value of {@link #getFormat()} for IFF streams.
- */
- public static final int FORMAT_IFF = 5;
-
- /**
- * Return value of {@link #getFormat()} for RAS streams.
- * Sun Raster allows for one image per file only and is not able to
- * store physical resolution or comments.
- */
- public static final int FORMAT_RAS = 6;
-
- /** Return value of {@link #getFormat()} for PBM streams. */
- public static final int FORMAT_PBM = 7;
-
- /** Return value of {@link #getFormat()} for PGM streams. */
- public static final int FORMAT_PGM = 8;
-
- /** Return value of {@link #getFormat()} for PPM streams. */
- public static final int FORMAT_PPM = 9;
-
- /** Return value of {@link #getFormat()} for PSD streams. */
- public static final int FORMAT_PSD = 10;
-
- /** Return value of {@link #getFormat()} for SWF (Shockwave) streams. */
- public static final int FORMAT_SWF = 11;
-
- public static final int COLOR_TYPE_UNKNOWN = -1;
- public static final int COLOR_TYPE_TRUECOLOR_RGB = 0;
- public static final int COLOR_TYPE_PALETTED = 1;
- public static final int COLOR_TYPE_GRAYSCALE= 2;
- public static final int COLOR_TYPE_BLACK_AND_WHITE = 3;
-
- /**
- * The names of all supported file formats.
- * The FORMAT_xyz int constants can be used as index values for
- * this array.
- */
- private static final String[] FORMAT_NAMES =
- {"JPEG", "GIF", "PNG", "BMP", "PCX",
- "IFF", "RAS", "PBM", "PGM", "PPM",
- "PSD", "SWF"};
-
- /**
- * The names of the MIME types for all supported file formats.
- * The FORMAT_xyz int constants can be used as index values for
- * this array.
- */
- private static final String[] MIME_TYPE_STRINGS =
- {"image/jpeg", "image/gif", "image/png", "image/bmp", "image/pcx",
- "image/iff", "image/ras", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap",
- "image/psd", "application/x-shockwave-flash"};
-
- private int width;
- private int height;
- private int bitsPerPixel;
- private int colorType = COLOR_TYPE_UNKNOWN;
- private boolean progressive;
- private int format;
- private InputStream in;
- private DataInput din;
- private boolean collectComments = true;
- private Vector comments;
- private boolean determineNumberOfImages;
- private int numberOfImages;
- private int physicalHeightDpi;
- private int physicalWidthDpi;
- private int bitBuf;
- private int bitPos;
-
- private void addComment(String s) {
- if (comments == null) {
- comments = new Vector();
- }
- comments.addElement(s);
- }
-
- /**
- * Call this method after you have provided an input stream or file
- * using {@link #setInput(InputStream)} or {@link #setInput(DataInput)}.
- * If true is returned, the file format was known and information
- * on the file's content can be retrieved using the various getXyz methods.
- * @return if information could be retrieved from input
- */
- public boolean check() {
- format = -1;
- width = -1;
- height = -1;
- bitsPerPixel = -1;
- numberOfImages = 1;
- physicalHeightDpi = -1;
- physicalWidthDpi = -1;
- comments = null;
- try {
- int b1 = read() & 0xff;
- int b2 = read() & 0xff;
- if (b1 == 0x47 && b2 == 0x49) {
- return checkGif();
- }
- else
- if (b1 == 0x89 && b2 == 0x50) {
- return checkPng();
- }
- else
- if (b1 == 0xff && b2 == 0xd8) {
- return checkJpeg();
- }
- else
- if (b1 == 0x42 && b2 == 0x4d) {
- return checkBmp();
- }
- else
- if (b1 == 0x0a && b2 < 0x06) {
- return checkPcx();
- }
- else
- if (b1 == 0x46 && b2 == 0x4f) {
- return checkIff();
- }
- else
- if (b1 == 0x59 && b2 == 0xa6) {
- return checkRas();
- }
- else
- if (b1 == 0x50 && b2 >= 0x31 && b2 <= 0x36) {
- return checkPnm(b2 - '0');
- }
- else
- if (b1 == 0x38 && b2 == 0x42) {
- return checkPsd();
- }
- else
- if (b1 == 0x46 && b2 == 0x57) {
- return checkSwf();
- }
- else {
- return false;
- }
- } catch (IOException ioe) {
- return false;
- }
- }
-
- private boolean checkBmp() throws IOException {
- byte[] a = new byte[44];
- if (read(a) != a.length) {
- return false;
- }
- width = getIntLittleEndian(a, 16);
- height = getIntLittleEndian(a, 20);
- if (width < 1 || height < 1) {
- return false;
- }
- bitsPerPixel = getShortLittleEndian(a, 26);
- if (bitsPerPixel != 1 && bitsPerPixel != 4 &&
- bitsPerPixel != 8 && bitsPerPixel != 16 &&
- bitsPerPixel != 24 && bitsPerPixel != 32) {
- return false;
- }
- int x = (int)(getIntLittleEndian(a, 36) * 0.0254);
- if (x > 0) {
- setPhysicalWidthDpi(x);
- }
- int y = (int)(getIntLittleEndian(a, 40) * 0.0254);
- if (y > 0) {
- setPhysicalHeightDpi(y);
- }
- format = FORMAT_BMP;
- return true;
- }
-
- private boolean checkGif() throws IOException {
- final byte[] GIF_MAGIC_87A = {0x46, 0x38, 0x37, 0x61};
- final byte[] GIF_MAGIC_89A = {0x46, 0x38, 0x39, 0x61};
- byte[] a = new byte[11]; // 4 from the GIF signature + 7 from the global header
- if (read(a) != 11) {
- return false;
- }
- if ((!equals(a, 0, GIF_MAGIC_89A, 0, 4)) &&
- (!equals(a, 0, GIF_MAGIC_87A, 0, 4))) {
- return false;
- }
- format = FORMAT_GIF;
- width = getShortLittleEndian(a, 4);
- height = getShortLittleEndian(a, 6);
- int flags = a[8] & 0xff;
- bitsPerPixel = ((flags >> 4) & 0x07) + 1;
- progressive = (flags & 0x02) != 0;
- if (!determineNumberOfImages) {
- return true;
- }
- // skip global color palette
- if ((flags & 0x80) != 0) {
- int tableSize = (1 << ((flags & 7) + 1)) * 3;
- skip(tableSize);
- }
- numberOfImages = 0;
- int blockType;
- do
- {
- blockType = read();
- switch(blockType)
- {
- case(0x2c): // image separator
- {
- if (read(a, 0, 9) != 9) {
- return false;
- }
- flags = a[8] & 0xff;
- int localBitsPerPixel = (flags & 0x07) + 1;
- if (localBitsPerPixel > bitsPerPixel) {
- bitsPerPixel = localBitsPerPixel;
- }
- if ((flags & 0x80) != 0) {
- skip((1 << localBitsPerPixel) * 3);
- }
- skip(1); // initial code length
- int n;
- do
- {
- n = read();
- if (n > 0) {
- skip(n);
- }
- else
- if (n == -1) {
- return false;
- }
- }
- while (n > 0);
- numberOfImages++;
- break;
- }
- case(0x21): // extension
- {
- int extensionType = read();
- if (collectComments && extensionType == 0xfe) {
- StringBuffer sb = new StringBuffer();
- int n;
- do
- {
- n = read();
- if (n == -1) {
- return false;
- }
- if (n > 0) {
- for (int i = 0; i < n; i++) {
- int ch = read();
- if (ch == -1) {
- return false;
- }
- sb.append((char)ch);
- }
- }
- }
- while (n > 0);
- } else {
- int n;
- do
- {
- n = read();
- if (n > 0) {
- skip(n);
- }
- else
- if (n == -1) {
- return false;
- }
- }
- while (n > 0);
- }
- break;
- }
- case(0x3b): // end of file
- {
- break;
- }
- default:
- {
- return false;
- }
- }
- }
- while (blockType != 0x3b);
- return true;
- }
-
- private boolean checkIff() throws IOException {
- byte[] a = new byte[10];
- // read remaining 2 bytes of file id, 4 bytes file size
- // and 4 bytes IFF subformat
- if (read(a, 0, 10) != 10) {
- return false;
- }
- final byte[] IFF_RM = {0x52, 0x4d};
- if (!equals(a, 0, IFF_RM, 0, 2)) {
- return false;
- }
- int type = getIntBigEndian(a, 6);
- if (type != 0x494c424d && // type must be ILBM...
- type != 0x50424d20) { // ...or PBM
- return false;
- }
- // loop chunks to find BMHD chunk
- do {
- if (read(a, 0, 8) != 8) {
- return false;
- }
- int chunkId = getIntBigEndian(a, 0);
- int size = getIntBigEndian(a, 4);
- if ((size & 1) == 1) {
- size++;
- }
- if (chunkId == 0x424d4844) { // BMHD chunk
- if (read(a, 0, 9) != 9) {
- return false;
- }
- format = FORMAT_IFF;
- width = getShortBigEndian(a, 0);
- height = getShortBigEndian(a, 2);
- bitsPerPixel = a[8] & 0xff;
- return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel < 33);
- } else {
- skip(size);
- }
- } while (true);
- }
-
- private boolean checkJpeg() throws IOException {
- byte[] data = new byte[12];
- while (true) {
- if (read(data, 0, 4) != 4) {
- return false;
- }
- int marker = getShortBigEndian(data, 0);
- int size = getShortBigEndian(data, 2);
- if ((marker & 0xff00) != 0xff00) {
- return false; // not a valid marker
- }
- if (marker == 0xffe0) { // APPx
- if (size < 14) {
- return false; // APPx header must be >= 14 bytes
- }
- if (read(data, 0, 12) != 12) {
- return false;
- }
- final byte[] APP0_ID = {0x4a, 0x46, 0x49, 0x46, 0x00};
- if (equals(APP0_ID, 0, data, 0, 5)) {
- //System.out.println("data 7=" + data[7]);
- if (data[7] == 1) {
- setPhysicalWidthDpi(getShortBigEndian(data, 8));
- setPhysicalHeightDpi(getShortBigEndian(data, 10));
- }
- else
- if (data[7] == 2) {
- int x = getShortBigEndian(data, 8);
- int y = getShortBigEndian(data, 10);
- setPhysicalWidthDpi((int)(x * 2.54f));
- setPhysicalHeightDpi((int)(y * 2.54f));
- }
- }
- skip(size - 14);
- }
- else
- if (collectComments && size > 2 && marker == 0xfffe) { // comment
- size -= 2;
- byte[] chars = new byte[size];
- if (read(chars, 0, size) != size) {
- return false;
- }
- String comment = new String(chars, "iso-8859-1");
- comment = comment.trim();
- addComment(comment);
- }
- else
- if (marker >= 0xffc0 && marker <= 0xffcf && marker != 0xffc4 && marker != 0xffc8) {
- if (read(data, 0, 6) != 6) {
- return false;
- }
- format = FORMAT_JPEG;
- bitsPerPixel = (data[0] & 0xff) * (data[5] & 0xff);
- progressive = marker == 0xffc2 || marker == 0xffc6 ||
- marker == 0xffca || marker == 0xffce;
- width = getShortBigEndian(data, 3);
- height = getShortBigEndian(data, 1);
- return true;
- } else {
- skip(size - 2);
- }
- }
- }
-
- private boolean checkPcx() throws IOException {
- byte[] a = new byte[64];
- if (read(a) != a.length) {
- return false;
- }
- if (a[0] != 1) { // encoding, 1=RLE is only valid value
- return false;
- }
- // width / height
- int x1 = getShortLittleEndian(a, 2);
- int y1 = getShortLittleEndian(a, 4);
- int x2 = getShortLittleEndian(a, 6);
- int y2 = getShortLittleEndian(a, 8);
- if (x1 < 0 || x2 < x1 || y1 < 0 || y2 < y1) {
- return false;
- }
- width = x2 - x1 + 1;
- height = y2 - y1 + 1;
- // color depth
- int bits = a[1];
- int planes = a[63];
- if (planes == 1 &&
- (bits == 1 || bits == 2 || bits == 4 || bits == 8)) {
- // paletted
- bitsPerPixel = bits;
- } else
- if (planes == 3 && bits == 8) {
- // RGB truecolor
- bitsPerPixel = 24;
- } else {
- return false;
- }
- setPhysicalWidthDpi(getShortLittleEndian(a, 10));
- setPhysicalHeightDpi(getShortLittleEndian(a, 10));
- format = FORMAT_PCX;
- return true;
- }
-
- private boolean checkPng() throws IOException {
- final byte[] PNG_MAGIC = {0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a};
- byte[] a = new byte[27];
- if (read(a) != 27) {
- return false;
- }
- if (!equals(a, 0, PNG_MAGIC, 0, 6)) {
- return false;
- }
- format = FORMAT_PNG;
- width = getIntBigEndian(a, 14);
- height = getIntBigEndian(a, 18);
- bitsPerPixel = a[22] & 0xff;
- int colorType = a[23] & 0xff;
- if (colorType == 2 || colorType == 6) {
- bitsPerPixel *= 3;
- }
- progressive = (a[26] & 0xff) != 0;
- return true;
- }
-
- private boolean checkPnm(int id) throws IOException {
- if (id < 1 || id > 6) {
- return false;
- }
- final int[] PNM_FORMATS = {FORMAT_PBM, FORMAT_PGM, FORMAT_PPM};
- format = PNM_FORMATS[(id - 1) % 3];
- boolean hasPixelResolution = false;
- String s;
- while (true)
- {
- s = readLine();
- if (s != null) {
- s = s.trim();
- }
- if (s == null || s.length() < 1) {
- continue;
- }
- if (s.charAt(0) == '#') { // comment
- if (collectComments && s.length() > 1) {
- addComment(s.substring(1));
- }
- continue;
- }
- if (!hasPixelResolution) { // split "343 966" into width=343, height=966
- int spaceIndex = s.indexOf(' ');
- if (spaceIndex == -1) {
- return false;
- }
- String widthString = s.substring(0, spaceIndex);
- spaceIndex = s.lastIndexOf(' ');
- if (spaceIndex == -1) {
- return false;
- }
- String heightString = s.substring(spaceIndex + 1);
- try {
- width = Integer.parseInt(widthString);
- height = Integer.parseInt(heightString);
- } catch (NumberFormatException nfe) {
- return false;
- }
- if (width < 1 || height < 1) {
- return false;
- }
- if (format == FORMAT_PBM) {
- bitsPerPixel = 1;
- return true;
- }
- hasPixelResolution = true;
- }
- else
- {
- int maxSample;
- try {
- maxSample = Integer.parseInt(s);
- } catch (NumberFormatException nfe) {
- return false;
- }
- if (maxSample < 0) {
- return false;
- }
- for (int i = 0; i < 25; i++) {
- if (maxSample < (1 << (i + 1))) {
- bitsPerPixel = i + 1;
- if (format == FORMAT_PPM) {
- bitsPerPixel *= 3;
- }
- return true;
- }
- }
- return false;
- }
- }
- }
-
- private boolean checkPsd() throws IOException {
- byte[] a = new byte[24];
- if (read(a) != a.length) {
- return false;
- }
- final byte[] PSD_MAGIC = {0x50, 0x53};
- if (!equals(a, 0, PSD_MAGIC, 0, 2)) {
- return false;
- }
- format = FORMAT_PSD;
- width = getIntBigEndian(a, 16);
- height = getIntBigEndian(a, 12);
- int channels = getShortBigEndian(a, 10);
- int depth = getShortBigEndian(a, 20);
- bitsPerPixel = channels * depth;
- return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel <= 64);
- }
-
- private boolean checkRas() throws IOException {
- byte[] a = new byte[14];
- if (read(a) != a.length) {
- return false;
- }
- final byte[] RAS_MAGIC = {0x6a, (byte)0x95};
- if (!equals(a, 0, RAS_MAGIC, 0, 2)) {
- return false;
- }
- format = FORMAT_RAS;
- width = getIntBigEndian(a, 2);
- height = getIntBigEndian(a, 6);
- bitsPerPixel = getIntBigEndian(a, 10);
- return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel <= 24);
- }
-
- // Written by Michael Aird.
- private boolean checkSwf() throws IOException {
- //get rid of the last byte of the signature, the byte of the version and 4 bytes of the size
- byte[] a = new byte[6];
- if (read(a) != a.length) {
- return false;
- }
- format = FORMAT_SWF;
- int bitSize = (int)readUBits( 5 );
- int minX = (int)readSBits( bitSize );
- int maxX = (int)readSBits( bitSize );
- int minY = (int)readSBits( bitSize );
- int maxY = (int)readSBits( bitSize );
- width = maxX/20; //cause we're in twips
- height = maxY/20; //cause we're in twips
- setPhysicalWidthDpi(72);
- setPhysicalHeightDpi(72);
- return (width > 0 && height > 0);
- }
-
- /**
- * Run over String list, return false iff at least one of the arguments
- * equals <code>-c</code>.
- */
- private static boolean determineVerbosity(String[] args) {
- if (args != null && args.length > 0) {
- for (int i = 0; i < args.length; i++) {
- if ("-c".equals(args[i])) {
- return false;
- }
- }
- }
- return true;
- }
-
- private boolean equals(byte[] a1, int offs1, byte[] a2, int offs2, int num) {
- while (num-- > 0) {
- if (a1[offs1++] != a2[offs2++]) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * If {@link #check()} was successful, returns the image's number of bits per pixel.
- * Does not include transparency information like the alpha channel.
- * @return number of bits per image pixel
- */
- public int getBitsPerPixel() {
- return bitsPerPixel;
- }
-
- /**
- * Returns the index'th comment retrieved from the image.
- * @throws IllegalArgumentException if index is smaller than 0 or larger than or equal
- * to the number of comments retrieved
- * @see #getNumberOfComments
- */
- public String getComment(int index) {
- if (comments == null || index < 0 || index >= comments.size()) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.INVALID_COMMENT_INDEX, "" + index));
- }
- return (String)comments.elementAt(index);
- }
-
- /**
- * If {@link #check()} was successful, returns the image format as one
- * of the FORMAT_xyz constants from this class.
- * Use {@link #getFormatName()} to get a textual description of the file format.
- * @return file format as a FORMAT_xyz constant
- */
- public int getFormat() {
- return format;
- }
-
- /**
- * If {@link #check()} was successful, returns the image format's name.
- * Use {@link #getFormat()} to get a unique number.
- * @return file format name
- */
- public String getFormatName() {
- if (format >= 0 && format < FORMAT_NAMES.length) {
- return FORMAT_NAMES[format];
- } else {
- return "?";
- }
- }
-
- /**
- * If {@link #check()} was successful, returns one the image's vertical
- * resolution in pixels.
- * @return image height in pixels
- */
- public int getHeight() {
- return height;
- }
-
- private int getIntBigEndian(byte[] a, int offs) {
- return
- (a[offs] & 0xff) << 24 |
- (a[offs + 1] & 0xff) << 16 |
- (a[offs + 2] & 0xff) << 8 |
- a[offs + 3] & 0xff;
- }
-
- private int getIntLittleEndian(byte[] a, int offs) {
- return
- (a[offs + 3] & 0xff) << 24 |
- (a[offs + 2] & 0xff) << 16 |
- (a[offs + 1] & 0xff) << 8 |
- a[offs] & 0xff;
- }
-
- /**
- * If {@link #check()} was successful, returns a String with the
- * MIME type of the format.
- * @return MIME type, e.g. <code>image/jpeg</code>
- */
- public String getMimeType() {
- if (format >= 0 && format < MIME_TYPE_STRINGS.length) {
- if (format == FORMAT_JPEG && progressive)
- {
- return "image/pjpeg";
- }
- return MIME_TYPE_STRINGS[format];
- } else {
- return null;
- }
- }
-
- /**
- * If {@link #check()} was successful and {@link #setCollectComments(boolean)} was called with
- * <code>true</code> as argument, returns the number of comments retrieved
- * from the input image stream / file.
- * Any number >= 0 and smaller than this number of comments is then a
- * valid argument for the {@link #getComment(int)} method.
- * @return number of comments retrieved from input image
- */
- public int getNumberOfComments()
- {
- if (comments == null) {
- return 0;
- } else {
- return comments.size();
- }
- }
-
- /**
- * Returns the number of images in the examined file.
- * Assumes that <code>setDetermineImageNumber(true);</code> was called before
- * a successful call to {@link #check()}.
- * This value can currently be only different from <code>1</code> for GIF images.
- * @return number of images in file
- */
- public int getNumberOfImages()
- {
- return numberOfImages;
- }
-
- /**
- * Returns the physical height of this image in dots per inch (dpi).
- * Assumes that {@link #check()} was successful.
- * Returns <code>-1</code> on failure.
- * @return physical height (in dpi)
- * @see #getPhysicalWidthDpi()
- * @see #getPhysicalHeightInch()
- */
- public int getPhysicalHeightDpi() {
- return physicalHeightDpi;
- }
-
- /**
- * If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
- * or -1 if no value could be found.
- * @return physical height (in dpi)
- * @see #getPhysicalHeightDpi()
- * @see #getPhysicalWidthDpi()
- * @see #getPhysicalWidthInch()
- */
- public float getPhysicalHeightInch() {
- int h = getHeight();
- int ph = getPhysicalHeightDpi();
- if (h > 0 && ph > 0) {
- return ((float)h) / ((float)ph);
- } else {
- return -1.0f;
- }
- }
-
- /**
- * If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
- * or -1 if no value could be found.
- * @return physical width (in dpi)
- * @see #getPhysicalHeightDpi()
- * @see #getPhysicalWidthInch()
- * @see #getPhysicalHeightInch()
- */
- public int getPhysicalWidthDpi() {
- return physicalWidthDpi;
- }
-
- /**
- * Returns the physical width of an image in inches, or
- * <code>-1.0f</code> if width information is not available.
- * Assumes that {@link #check} has been called successfully.
- * @return physical width in inches or <code>-1.0f</code> on failure
- * @see #getPhysicalWidthDpi
- * @see #getPhysicalHeightInch
- */
- public float getPhysicalWidthInch() {
- int w = getWidth();
- int pw = getPhysicalWidthDpi();
- if (w > 0 && pw > 0) {
- return ((float)w) / ((float)pw);
- } else {
- return -1.0f;
- }
- }
-
- private int getShortBigEndian(byte[] a, int offs) {
- return
- (a[offs] & 0xff) << 8 |
- (a[offs + 1] & 0xff);
- }
-
- private int getShortLittleEndian(byte[] a, int offs) {
- return (a[offs] & 0xff) | (a[offs + 1] & 0xff) << 8;
- }
-
- /**
- * If {@link #check()} was successful, returns one the image's horizontal
- * resolution in pixels.
- * @return image width in pixels
- */
- public int getWidth() {
- return width;
- }
-
- /**
- * Returns whether the image is stored in a progressive (also called: interlaced) way.
- * @return true for progressive/interlaced, false otherwise
- */
- public boolean isProgressive()
- {
- return progressive;
- }
-
- /**
- * To use this class as a command line application, give it either
- * some file names as parameters (information on them will be
- * printed to standard output, one line per file) or call
- * it with no parameters. It will then check data given to it
- * via standard input.
- * @param args the program arguments which must be file names
- */
- public static void main(String[] args) {
- ImageInfo imageInfo = new ImageInfo();
- imageInfo.setDetermineImageNumber(true);
- boolean verbose = determineVerbosity(args);
- if (args.length == 0) {
- run(null, System.in, imageInfo, verbose);
- } else {
- int index = 0;
- while (index < args.length) {
- InputStream in = null;
- try {
- String name = args[index++];
- System.out.print(name + ";");
- if (name.startsWith("http://")) {
- in = new URL(name).openConnection().getInputStream();
- } else {
- in = new FileInputStream(name);
- }
- run(name, in, imageInfo, verbose);
- in.close();
- } catch (Exception e) {
- System.out.println(e);
- try {
- in.close();
- } catch (Exception ee) {
- }
- }
- }
- }
- }
-
- private static void print(String sourceName, ImageInfo ii, boolean verbose) {
- if (verbose) {
- printVerbose(sourceName, ii);
- } else {
- printCompact(sourceName, ii);
- }
- }
-
- private static void printCompact(String sourceName, ImageInfo imageInfo) {
- System.out.println(
- imageInfo.getFormatName() + ";" +
- imageInfo.getMimeType() + ";" +
- imageInfo.getWidth() + ";" +
- imageInfo.getHeight() + ";" +
- imageInfo.getBitsPerPixel() + ";" +
- imageInfo.getNumberOfImages() + ";" +
- imageInfo.getPhysicalWidthDpi() + ";" +
- imageInfo.getPhysicalHeightDpi() + ";" +
- imageInfo.getPhysicalWidthInch() + ";" +
- imageInfo.getPhysicalHeightInch() + ";" +
- imageInfo.isProgressive()
- );
- }
-
- private static void printLine(int indentLevels, String text, float value, float minValidValue) {
- if (value < minValidValue) {
- return;
- }
- printLine(indentLevels, text, Float.toString(value));
- }
-
- private static void printLine(int indentLevels, String text, int value, int minValidValue) {
- if (value >= minValidValue) {
- printLine(indentLevels, text, Integer.toString(value));
- }
- }
-
- private static void printLine(int indentLevels, String text, String value) {
- if (value == null || value.length() == 0) {
- return;
- }
- while (indentLevels-- > 0) {
- System.out.print("\t");
- }
- if (text != null && text.length() > 0) {
- System.out.print(text);
- System.out.print(" ");
- }
- System.out.println(value);
- }
-
- private static void printVerbose(String sourceName, ImageInfo ii) {
- printLine(0, null, sourceName);
- printLine(1, "File format: ", ii.getFormatName());
- printLine(1, "MIME type: ", ii.getMimeType());
- printLine(1, "Width (pixels): ", ii.getWidth(), 1);
- printLine(1, "Height (pixels): ", ii.getHeight(), 1);
- printLine(1, "Bits per pixel: ", ii.getBitsPerPixel(), 1);
- printLine(1, "Progressive: ", Boolean.toString(ii.isProgressive()));
- printLine(1, "Number of images: ", ii.getNumberOfImages(), 1);
- printLine(1, "Physical width (dpi): ", ii.getPhysicalWidthDpi(), 1);
- printLine(1, "Physical height (dpi): ", ii.getPhysicalHeightDpi(), 1);
- printLine(1, "Physical width (inches): ", ii.getPhysicalWidthInch(), 1.0f);
- printLine(1, "Physical height (inches): ", ii.getPhysicalHeightInch(), 1.0f);
- int numComments = ii.getNumberOfComments();
- printLine(1, "Number of textual comments: ", numComments, 1);
- if (numComments > 0) {
- for (int i = 0; i < numComments; i++) {
- printLine(2, null, ii.getComment(i));
- }
- }
- }
-
- private int read() throws IOException {
- if (in != null) {
- return in.read();
- } else {
- return din.readByte();
- }
- }
-
- private int read(byte[] a) throws IOException {
- if (in != null) {
- return in.read(a);
- } else {
- din.readFully(a);
- return a.length;
- }
- }
-
- private int read(byte[] a, int offset, int num) throws IOException {
- if (in != null) {
- return in.read(a, offset, num);
- } else {
- din.readFully(a, offset, num);
- return num;
- }
- }
-
- private String readLine() throws IOException {
- return readLine(new StringBuffer());
- }
-
- private String readLine(StringBuffer sb) throws IOException {
- boolean finished;
- do {
- int value = read();
- finished = (value == -1 || value == 10);
- if (!finished) {
- sb.append((char)value);
- }
- } while (!finished);
- return sb.toString();
- }
-
- private long readUBits( int numBits ) throws IOException
- {
- if (numBits == 0) {
- return 0;
- }
- int bitsLeft = numBits;
- long result = 0;
- if (bitPos == 0) { //no value in the buffer - read a byte
- if (in != null) {
- bitBuf = in.read();
- } else {
- bitBuf = din.readByte();
- }
- bitPos = 8;
- }
-
- while( true )
- {
- int shift = bitsLeft - bitPos;
- if( shift > 0 )
- {
- // Consume the entire buffer
- result |= bitBuf << shift;
- bitsLeft -= bitPos;
-
- // Get the next byte from the input stream
- if (in != null) {
- bitBuf = in.read();
- } else {
- bitBuf = din.readByte();
- }
- bitPos = 8;
- }
- else
- {
- // Consume a portion of the buffer
- result |= bitBuf >> -shift;
- bitPos -= bitsLeft;
- bitBuf &= 0xff >> (8 - bitPos); // mask off the consumed bits
-
- return result;
- }
- }
- }
-
- /**
- * Read a signed value from the given number of bits
- */
- private int readSBits( int numBits ) throws IOException
- {
- // Get the number as an unsigned value.
- long uBits = readUBits( numBits );
-
- // Is the number negative?
- if( ( uBits & (1L << (numBits - 1))) != 0 )
- {
- // Yes. Extend the sign.
- uBits |= -1L << numBits;
- }
-
- return (int)uBits;
- }
-
- private void synchBits()
- {
- bitBuf = 0;
- bitPos = 0;
- }
-
- private String readLine(int firstChar) throws IOException {
- StringBuffer result = new StringBuffer();
- result.append((char)firstChar);
- return readLine(result);
- }
-
- private static void run(String sourceName, InputStream in, ImageInfo imageInfo, boolean verbose) {
- imageInfo.setInput(in);
- imageInfo.setDetermineImageNumber(false);
- imageInfo.setCollectComments(verbose);
- if (imageInfo.check()) {
- print(sourceName, imageInfo, verbose);
- }
- }
-
- /**
- * Specify whether textual comments are supposed to be extracted from input.
- * Default is <code>false</code>.
- * If enabled, comments will be added to an internal list.
- * @param newValue if <code>true</code>, this class will read comments
- * @see #getNumberOfComments
- * @see #getComment
- */
- public void setCollectComments(boolean newValue)
- {
- collectComments = newValue;
- }
-
- /**
- * Specify whether the number of images in a file is to be
- * determined - default is <code>false</code>.
- * This is a special option because some file formats require running over
- * the entire file to find out the number of images, a rather time-consuming
- * task.
- * Not all file formats support more than one image.
- * If this method is called with <code>true</code> as argument,
- * the actual number of images can be queried via
- * {@link #getNumberOfImages()} after a successful call to
- * {@link #check()}.
- * @param newValue will the number of images be determined?
- * @see #getNumberOfImages
- */
- public void setDetermineImageNumber(boolean newValue)
- {
- determineNumberOfImages = newValue;
- }
-
- /**
- * Set the input stream to the argument stream (or file).
- * Note that {@link java.io.RandomAccessFile} implements
- * {@link java.io.DataInput}.
- * @param dataInput the input stream to read from
- */
- public void setInput(DataInput dataInput) {
- din = dataInput;
- in = null;
- }
-
- /**
- * Set the input stream to the argument stream (or file).
- * @param inputStream the input stream to read from
- */
- public void setInput(InputStream inputStream) {
- in = inputStream;
- din = null;
- }
-
- private void setPhysicalHeightDpi(int newValue) {
- physicalWidthDpi = newValue;
- }
-
- private void setPhysicalWidthDpi(int newValue) {
- physicalHeightDpi = newValue;
- }
-
- private void skip(int num) throws IOException {
- while (num > 0) {
- long result;
- if (in != null) {
- result = in.skip(num);
- } else {
- result = din.skipBytes(num);
- }
- if (result > 0) {
- num -= result;
- }
- }
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageWaiter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageWaiter.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageWaiter.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,133 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Helma License Notice
- *
- * The contents of this file are subject to the Helma License
- * Version 2.0 (the "License"). You may not use this file except in
- * compliance with the License. A copy of the License is available at
- * http://adele.helma.org/download/helma/license.txt
- *
- * Copyright 1998-2003 Helma Software. All Rights Reserved.
- *
- * $RCSfile: ImageWaiter.java,v $
- * $Author: alexsmirnov $
- * $Revision: 1.1.2.1 $
- * $Date: 2007/01/09 18:59:07 $
- */
-
-package org.ajax4jsf.framework.util.image;
-
-import java.awt.Image;
-import java.awt.image.ImageObserver;
-
-import org.ajax4jsf.Messages;
-
-/**
- * The ImageWaiter will only be used like this:
- * image = ImageWaiter.waitForImage(image);
- */
-public class ImageWaiter implements ImageObserver {
- Image image;
- int width;
- int height;
- boolean waiting;
- boolean firstFrameLoaded;
-
- private ImageWaiter(Image image) {
- this.image = image;
- waiting = true;
- firstFrameLoaded = false;
- }
-
- public static Image waitForImage(Image image) {
- ImageWaiter waiter = new ImageWaiter(image);
- try {
- waiter.waitForImage();
- } finally {
- waiter.done();
- }
- return waiter.width == -1 || waiter.height == -1 ? null : image;
- }
-
- private synchronized void waitForImage() {
- width = image.getWidth(this);
- height = image.getHeight(this);
-
- if (width == -1 || height == -1) {
- try {
- wait(45000);
- } catch (InterruptedException x) {
- waiting = false;
- return;
- } finally {
- waiting = false;
- }
- }
-
- // if width and height haven't been set, throw tantrum
- if (width == -1 || height == -1) {
- throw new RuntimeException(Messages.getMessage(Messages.LOADING_IMAGE_ERROR));
- }
- }
-
- private synchronized void done() {
- waiting = false;
- notifyAll();
- }
-
- public synchronized boolean imageUpdate(Image img, int infoflags, int x,
- int y, int w, int h) {
- // check if there was an error
- if (!waiting || (infoflags & ERROR) > 0 || (infoflags & ABORT) > 0) {
- // we either timed out or there was an error.
- notifyAll();
-
- return false;
- }
-
- if ((infoflags & WIDTH) > 0 || (infoflags & HEIGHT) > 0) {
- if ((infoflags & WIDTH) > 0) {
- width = w;
- }
-
- if ((infoflags & HEIGHT) > 0) {
- height = h;
- }
-
- if (width > -1 && h > -1 && firstFrameLoaded) {
- notifyAll();
-
- return false;
- }
- }
-
- if ((infoflags & ALLBITS) > 0 || (infoflags & FRAMEBITS) > 0) {
- firstFrameLoaded = true;
- notifyAll();
-
- return false;
- }
-
- return true;
- }
-}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageWrapper.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageWrapper.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/ImageWrapper.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,531 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Helma License Notice
- *
- * The contents of this file are subject to the Helma License
- * Version 2.0 (the "License"). You may not use this file except in
- * compliance with the License. A copy of the License is available at
- * http://adele.helma.org/download/helma/license.txt
- *
- * Copyright 1998-2003 Helma Software. All Rights Reserved.
- *
- * $RCSfile: ImageWrapper.java,v $
- * $Author: alexsmirnov $
- * $Revision: 1.1.2.1 $
- * $Date: 2007/01/09 18:59:05 $
- */
-
-/*
- * A few explanations:
- *
- * - this.image is either an AWT Image or a BufferedImage.
- * It depends on the ImageGenerator in what form the Image initially is.
- * (the ImageIO implementation only uses BufferedImages for example.)
- *
- * As soon as some action that needs the graphics object is performed and the
- * image is still in AWT format, it is converted to a BufferedImage
- *
- * Any internal function that performs graphical actions needs to call
- * getGraphics, never rely on this.graphics being set correctly!
- *
- * - ImageWrapper objects are created and safed by the ImageGenerator class
- * all different implementations of Imaging functionallity are implemented
- * as a ImageGenerator extending class.
- *
- */
-
-package org.ajax4jsf.framework.util.image;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.Image;
-import java.awt.RenderingHints;
-import java.awt.geom.AffineTransform;
-import java.awt.image.AreaAveragingScaleFilter;
-import java.awt.image.BufferedImage;
-import java.awt.image.ColorModel;
-import java.awt.image.ImageProducer;
-import java.awt.image.IndexColorModel;
-import java.io.IOException;
-
-import org.ajax4jsf.Messages;
-
-/**
- * Abstract base class for Image Wrappers.
- */
-public class ImageWrapper {
- protected Image image;
- protected int width;
- protected int height;
- protected ImageGenerator generator;
- private Graphics2D graphics;
-
- /**
- * Creates a new ImageWrapper object.
- *
- * @param image ...
- * @param width ...
- * @param height ...
- */
- public ImageWrapper(Image image, int width, int height,
- ImageGenerator generator) {
- this.image = image;
- this.width = width;
- this.height = height;
- this.generator = generator;
- // graphics are turned off by default. getGraphics activates it if necessary.
- this.graphics = null;
- }
-
- public ImageWrapper(Image image, ImageGenerator generator) {
- this(image, image.getWidth(null), image.getHeight(null), generator);
- }
-
- /**
- * Converts the internal image object to a BufferedImage (if it's not
- * already) and returns it. this is necessary as not all images are of type
- * BufferedImage. e.g. images loaded from a resource with the Toolkit are
- * not. By using getBufferedImage, images are only converted to a
- * getBufferedImage when this is actually needed, which is better than
- * storing images as BufferedImage in general.
- *
- * @return the Image object as a BufferedImage
- */
- public BufferedImage getBufferedImage() {
- if (!(image instanceof BufferedImage)) {
- BufferedImage buffered = new BufferedImage(width, height,
- BufferedImage.TYPE_INT_ARGB);
- buffered.createGraphics().drawImage(image, 0, 0, null);
- setImage(buffered);
- }
- return (BufferedImage)image;
- }
-
- /**
- * Returns the Graphics object to directly paint to this Image. Converts the
- * internal image to a BufferedImage if necessary.
- *
- * @return the Graphics object for drawing into this image
- */
- public Graphics getGraphics() {
- if (graphics == null) {
- // make sure the image is a BufferedImage and then create a graphics object
- BufferedImage img = getBufferedImage();
- graphics = img.createGraphics();
- }
- return graphics;
- }
-
- /**
- * Sets the internal image and clears the stored graphics object.
- * Any code that is changing the internal image should do it through this function
- * to make sure getGraphcis() returns a valid graphics object the next time it is called.
- */
- protected void setImage(Image image) {
- this.image = image;
- graphics = null;
- }
-
- /**
- * Creates and returns a copy of this image.
- *
- * @return a clone of this image.
- */
- public Object clone() {
- ImageWrapper wrapper = generator.createImage(this.width,
- this.height);
- wrapper.getGraphics().drawImage(image, 0, 0, null);
- return wrapper;
- }
-
- /**
- * Returns the Image object represented by this ImageWrapper.
- *
- * @return the image object
- */
- public Image getImage() {
- return image;
- }
-
- /**
- * Returns the ImageProducer of the wrapped image
- *
- * @return the images's ImageProducer
- */
- public ImageProducer getSource() {
- return image.getSource();
- }
-
- /**
- * Dispose the Graphics context and null out the image.
- */
- public void dispose() {
- image = null;
- if (graphics != null) {
- graphics.dispose();
- graphics = null;
- }
- }
-
- /**
- * Set the font used to write on this image.
- */
- public void setFont(String name, int style, int size) {
- getGraphics().setFont(new Font(name, style, size));
- }
-
- /**
- * Sets the color used to write/paint to this image.
- *
- * @param red ...
- * @param green ...
- * @param blue ...
- */
- public void setColor(int red, int green, int blue) {
- getGraphics().setColor(new Color(red, green, blue));
- }
-
- /**
- * Sets the color used to write/paint to this image.
- *
- * @param color ...
- */
- public void setColor(int color) {
- getGraphics().setColor(new Color(color));
- }
-
- /**
- * Sets the color used to write/paint to this image.
- *
- * @param color ...
- */
- public void setColor(Color color) {
- getGraphics().setColor(color);
- }
-
- /**
- * Sets the color used to write/paint to this image.
- *
- * @param color ...
- */
- public void setColor(String color) {
- getGraphics().setColor(Color.decode(color));
- }
- /**
- * Draws a string to this image at the given coordinates.
- *
- * @param str ...
- * @param x ...
- * @param y ...
- */
- public void drawString(String str, int x, int y) {
- getGraphics().drawString(str, x, y);
- }
-
- /**
- * Draws a line to this image from x1/y1 to x2/y2.
- *
- * @param x1 ...
- * @param y1 ...
- * @param x2 ...
- * @param y2 ...
- */
- public void drawLine(int x1, int y1, int x2, int y2) {
- getGraphics().drawLine(x1, y1, x2, y2);
- }
-
- /**
- * Draws a rectangle to this image.
- *
- * @param x ...
- * @param y ...
- * @param w ...
- * @param h ...
- */
- public void drawRect(int x, int y, int w, int h) {
- getGraphics().drawRect(x, y, w, h);
- }
-
- /**
- * Draws another image to this image.
- *
- * @param filename ...
- * @param x ...
- * @param y ...
- */
- public void drawImage(String filename, int x, int y)
- throws IOException {
- Image img = generator.read(filename);
- if (img != null)
- getGraphics().drawImage(img, x, y, null);
- }
-
- /**
- * Draws another image to this image.
- *
- * @param filename ...
- * @param x ...
- * @param y ...
- */
- public void drawImage(ImageWrapper image, int x, int y)
- throws IOException {
- getGraphics().drawImage(image.getImage(), x, y, null);
- }
-
- /**
- * Draws a filled rectangle to this image.
- *
- * @param x ...
- * @param y ...
- * @param w ...
- * @param h ...
- */
- public void fillRect(int x, int y, int w, int h) {
- getGraphics().fillRect(x, y, w, h);
- }
-
- /**
- * Returns the width of this image.
- *
- * @return the width of this image
- */
- public int getWidth() {
- return width;
- }
-
- /**
- * Returns the height of this image.
- *
- * @return the height of this image
- */
- public int getHeight() {
- return height;
- }
-
- /**
- * Crops the image.
- *
- * @param x ...
- * @param y ...
- * @param w ...
- * @param h ...
- */
- public void crop(int x, int y, int w, int h) {
- // do not use the CropFilter any longer:
- if (image instanceof BufferedImage) {
- // BufferedImages define their own function for cropping:
- setImage(((BufferedImage)image).getSubimage(x, y, w, h));
- } else {
- // The internal image will be a BufferedImage after this.
- // Simply create it with the cropped dimensions and draw the image into it:
- BufferedImage buffered = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g2d = buffered.createGraphics();
- g2d.drawImage(image, -x, -y, null);
- g2d.dispose();
- setImage(buffered);
- }
- }
-
- /**
- * resizes the image using the Graphics2D approach
- */
- protected BufferedImage resize(int w, int h, boolean smooth) {
- BufferedImage buffered = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g2d = buffered.createGraphics();
-
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
- smooth ? RenderingHints.VALUE_INTERPOLATION_BICUBIC :
- RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
- );
-
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
- smooth ? RenderingHints.VALUE_RENDER_QUALITY :
- RenderingHints.VALUE_RENDER_SPEED
- );
-
- AffineTransform at = AffineTransform.getScaleInstance(
- (double) w / width,
- (double) h / height
- );
- g2d.drawImage(image, at, null);
- g2d.dispose();
- return buffered;
- }
-
- /**
- * Resize the image
- *
- * @param w ...
- * @param h ...
- */
-
- public void resize(int w, int h) {
- double factor = Math.max(
- (double) w / width,
- (double) h / height
- );
- // if the image is scaled, used the Graphcis2D method, otherwise use AWT:
- if (factor > 1f) {
- // scalie it with the Graphics2D approach for supperiour quality.
- setImage(resize(w, h, true));
- } else {
- // Area averaging has the best results for shrinking of images:
-
- // as getScaledInstance is asynchronous, the ImageWaiter is needed here too:
- // Image scaled = ImageWaiter.waitForImage(image.getScaledInstance(w, h, Image.SCALE_AREA_AVERAGING));
- // if (scaled == null)
- // throw new RuntimeException("Image cannot be resized.");
-
- // this version is up to 4 times faster than getScaledInstance:
- ImageFilterOp filter = new ImageFilterOp(new AreaAveragingScaleFilter(w, h));
- setImage(filter.filter(getBufferedImage(), null));
- }
- width = w;
- height = h;
- }
-
- /**
- * Resize the image, using a fast and cheap algorithm
- *
- * @param w ...
- * @param h ...
- */
- public void resizeFast(int w, int h) {
- image = resize(w, h, false);
- width = w;
- height = h;
- }
-
- /**
- * Reduces the colors used in the image. Necessary before saving as GIF.
- *
- * @param colors colors the number of colors to use, usually <= 256.
- */
- public void reduceColors(int colors) {
- reduceColors(colors, false);
- }
-
- /**
- * Reduces the colors used in the image. Necessary before saving as GIF.
- *
- * @param colors colors the number of colors to use, usually <= 256.
- * @param dither ...
- */
- public void reduceColors(int colors, boolean dither) {
- reduceColors(colors, dither, true);
- }
-
- /**
- * Reduce the colors used in this image. Useful and necessary before saving
- * the image as GIF file.
- *
- * @param colors the number of colors to use, usually <= 256.
- * @param dither ...
- * @param alphaToBitmask ...
- */
-
- public void reduceColors(int colors, boolean dither, boolean alphaToBitmask) {
- setImage(Quantize.process(getBufferedImage(), colors, dither,
- alphaToBitmask));
- }
-
- /**
- * Save the image. Image format is deduced from filename.
- *
- * @param filename ...
- * @throws IOException
- */
- public void saveAs(String filename)
- throws IOException {
- saveAs(filename, -1f, false); // -1 means default quality
- }
-
- /**
- * Saves the image. Image format is deduced from filename.
- *
- * @param filename ...
- * @param quality ...
- * @throws IOException
- */
- public void saveAs(String filename, float quality)
- throws IOException {
- saveAs(filename, quality, false);
- }
-
- /**
- * Saves the image. Image format is deduced from filename.
- *
- * @param filename ...
- * @param quality ...
- * @param alpha ...
- * @throws IOException
- */
- public void saveAs(String filename, float quality, boolean alpha)
- throws IOException {
- generator.write(this, filename, quality, alpha);
- }
-
- /**
- * Sets the palette index of the transparent color for Images with an
- * IndexColorModel. This can be used together with
- * {@link helma.image.ImageWrapper#getPixel}.
- */
- public void setTransparentPixel(int trans) {
- BufferedImage bi = this.getBufferedImage();
- ColorModel cm = bi.getColorModel();
- if (!(cm instanceof IndexColorModel))
- throw new RuntimeException(Messages.getMessage(Messages.NOT_INDEXED_IMAGE_ERROR));
- IndexColorModel icm = (IndexColorModel) cm;
- int mapSize = icm.getMapSize();
- byte reds[] = new byte[mapSize];
- byte greens[] = new byte[mapSize];
- byte blues[] = new byte[mapSize];
- icm.getReds(reds);
- icm.getGreens(greens);
- icm.getBlues(blues);
- // create the new IndexColorModel with the changed transparentPixel:
- icm = new IndexColorModel(icm.getPixelSize(), mapSize, reds, greens,
- blues, trans);
- // create a new BufferedImage with the new IndexColorModel and the old
- // raster:
- setImage(new BufferedImage(icm, bi.getRaster(), false, null));
- }
-
- /**
- * Returns the pixel at x, y. If the image is indexed, it returns the
- * palette index, otherwise the rgb code of the color is returned.
- *
- * @param x the x coordinate of the pixel
- * @param y the y coordinate of the pixel
- * @return the pixel at x, y
- */
- public int getPixel(int x, int y) {
- BufferedImage bi = this.getBufferedImage();
- if (bi.getColorModel() instanceof IndexColorModel)
- return bi.getRaster().getSample(x, y, 0);
- else
- return bi.getRGB(x, y);
- }
-}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/IndexImage.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/IndexImage.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/IndexImage.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,886 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
-
- Copyright 2002-2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- */
-package org.ajax4jsf.framework.util.image;
-
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.RenderingHints;
-import java.awt.image.BufferedImage;
-import java.awt.image.ColorModel;
-import java.awt.image.DataBuffer;
-import java.awt.image.DataBufferInt;
-import java.awt.image.IndexColorModel;
-import java.awt.image.MultiPixelPackedSampleModel;
-import java.awt.image.Raster;
-import java.awt.image.SampleModel;
-import java.awt.image.SinglePixelPackedSampleModel;
-import java.awt.image.WritableRaster;
-import java.util.Iterator;
-import java.util.Vector;
-
-/**
- * This implements an adaptive pallete generator to reduce images to a
- * specified number of colors.
- *
- * Ideally this would also support a better dither option than just
- * the JDK's pattern dither.
- *
- * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
- * @author <a href="mailto:jun@oop-reserch.com">Jun Inamori</a>
- * @version $Id: IndexImage.java,v 1.1.2.1 2007/01/09 18:59:03 alexsmirnov Exp $ */
-public class IndexImage{
-
- /**
- * Used to track a color and the number of pixels of that colors
- */
- private static class Counter {
- public int val;
- public int count=1;
- public Counter(int val) { this.val = val; }
- public boolean add(int val) {
- // See if the value matches us...
- if (this.val != val)
- return false;
- count++;
- return true;
- }
- }
-
- /**
- * Used to define a cube of the colorspace. The cube can be split
- * approximagely in half to generate two cubes.
- */
- private static class Cube {
- int []min={0, 0, 0}, max={255,255,255};
-
- boolean done = false;
-
- Vector []colors = null;
- int count=0;
- static final int RED = 0;
- static final int GRN = 1;
- static final int BLU = 2;
-
- /**
- * Define a new cube.
- * @param colors contains the 3D color histogram to be subdivided
- * @param count the total number of pixels in the 3D histogram.
- */
- public Cube(Vector []colors, int count) {
- this.colors = colors;
- this.count = count;
- }
-
- /**
- * If this returns true then the cube can not be subdivided any
- * further
- */
- public boolean isDone() { return done; }
- /**
- * Splits the cube into two parts. This cube is
- * changed to be one half and the returned cube is the other half.
- * This tries to pick the right channel to split on.
- */
- public Cube split() {
- int dr = max[0]-min[0]+1;
- int dg = max[1]-min[1]+1;
- int db = max[2]-min[2]+1;
- int c0, c1, splitChannel;
-
- // Figure out which axis is the longest and split along
- // that axis (this tries to keep cubes square-ish).
- if (dr >= dg) {
- c0 = GRN;
- if (dr >= db) { splitChannel = RED; c1=BLU; }
- else { splitChannel = BLU; c1=RED; }
- } else if (dg >= db) {
- splitChannel = GRN;
- c0=RED;
- c1=BLU;
- } else {
- splitChannel = BLU;
- c0=RED;
- c1=GRN;
- }
-
- Cube ret;
- ret = splitChannel(splitChannel, c0, c1);
- if (ret != null ) return ret;
-
- ret = splitChannel(c0, splitChannel, c1);
- if (ret != null ) return ret;
-
- ret = splitChannel(c1, splitChannel, c0);
- if (ret != null) return ret;
-
- done = true;
- return null;
- }
-
- /**
- * Splits the image according to the parameters. It tries
- * to find a location where half the pixels are on one side
- * and half the pixels are on the other.
- */
- public Cube splitChannel(int splitChannel, int c0, int c1) {
- if (min[splitChannel] == max[splitChannel]) return null;
-
- int splitSh4 = (2-splitChannel)*4;
- int c0Sh4 = (2-c0)*4;
- int c1Sh4 = (2-c1)*4;
-
- int half = count/2;
- // Each entry is the number of pixels that have that value
- // in the split channel within the cube (so pixels
- // that have that value in the split channel aren't counted
- // if they are outside the cube in the other color channels.
- int counts [] = new int[256];
- int tcount = 0;
-
- // System.out.println("Cube: [" +
- // min[0] + "-" + max[0] + "] [" +
- // min[1] + "-" + max[1] + "] [" +
- // min[2] + "-" + max[2] + "]");
-
- int [] minIdx = {min[0]>>4, min[1]>>4, min[2]>>4};
- int [] maxIdx = {max[0]>>4, max[1]>>4, max[2]>>4};
- int minR=min[0], minG=min[1], minB=min[2];
- int maxR=max[0], maxG=max[1], maxB=max[2];
- int val = 0;
- int [] vals = {0, 0, 0};
- for (int i=minIdx[splitChannel]; i<=maxIdx[splitChannel]; i++) {
- int idx1 = i<<splitSh4;
- for (int j=minIdx[c0]; j<=maxIdx[c0]; j++) {
- int idx2 = idx1 | (j<<c0Sh4);
- for (int k=minIdx[c1]; k<=maxIdx[c1]; k++) {
- int idx = idx2 | (k<<c1Sh4);
- Vector v = colors[idx];
- if (v==null) continue;
- Iterator itr = v.iterator();
- Counter c;
- while (itr.hasNext()) {
- c = (Counter)itr.next();
- val = c.val;
- vals[0] = (val&0xFF0000)>>16;
- vals[1] = (val&0xFF00)>>8;
- vals[2] = (val&0xFF);
- if (((vals[0] >= minR) && (vals[0] <= maxR))&&
- ((vals[1] >= minG) && (vals[1] <= maxG))&&
- ((vals[2] >= minB) && (vals[2] <= maxB))) {
- // The val lies within this cube so count it.
- counts[vals[splitChannel]] += c.count;
- tcount += c.count;
- }
- }
- }
- }
- // We've found the half way point. Note that the
- // rest of counts is not filled out.
- if (tcount >= half) break;
- }
-
- tcount=0;
- int lastAdd=-1;
- // These indicate what the top value for the low cube and
- // the low value of the high cube should be in the split channel
- // (they may not be one off if there are 'dead' spots in the
- // counts array.
- int splitLo=min[splitChannel], splitHi=max[splitChannel];
- for (int i=min[splitChannel]; i<=max[splitChannel]; i++) {
- int c = counts[i];
- if (c == 0) {
- // No counts below this so move up bottom of cube.
- if ((tcount == 0) && (i < max[splitChannel]))
- this.min[splitChannel] = i+1;
- continue;
- }
-
- if (tcount+c < half) {
- lastAdd = i;
- tcount+=c;
- continue;
- }
- if ((half-tcount) <= ((tcount+c)-half)) {
- // Then lastAdd is a better top idx for this then i.
- if (lastAdd == -1) {
- // No lower place to break.
- if (c == this.count) {
- // All pixels are at this value so make min/max
- // reflect that.
- this.max[splitChannel] = i;
- return null; // no split to make.
- } else {
- // There are values about this one so
- // split above.
- splitLo = i;
- splitHi = i+1;
- break;
- }
- }
- splitLo = lastAdd;
- splitHi = i;
- } else {
- if (i == this.max[splitChannel]) {
- if ( c == this.count) {
- // would move min up but that should
- // have happened already.
- return null; // no split to make.
- } else {
- // Would like to break between i and i+1
- // but no i+1 so use lastAdd and i;
- splitLo = lastAdd;
- splitHi = i;
- break;
- }
- }
- // Include c in counts
- tcount += c;
- splitLo = i;
- splitHi = i+1;
- }
- break;
- }
-
- // System.out.println("Split: " + splitChannel + "@"
- // + splitLo + "-"+splitHi +
- // " Count: " + tcount + " of " + count +
- // " LA: " + lastAdd);
-
- // Create the new cube and update everone's bounds & counts.
- Cube ret = new Cube(colors, tcount);
- this.count = this.count-tcount;
- ret.min[splitChannel] = this.min[splitChannel];
- ret.max[splitChannel] = splitLo;
- this.min[splitChannel] = splitHi;
- ret.min[c0] = this.min[c0];
- ret.max[c0] = this.max[c0];
- ret.min[c1] = this.min[c1];
- ret.max[c1] = this.max[c1];
- return ret;
- }
-
- /**
- * Returns the average color for this cube
- */
- public int averageColor() {
- if (this.count == 0) return 0;
-
- float red=0, grn=0, blu=0;
-
- int minR=min[0], minG=min[1], minB=min[2];
- int maxR=max[0], maxG=max[1], maxB=max[2];
- int [] minIdx = {minR>>4, minG>>4, minB>>4};
- int [] maxIdx = {maxR>>4, maxG>>4, maxB>>4};
- int val, ired, igrn, iblu;
- float weight;
- for (int i=minIdx[0]; i<=maxIdx[0]; i++) {
- int idx1 = i<<8;
- for (int j=minIdx[1]; j<=maxIdx[1]; j++) {
- int idx2 = idx1 | (j<<4);
- for (int k=minIdx[2]; k<=maxIdx[2]; k++) {
- int idx = idx2 | k;
- Vector v = colors[idx];
- if (v==null) continue;
- Iterator itr = v.iterator();
- Counter c;
- while (itr.hasNext()) {
- c = (Counter)itr.next();
- val = c.val;
- ired = (val&0xFF0000)>>16;
- igrn = (val&0x00FF00)>>8;
- iblu = (val&0x0000FF);
- if (((ired >= minR) && (ired <= maxR))&&
- ((igrn >= minG) && (igrn <= maxG))&&
- ((iblu >= minB) && (iblu <= maxB))) {
- weight = (c.count/(float)this.count);
- red += (ired*weight);
- grn += (igrn*weight);
- blu += (iblu*weight);
- }
- }
- }
- }
- }
- // System.out.println("RGB: [" + red + ", " +
- // grn + ", " + blu + "]");
- return (((int)(red+0.5))<<16 |
- ((int)(grn+0.5))<<8 |
- ((int)(blu+0.5)));
- }
- }
-
- /**
- * Converts the input image (must be TYPE_INT_RGB or
- * TYPE_INT_ARGB) to an indexed image. Generating an adaptive
- * palette with number of colors specified.
- * @param bi the image to be processed.
- * @param nColors number of colors in the palette
- */
- static public BufferedImage getIndexedImage
- (BufferedImage bi, int nColors) {
- int w=bi.getWidth();
- int h=bi.getHeight();
-
- // Using 4 bits from RG & B.
- Vector [] colors = new Vector[1<<12];
-
- int rgb=0;
- for(int i_w=0; i_w<w; i_w++){
- for(int i_h=0; i_h<h; i_h++){
- rgb=(bi.getRGB(i_w,i_h) & 0xFFFFFF);
- // Get index from high four bits of each component.
- int idx = (((rgb&0xF00000)>>> 12) |
- ((rgb&0x00F000)>>> 8) |
- ((rgb&0x0000F0)>>> 4));
-
- // Get the 'hash vector' for that key.
- Vector v = colors[idx];
- if (v == null) {
- // No colors in this bin yet so create vector and
- // add color.
- v = new Vector();
- v.add(new Counter(rgb));
- colors[idx] = v;
- } else {
- // find our color in the bin or create a counter for it.
- Iterator i = v.iterator();
- while (true) {
- if (i.hasNext()) {
- // try adding our color to each counter...
- if (((Counter)i.next()).add(rgb)) break;
- } else {
- v.add(new Counter(rgb));
- break;
- }
- }
- }
- }
- }
-
- int nCubes=1;
- int fCube=0;
- Cube [] cubes = new Cube[nColors];
- cubes[0] = new Cube(colors, w*h);
-
- while (nCubes < nColors) {
- while (cubes[fCube].isDone()) {
- fCube++;
- if (fCube == nCubes) break;
- }
- if (fCube == nCubes) break;
- Cube c = cubes[fCube];
- Cube nc = c.split();
- if (nc != null) {
- if (nc.count > c.count) {
- Cube tmp = c; c= nc; nc = tmp;
- }
- int j = fCube;
- int cnt = c.count;
- for (int i=fCube+1; i<nCubes; i++) {
- if (cubes[i].count < cnt)
- break;
- cubes[j++] = cubes[i];
- }
- cubes[j++] = c;
-
- cnt = nc.count;
- while (j<nCubes) {
- if (cubes[j].count < cnt)
- break;
- j++;
- }
- for (int i=nCubes; i>j; i--)
- cubes[i] = cubes[i-1];
- cubes[j++] = nc;
- nCubes++;
- }
- }
-
- byte [] r = new byte[nCubes];
- byte [] g = new byte[nCubes];
- byte [] b = new byte[nCubes];
- for (int i=0; i<nCubes; i++) {
- int val = cubes[i].averageColor();
- r[i] = (byte)((val>>16)&0xFF);
- g[i] = (byte)((val>> 8)&0xFF);
- b[i] = (byte)((val )&0xFF);
-
- // System.out.println("Color [" + i + "]: #" +
- // (((val>>16)<16)?"0":"") +
- // Integer.toHexString(val));
- }
- BufferedImage indexed;
-
-
- // The JDK doesn't seem to dither the image correctly if I go
- // below 8bits per pixel. So I dither to an 8bit pallete
- // image that only has nCubes colors. Then I copy the data to
- // a lower bit depth image that I return.
- IndexColorModel icm=new IndexColorModel(8,nCubes,r,g,b);
- indexed =new BufferedImage
- (w, h, BufferedImage.TYPE_BYTE_INDEXED, icm);
- Graphics2D g2d=indexed.createGraphics();
- g2d.setRenderingHint
- (RenderingHints.KEY_DITHERING,
- RenderingHints.VALUE_DITHER_ENABLE);
- g2d.drawImage(bi, 0, 0, null);
- g2d.dispose();
-
-
- int bits;
- for (bits=1; bits <=8; bits++) {
- if ((1<<bits) >= nCubes) break;
- }
- // System.out.println("Bits: " + bits + " Cubes: " + nCubes);
-
- if (bits > 4)
- // 8 bit image we are done...
- return indexed;
-
- // Create our low bit depth image...
- if (bits ==3) bits = 4;
- ColorModel cm=new IndexColorModel(bits,nCubes,r,g,b);
- SampleModel sm = new MultiPixelPackedSampleModel
- (DataBuffer.TYPE_BYTE, w, h, bits);
- WritableRaster ras = Raster.createWritableRaster
- (sm, new Point(0,0));
-
- // Copy the data to the low bitdepth image.
- bi = indexed;
- indexed = new BufferedImage(cm, ras,
- bi.isAlphaPremultiplied(), null);
- copyData(bi, indexed);
- return indexed;
- }
-
- /**
- * An internal optimized version of copyData designed to work on
- * Integer packed data with a SinglePixelPackedSampleModel. Only
- * the region of overlap between src and dst is copied.
- *
- * Calls to this should be preflighted with is_INT_PACK_Data
- * on both src and dest (requireAlpha can be false).
- *
- * @param src The source of the data
- * @param dst The destination for the data.
- */
- public static void copyData_INT_PACK(Raster src, WritableRaster dst) {
- // System.out.println("Fast copyData");
- int x0 = dst.getMinX();
- if (x0 < src.getMinX()) x0 = src.getMinX();
-
- int y0 = dst.getMinY();
- if (y0 < src.getMinY()) y0 = src.getMinY();
-
- int x1 = dst.getMinX()+dst.getWidth()-1;
- if (x1 > src.getMinX()+src.getWidth()-1)
- x1 = src.getMinX()+src.getWidth()-1;
-
- int y1 = dst.getMinY()+dst.getHeight()-1;
- if (y1 > src.getMinY()+src.getHeight()-1)
- y1 = src.getMinY()+src.getHeight()-1;
-
- int width = x1-x0+1;
- int height = y1-y0+1;
-
- SinglePixelPackedSampleModel srcSPPSM;
- srcSPPSM = (SinglePixelPackedSampleModel)src.getSampleModel();
-
- final int srcScanStride = srcSPPSM.getScanlineStride();
- DataBufferInt srcDB = (DataBufferInt)src.getDataBuffer();
- final int [] srcPixels = srcDB.getBankData()[0];
- final int srcBase =
- (srcDB.getOffset() +
- srcSPPSM.getOffset(x0-src.getSampleModelTranslateX(),
- y0-src.getSampleModelTranslateY()));
-
-
- SinglePixelPackedSampleModel dstSPPSM;
- dstSPPSM = (SinglePixelPackedSampleModel)dst.getSampleModel();
-
- final int dstScanStride = dstSPPSM.getScanlineStride();
- DataBufferInt dstDB = (DataBufferInt)dst.getDataBuffer();
- final int [] dstPixels = dstDB.getBankData()[0];
- final int dstBase =
- (dstDB.getOffset() +
- dstSPPSM.getOffset(x0-dst.getSampleModelTranslateX(),
- y0-dst.getSampleModelTranslateY()));
-
- if ((srcScanStride == dstScanStride) &&
- (srcScanStride == width)) {
- // System.out.println("VERY Fast copyData");
-
- System.arraycopy(srcPixels, srcBase, dstPixels, dstBase,
- width*height);
- } else if (width > 128) {
- int srcSP = srcBase;
- int dstSP = dstBase;
- for (int y=0; y<height; y++) {
- System.arraycopy(srcPixels, srcSP, dstPixels, dstSP, width);
- srcSP += srcScanStride;
- dstSP += dstScanStride;
- }
- } else {
- for (int y=0; y<height; y++) {
- int srcSP = srcBase+y*srcScanStride;
- int dstSP = dstBase+y*dstScanStride;
- for (int x=0; x<width; x++)
- dstPixels[dstSP++] = srcPixels[srcSP++];
- }
- }
- }
-
- public static void copyData_FALLBACK(Raster src, WritableRaster dst) {
- // System.out.println("Fallback copyData");
-
- int x0 = dst.getMinX();
- if (x0 < src.getMinX()) x0 = src.getMinX();
-
- int y0 = dst.getMinY();
- if (y0 < src.getMinY()) y0 = src.getMinY();
-
- int x1 = dst.getMinX()+dst.getWidth()-1;
- if (x1 > src.getMinX()+src.getWidth()-1)
- x1 = src.getMinX()+src.getWidth()-1;
-
- int y1 = dst.getMinY()+dst.getHeight()-1;
- if (y1 > src.getMinY()+src.getHeight()-1)
- y1 = src.getMinY()+src.getHeight()-1;
-
- int width = x1-x0+1;
- int [] data = null;
-
- for (int y = y0; y <= y1 ; y++) {
- data = src.getPixels(x0,y,width,1,data);
- dst.setPixels (x0,y,width,1,data);
- }
- }
-
- /**
- * Copies data from one raster to another. Only the region of
- * overlap between src and dst is copied. <tt>Src</tt> and
- * <tt>Dst</tt> must have compatible SampleModels.
- *
- * @param src The source of the data
- * @param dst The destination for the data.
- */
- public static void copyData(Raster src, WritableRaster dst) {
- if (is_INT_PACK_Data(src.getSampleModel(), false) &&
- is_INT_PACK_Data(dst.getSampleModel(), false)) {
- copyData_INT_PACK(src, dst);
- return;
- }
-
- copyData_FALLBACK(src, dst);
- }
-
- /**
- * Copies data from one bufferedImage to another paying attention
- * to the state of AlphaPreMultiplied.
- *
- * @param src The source
- * @param dst The destination
- */
- public static void
- copyData(BufferedImage src, BufferedImage dst) {
- Rectangle srcRect = new Rectangle(0, 0,
- src.getWidth(), src.getHeight());
- copyData(src, srcRect, dst, new Point(0,0));
- }
-
-
- /**
- * Copies data from one bufferedImage to another paying attention
- * to the state of AlphaPreMultiplied.
- *
- * @param src The source
- * @param srcRect The Rectangle of source data to be copied
- * @param dst The destination
- * @param destP The Place for the upper left corner of srcRect in dst.
- */
- public static void
- copyData(BufferedImage src, Rectangle srcRect,
- BufferedImage dst, Point destP) {
-
- /*
- if (srcCS != dstCS)
- throw new IllegalArgumentException
- ("Images must be in the same ColorSpace in order "+
- "to copy Data between them");
- */
- boolean srcAlpha = src.getColorModel().hasAlpha();
- boolean dstAlpha = dst.getColorModel().hasAlpha();
-
- // System.out.println("Src has: " + srcAlpha +
- // " is: " + src.isAlphaPremultiplied());
- //
- // System.out.println("Dst has: " + dstAlpha +
- // " is: " + dst.isAlphaPremultiplied());
-
- if (srcAlpha == dstAlpha)
- if ((srcAlpha == false) ||
- (src.isAlphaPremultiplied() == dst.isAlphaPremultiplied())) {
- // They match one another so just copy everything...
- copyData(src.getRaster(), dst.getRaster());
- return;
- }
-
- // System.out.println("Using Slow CopyData");
-
- int [] pixel = null;
- Raster srcR = src.getRaster();
- WritableRaster dstR = dst.getRaster();
- int bands = dstR.getNumBands();
-
- int dx = destP.x-srcRect.x;
- int dy = destP.y-srcRect.y;
-
- int w = srcRect.width;
- int x0 = srcRect.x;
- int y0 = srcRect.y;
- int y1 = y0+srcRect.height-1;
-
- if (!srcAlpha) {
- // Src has no alpha dest does so set alpha to 1.0 everywhere.
- // System.out.println("Add Alpha");
- int [] oPix = new int[bands*w];
- int out = (w*bands)-1; // The 2 skips alpha channel
- while(out >= 0) {
- // Fill alpha channel with 255's
- oPix[out] = 255;
- out -= bands;
- }
-
- int b, in;
- for (int y=y0; y<=y1; y++) {
- pixel = srcR.getPixels(x0,y,w,1,pixel);
- in = w*(bands-1)-1;
- out = (w*bands)-2; // The 2 skips alpha channel on last pix
- switch (bands) {
- case 4:
- while(in >= 0) {
- oPix[out--] = pixel[in--];
- oPix[out--] = pixel[in--];
- oPix[out--] = pixel[in--];
- out--;
- }
- break;
- default:
- while(in >= 0) {
- for (b=0; b<bands-1; b++)
- oPix[out--] = pixel[in--];
- out--;
- }
- }
- dstR.setPixels(x0+dx, y+dy, w, 1, oPix);
- }
- } else if (dstAlpha && dst.isAlphaPremultiplied()) {
- // Src and dest have Alpha but we need to multiply it for dst.
- // System.out.println("Mult Case");
- int a, b, alpha, in, fpNorm = (1<<24)/255, pt5 = 1<<23;
- for (int y=y0; y<=y1; y++) {
- pixel = srcR.getPixels(x0,y,w,1,pixel);
- in=bands*w-1;
- switch (bands) {
- case 4:
- while(in >= 0) {
- a = pixel[in];
- if (a == 255)
- in -= 4;
- else {
- in--;
- alpha = fpNorm*a;
- pixel[in] = (pixel[in]*alpha+pt5)>>>24; in--;
- pixel[in] = (pixel[in]*alpha+pt5)>>>24; in--;
- pixel[in] = (pixel[in]*alpha+pt5)>>>24; in--;
- }
- }
- break;
- default:
- while(in >= 0) {
- a = pixel[in];
- if (a == 255)
- in -= bands;
- else {
- in--;
- alpha = fpNorm*a;
- for (b=0; b<bands-1; b++) {
- pixel[in] = (pixel[in]*alpha+pt5)>>>24;
- in--;
- }
- }
- }
- }
- dstR.setPixels(x0+dx, y+dy, w, 1, pixel);
- }
- } else if (dstAlpha && !dst.isAlphaPremultiplied()) {
- // Src and dest have Alpha but we need to divide it out for dst.
- // System.out.println("Div Case");
- int a, b, ialpha, in, fpNorm = 0x00FF0000, pt5 = 1<<15;
- for (int y=y0; y<=y1; y++) {
- pixel = srcR.getPixels(x0,y,w,1,pixel);
- in=(bands*w)-1;
- switch(bands) {
- case 4:
- while(in >= 0) {
- a = pixel[in];
- if ((a <= 0) || (a >= 255))
- in -= 4;
- else {
- in--;
- ialpha = fpNorm/a;
- pixel[in] = (pixel[in]*ialpha+pt5)>>>16; in--;
- pixel[in] = (pixel[in]*ialpha+pt5)>>>16; in--;
- pixel[in] = (pixel[in]*ialpha+pt5)>>>16; in--;
- }
- }
- break;
- default:
- while(in >= 0) {
- a = pixel[in];
- if ((a <= 0) || (a >= 255))
- in -= bands;
- else {
- in--;
- ialpha = fpNorm/a;
- for (b=0; b<bands-1; b++) {
- pixel[in] = (pixel[in]*ialpha+pt5)>>>16;
- in--;
- }
- }
- }
- }
- dstR.setPixels(x0+dx, y+dy, w, 1, pixel);
- }
- } else if (src.isAlphaPremultiplied()) {
- int [] oPix = new int[bands*w];
- // Src has alpha dest does not so unpremult and store...
- // System.out.println("Remove Alpha, Div Case");
- int a, b, ialpha, in, out, fpNorm = 0x00FF0000, pt5 = 1<<15;
- for (int y=y0; y<=y1; y++) {
- pixel = srcR.getPixels(x0,y,w,1,pixel);
- in = (bands+1)*w -1;
- out = (bands*w)-1;
- while(in >= 0) {
- a = pixel[in]; in--;
- if (a > 0) {
- if (a < 255) {
- ialpha = fpNorm/a;
- for (b=0; b<bands; b++)
- oPix[out--] = (pixel[in--]*ialpha+pt5)>>>16;
- } else
- for (b=0; b<bands; b++)
- oPix[out--] = pixel[in--];
- } else {
- in -= bands;
- for (b=0; b<bands; b++)
- oPix[out--] = 255;
- }
- }
- dstR.setPixels(x0+dx, y+dy, w, 1, oPix);
- }
- } else {
- // Src has unpremult alpha, dest does not have alpha,
- // just copy the color channels over.
- Rectangle dstRect = new Rectangle(destP.x, destP.y,
- srcRect.width, srcRect.height);
- for (int b=0; b<bands; b++)
- copyBand(srcR, srcRect, b,
- dstR, dstRect, b);
- }
- }
-
- public static void copyBand(Raster src, int srcBand,
- WritableRaster dst, int dstBand) {
-
- Rectangle sR = src.getBounds();
- Rectangle dR = dst.getBounds();
- Rectangle cpR = sR.intersection(dR);
-
- copyBand(src, cpR, srcBand, dst, cpR, dstBand);
- }
-
- public static void copyBand(Raster src, Rectangle sR, int sBand,
- WritableRaster dst, Rectangle dR, int dBand) {
- int dy = dR.y -sR.y;
- int dx = dR.x -sR.x;
- sR = sR.intersection(src.getBounds());
- dR = dR.intersection(dst.getBounds());
- int width, height;
- if (dR.width < sR.width) width = dR.width;
- else width = sR.width;
- if (dR.height < sR.height) height = dR.height;
- else height = sR.height;
-
- int x = sR.x+dx;
- int [] samples = null;
- for (int y=sR.y; y< sR.y+height; y++) {
- samples = src.getSamples(sR.x, y, width, 1, sBand, samples);
- dst.setSamples(x, y+dy, width, 1, dBand, samples);
- }
- }
-
- public static boolean is_INT_PACK_Data(SampleModel sm,
- boolean requireAlpha) {
-// Check ColorModel is of type DirectColorModel
-if(!(sm instanceof SinglePixelPackedSampleModel)) return false;
-
-// Check transfer type
-if(sm.getDataType() != DataBuffer.TYPE_INT) return false;
-
-SinglePixelPackedSampleModel sppsm;
-sppsm = (SinglePixelPackedSampleModel)sm;
-
-int [] masks = sppsm.getBitMasks();
-if (masks.length == 3) {
-if (requireAlpha) return false;
-} else if (masks.length != 4)
-return false;
-
-if(masks[0] != 0x00ff0000) return false;
-if(masks[1] != 0x0000ff00) return false;
-if(masks[2] != 0x000000ff) return false;
-if ((masks.length == 4) &&
-(masks[3] != 0xff000000)) return false;
-
-return true;
-}
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/Quantize.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/Quantize.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/Quantize.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,840 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Helma License Notice
- *
- * The contents of this file are subject to the Helma License
- * Version 2.0 (the "License"). You may not use this file except in
- * compliance with the License. A copy of the License is available at
- * http://adele.helma.org/download/helma/license.txt
- *
- * Copyright 1998-2003 Helma Software. All Rights Reserved.
- *
- * $RCSfile: Quantize.java,v $
- * $Author: alexsmirnov $
- * $Revision: 1.1.2.1 $
- * $Date: 2007/01/09 18:59:05 $
- */
-
-package org.ajax4jsf.framework.util.image;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.DataBufferByte;
-import java.awt.image.DataBufferInt;
-import java.awt.image.IndexColorModel;
-
-/*
- * @(#)Quantize.java 0.90 9/19/00 Adam Doppelt
- *
- * Modifications by Joerg Lehni:
- *
- * - Support for alpha-channels.
- * - Returns a BufferedImage of TYPE_BYTE_INDEXED with a IndexColorModel.
- * - Dithering of images through helma.image.DiffusionFilterOp by setting
- * the dither parameter to true.
- * - Support for a transparent color, which is correctly rendered by GIFEncoder.
- * All pixels with alpha < 0x80 are converted to this color when the parameter
- * alphaToBitmask is set to true.
- * - Removed the SQUARES lookup tables as multiplications of integer values
- * shouldn't take more than one clock nowadays anyhow.
- */
-
-/**
- * An efficient color quantization algorithm, adapted from the C++
- * implementation quantize.c in <a
- * href="http://www.imagemagick.org/">ImageMagick</a>. The pixels for
- * an image are placed into an oct tree. The oct tree is reduced in
- * size, and the pixels from the original image are reassigned to the
- * nodes in the reduced tree.<p>
- *
- * Here is the copyright notice from ImageMagick:
- *
- * <pre>
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Permission is hereby granted, free of charge, to any person obtaining a %
-% copy of this software and associated documentation files ("ImageMagick"), %
-% to deal in ImageMagick without restriction, including without limitation %
-% the rights to use, copy, modify, merge, publish, distribute, sublicense, %
-% and/or sell copies of ImageMagick, and to permit persons to whom the %
-% ImageMagick is furnished to do so, subject to the following conditions: %
-% %
-% The above copyright notice and this permission notice shall be included in %
-% all copies or substantial portions of ImageMagick. %
-% %
-% The software is provided "as is", without warranty of any kind, express or %
-% implied, including but not limited to the warranties of merchantability, %
-% fitness for a particular purpose and noninfringement. In no event shall %
-% E. I. du Pont de Nemours and Company be liable for any claim, damages or %
-% other liability, whether in an action of contract, tort or otherwise, %
-% arising from, out of or in connection with ImageMagick or the use or other %
-% dealings in ImageMagick. %
-% %
-% Except as contained in this notice, the name of the E. I. du Pont de %
-% Nemours and Company shall not be used in advertising or otherwise to %
-% promote the sale, use or other dealings in ImageMagick without prior %
-% written authorization from the E. I. du Pont de Nemours and Company. %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-</pre>
- *
- *
- * @version 0.90 19 Sep 2000
- * @author <a href="http://www.gurge.com/amd/">Adam Doppelt</a>
- */
-public class Quantize {
-
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-% QQQ U U AAA N N TTTTT IIIII ZZZZZ EEEEE %
-% Q Q U U A A NN N T I ZZ E %
-% Q Q U U AAAAA N N N T I ZZZ EEEEE %
-% Q QQ U U A A N NN T I ZZ E %
-% QQQQ UUU A A N N T IIIII ZZZZZ EEEEE %
-% %
-% %
-% Reduce the Number of Unique Colors in an Image %
-% %
-% %
-% Software Design %
-% John Cristy %
-% July 1992 %
-% %
-% %
-% Copyright 1998 E. I. du Pont de Nemours and Company %
-% %
-% Permission is hereby granted, free of charge, to any person obtaining a %
-% copy of this software and associated documentation files ("ImageMagick"), %
-% to deal in ImageMagick without restriction, including without limitation %
-% the rights to use, copy, modify, merge, publish, distribute, sublicense, %
-% and/or sell copies of ImageMagick, and to permit persons to whom the %
-% ImageMagick is furnished to do so, subject to the following conditions: %
-% %
-% The above copyright notice and this permission notice shall be included in %
-% all copies or substantial portions of ImageMagick. %
-% %
-% The software is provided "as is", without warranty of any kind, express or %
-% implied, including but not limited to the warranties of merchantability, %
-% fitness for a particular purpose and noninfringement. In no event shall %
-% E. I. du Pont de Nemours and Company be liable for any claim, damages or %
-% other liability, whether in an action of contract, tort or otherwise, %
-% arising from, out of or in connection with ImageMagick or the use or other %
-% dealings in ImageMagick. %
-% %
-% Except as contained in this notice, the name of the E. I. du Pont de %
-% Nemours and Company shall not be used in advertising or otherwise to %
-% promote the sale, use or other dealings in ImageMagick without prior %
-% written authorization from the E. I. du Pont de Nemours and Company. %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% Realism in computer graphics typically requires using 24 bits/pixel to
-% generate an image. Yet many graphic display devices do not contain
-% the amount of memory necessary to match the spatial and color
-% resolution of the human eye. The QUANTIZE program takes a 24 bit
-% image and reduces the number of colors so it can be displayed on
-% raster device with less bits per pixel. In most instances, the
-% quantized image closely resembles the original reference image.
-%
-% A reduction of colors in an image is also desirable for image
-% transmission and real-time animation.
-%
-% Function Quantize takes a standard RGB or monochrome images and quantizes
-% them down to some fixed number of colors.
-%
-% For purposes of color allocation, an image is a set of n pixels, where
-% each pixel is a point in RGB space. RGB space is a 3-dimensional
-% vector space, and each pixel, pi, is defined by an ordered triple of
-% red, green, and blue coordinates, (ri, gi, bi).
-%
-% Each primary color component (red, green, or blue) represents an
-% intensity which varies linearly from 0 to a maximum value, cmax, which
-% corresponds to full saturation of that color. Color allocation is
-% defined over a domain consisting of the cube in RGB space with
-% opposite vertices at (0,0,0) and (cmax,cmax,cmax). QUANTIZE requires
-% cmax = 255.
-%
-% The algorithm maps this domain onto a tree in which each node
-% represents a cube within that domain. In the following discussion
-% these cubes are defined by the coordinate of two opposite vertices:
-% The vertex nearest the origin in RGB space and the vertex farthest
-% from the origin.
-%
-% The tree's root node represents the the entire domain, (0,0,0) through
-% (cmax,cmax,cmax). Each lower level in the tree is generated by
-% subdividing one node's cube into eight smaller cubes of equal size.
-% This corresponds to bisecting the parent cube with planes passing
-% through the midpoints of each edge.
-%
-% The basic algorithm operates in three phases: Classification,
-% Reduction, and Assignment. Classification builds a color
-% description tree for the image. Reduction collapses the tree until
-% the number it represents, at most, the number of colors desired in the
-% output image. Assignment defines the output image's color map and
-% sets each pixel's color by reclassification in the reduced tree.
-% Our goal is to minimize the numerical discrepancies between the original
-% colors and quantized colors (quantization error).
-%
-% Classification begins by initializing a color description tree of
-% sufficient depth to represent each possible input color in a leaf.
-% However, it is impractical to generate a fully-formed color
-% description tree in the classification phase for realistic values of
-% cmax. If colors components in the input image are quantized to k-bit
-% precision, so that cmax= 2k-1, the tree would need k levels below the
-% root node to allow representing each possible input color in a leaf.
-% This becomes prohibitive because the tree's total number of nodes is
-% 1 + sum(i=1,k,8k).
-%
-% A complete tree would require 19,173,961 nodes for k = 8, cmax = 255.
-% Therefore, to avoid building a fully populated tree, QUANTIZE: (1)
-% Initializes data structures for nodes only as they are needed; (2)
-% Chooses a maximum depth for the tree as a function of the desired
-% number of colors in the output image (currently log2(colorMap size)).
-%
-% For each pixel in the input image, classification scans downward from
-% the root of the color description tree. At each level of the tree it
-% identifies the single node which represents a cube in RGB space
-% containing the pixel's color. It updates the following data for each
-% such node:
-%
-% n1: Number of pixels whose color is contained in the RGB cube
-% which this node represents;
-%
-% n2: Number of pixels whose color is not represented in a node at
-% lower depth in the tree; initially, n2 = 0 for all nodes except
-% leaves of the tree.
-%
-% Sr, Sg, Sb: Sums of the red, green, and blue component values for
-% all pixels not classified at a lower depth. The combination of
-% these sums and n2 will ultimately characterize the mean color of a
-% set of pixels represented by this node.
-%
-% E: The distance squared in RGB space between each pixel contained
-% within a node and the nodes' center. This represents the quantization
-% error for a node.
-%
-% Reduction repeatedly prunes the tree until the number of nodes with
-% n2 > 0 is less than or equal to the maximum number of colors allowed
-% in the output image. On any given iteration over the tree, it selects
-% those nodes whose E count is minimal for pruning and merges their
-% color statistics upward. It uses a pruning threshold, Ep, to govern
-% node selection as follows:
-%
-% Ep = 0
-% while number of nodes with (n2 > 0) > required maximum number of colors
-% prune all nodes such that E <= Ep
-% Set Ep to minimum E in remaining nodes
-%
-% This has the effect of minimizing any quantization error when merging
-% two nodes together.
-%
-% When a node to be pruned has offspring, the pruning procedure invokes
-% itself recursively in order to prune the tree from the leaves upward.
-% n2, Sr, Sg, and Sb in a node being pruned are always added to the
-% corresponding data in that node's parent. This retains the pruned
-% node's color characteristics for later averaging.
-%
-% For each node, n2 pixels exist for which that node represents the
-% smallest volume in RGB space containing those pixel's colors. When n2
-% > 0 the node will uniquely define a color in the output image. At the
-% beginning of reduction, n2 = 0 for all nodes except a the leaves of
-% the tree which represent colors present in the input image.
-%
-% The other pixel count, n1, indicates the total number of colors
-% within the cubic volume which the node represents. This includes n1 -
-% n2 pixels whose colors should be defined by nodes at a lower level in
-% the tree.
-%
-% Assignment generates the output image from the pruned tree. The
-% outpu t image consists of two parts: (1) A color map, which is an
-% array of color descriptions (RGB triples) for each color present in
-% the output image; (2) A pixel array, which represents each pixel as
-% an index into the color map array.
-%
-% First, the assignment phase makes one pass over the pruned color
-% description tree to establish the image's color map. For each node
-% with n2 > 0, it divides Sr, Sg, and Sb by n2 . This produces the
-% mean color of all pixels that classify no lower than this node. Each
-% of these colors becomes an entry in the color map.
-%
-% Finally, the assignment phase reclassifies each pixel in the pruned
-% tree to identify the deepest node containing the pixel's color. The
-% pixel's value in the pixel array becomes the index of this node's mean
-% color in the color map.
-%
-% With the permission of USC Information Sciences Institute, 4676 Admiralty
-% Way, Marina del Rey, California 90292, this code was adapted from module
-% ALCOLS written by Paul Raveling.
-%
-% The names of ISI and USC are not used in advertising or publicity
-% pertaining to distribution of the software without prior specific
-% written permission from ISI.
-%
-*/
-
- final static boolean QUICK = false;
-
- final static int MAX_RGB = 255;
- final static int MAX_NODES = 266817;
- final static int MAX_TREE_DEPTH = 8;
- final static int MAX_CHILDREN = 16;
-
- /**
- * Reduce the image to the given number of colors. The pixels are reduced in
- * place.
- *
- * @return The new color palette.
- */
- public static BufferedImage process(BufferedImage source, int maxColors,
- boolean dither, boolean alphaToBitmask) {
- int type = source.getType();
- int[] pixels;
- // try to get the direct pixels of the BufferedImage
- // this works for images of type INT_RGB, INT_ARGB and INT_ARGB_PRE
- // for all others, a new array with rgb pixels is created!
- if (type == BufferedImage.TYPE_INT_RGB
- || type == BufferedImage.TYPE_INT_ARGB
- || type == BufferedImage.TYPE_INT_ARGB_PRE) {
- pixels = ((DataBufferInt) source.getRaster().getDataBuffer()).getData();
- } else {
- pixels = source.getRGB(0, 0, source.getWidth(), source.getHeight(), null, 0, source.getWidth());
- }
- Cube cube = new Cube(source, pixels, maxColors, dither, alphaToBitmask);
- cube.classification();
- cube.reduction();
- return cube.assignment();
- }
-
- static class Cube {
- BufferedImage source;
- int[] pixels;
- int maxColors;
- byte colorMap[][];
-
- Node root;
- int depth;
-
- boolean dither;
- boolean alphaToBitmask;
- boolean addTransparency;
- // firstColor is set to 1 when when addTransparency is true!
- int firstColor = 0;
-
- // counter for the number of colors in the cube. this gets
- // recalculated often.
- int numColors;
-
- // counter for the number of nodes in the tree
- int numNodes;
-
- Cube(BufferedImage source, int[] pixels, int maxColors, boolean dither,
- boolean alphaToBitmask) {
- this.source = source;
- this.pixels = pixels;
- this.maxColors = maxColors;
- this.dither = dither;
- this.alphaToBitmask = alphaToBitmask;
-
- int i = maxColors;
- // tree_depth = log maxColors
- // 4
- for (depth = 1; i != 0; depth++) {
- i /= 4;
- }
- if (depth > 1) {
- --depth;
- }
- if (depth > MAX_TREE_DEPTH) {
- depth = MAX_TREE_DEPTH;
- } else if (depth < 2) {
- depth = 2;
- }
-
- root = new Node(this);
- }
-
- /*
- * Procedure Classification begins by initializing a color description
- * tree of sufficient depth to represent each possible input color in a
- * leaf. However, it is impractical to generate a fully-formed color
- * description tree in the classification phase for realistic values of
- * cmax. If colors components in the input image are quantized to k-bit
- * precision, so that cmax= 2k-1, the tree would need k levels below the
- * root node to allow representing each possible input color in a leaf.
- * This becomes prohibitive because the tree's total number of nodes is
- * 1 + sum(i=1,k,8k).
- *
- * A complete tree would require 19,173,961 nodes for k = 8, cmax = 255.
- * Therefore, to avoid building a fully populated tree, QUANTIZE: (1)
- * Initializes data structures for nodes only as they are needed; (2)
- * Chooses a maximum depth for the tree as a function of the desired
- * number of colors in the output image (currently log2(colorMap size)).
- *
- * For each pixel in the input image, classification scans downward from
- * the root of the color description tree. At each level of the tree it
- * identifies the single node which represents a cube in RGB space
- * containing It updates the following data for each such node:
- *
- * numPixels : Number of pixels whose color is contained in the RGB cube
- * which this node represents;
- *
- * unique : Number of pixels whose color is not represented in a node at
- * lower depth in the tree; initially, n2 = 0 for all nodes except
- * leaves of the tree.
- *
- * totalRed/green/blue : Sums of the red, green, and blue component
- * values for all pixels not classified at a lower depth. The
- * combination of these sums and n2 will ultimately characterize the
- * mean color of a set of pixels represented by this node.
- */
- void classification() {
- addTransparency = false;
- firstColor = 0;
- for (int i = 0; i < pixels.length; i++) {
- int pixel = pixels[i];
- int red = (pixel >> 16) & 0xff;
- int green = (pixel >> 8) & 0xff;
- int blue = (pixel >> 0) & 0xff;
- int alpha = (pixel >> 24) & 0xff;
- if (alphaToBitmask)
- alpha = alpha < 0x80 ? 0 : 0xff;
-
- if (alpha > 0) {
- // a hard limit on the number of nodes in the tree
- if (numNodes > MAX_NODES) {
- // System.out.println("pruning");
- root.pruneLevel();
- --depth;
- }
-
- // walk the tree to depth, increasing the
- // numPixels count for each node
- Node node = root;
- for (int level = 1; level <= depth; ++level) {
- int id = (((red > node.midRed ? 1 : 0) << 0)
- | ((green > node.midGreen ? 1 : 0) << 1)
- | ((blue > node.midBlue ? 1 : 0) << 2) | ((alpha > node.midAlpha ? 1
- : 0) << 3));
- if (node.children[id] == null) {
- node = new Node(node, id, level);
- } else {
- node = node.children[id];
- }
- node.numPixels++;
- }
-
- ++node.unique;
- node.totalRed += red;
- node.totalGreen += green;
- node.totalBlue += blue;
- node.totalAlpha += alpha;
- } else if (!addTransparency) {
- addTransparency = true;
- numColors++;
- firstColor = 1; // start at 1 as 0 will be the transparent
- // color
- }
- }
- }
-
- /*
- * reduction repeatedly prunes the tree until the number of nodes with
- * unique > 0 is less than or equal to the maximum number of colors
- * allowed in the output image.
- *
- * When a node to be pruned has offspring, the pruning procedure invokes
- * itself recursively in order to prune the tree from the leaves upward.
- * The statistics of the node being pruned are always added to the
- * corresponding data in that node's parent. This retains the pruned
- * node's color characteristics for later averaging.
- */
- void reduction() {
- int threshold = 1;
- while (numColors > maxColors) {
- numColors = firstColor;
- threshold = root.reduce(threshold, Integer.MAX_VALUE);
- }
- }
-
- /**
- * The result of a closest color search.
- */
- static class Search {
- int distance;
- int colorIndex;
- }
-
- /*
- * Procedure assignment generates the output image from the pruned tree.
- * The output image consists of two parts: (1) A color map, which is an
- * array of color descriptions (RGB triples) for each color present in
- * the output image; (2) A pixel array, which represents each pixel as
- * an index into the color map array.
- *
- * First, the assignment phase makes one pass over the pruned color
- * description tree to establish the image's color map. For each node
- * with n2 > 0, it divides Sr, Sg, and Sb by n2. This produces the mean
- * color of all pixels that classify no lower than this node. Each of
- * these colors becomes an entry in the color map.
- *
- * Finally, the assignment phase reclassifies each pixel in the pruned
- * tree to identify the deepest node containing the pixel's color. The
- * pixel's value in the pixel array becomes the index of this node's
- * mean color in the color map.
- */
- BufferedImage assignment() {
- colorMap = new byte[4][numColors];
-
- if (addTransparency) {
- // if a transparency color is added, firstColor was set to 1,
- // so color 0 can be used for this
- colorMap[0][0] = 0;
- colorMap[1][0] = 0;
- colorMap[2][0] = 0;
- colorMap[3][0] = 0;
- }
- numColors = firstColor;
- root.mapColors();
-
- // determine bit depth for palette
- int depth;
- for (depth = 1; depth <= 8; depth++)
- if ((1 << depth) >= numColors)
- break;
-
- // create the right color model, depending on transparency settings:
- IndexColorModel icm;
- if (alphaToBitmask) {
- if (addTransparency)
- icm = new IndexColorModel(depth, numColors, colorMap[0],
- colorMap[1], colorMap[2], 0);
- else
- icm = new IndexColorModel(depth, numColors, colorMap[0],
- colorMap[1], colorMap[2]);
- } else {
- icm = new IndexColorModel(depth, numColors, colorMap[0],
- colorMap[1], colorMap[2], colorMap[3]);
- }
- // create the indexed BufferedImage:
- BufferedImage dest = new BufferedImage(source.getWidth(),
- source.getHeight(), BufferedImage.TYPE_BYTE_INDEXED, icm);
-
- boolean firstOut = true;
- if (dither)
- new DiffusionFilterOp().filter(source, dest);
- else {
- Search search = new Search();
- // convert to indexed color
- byte[] dst = ((DataBufferByte) dest.getRaster().getDataBuffer()).getData();
-
- for (int i = 0; i < pixels.length; i++) {
- int pixel = pixels[i];
- int red = (pixel >> 16) & 0xff;
- int green = (pixel >> 8) & 0xff;
- int blue = (pixel >> 0) & 0xff;
- int alpha = (pixel >> 24) & 0xff;
-
- if (alphaToBitmask)
- alpha = alpha < 128 ? 0 : 0xff;
-
- // this is super weird: on some systems, transparent pixels are
- // not calculated correctly if the following block is taken out.
- // the bug is very strange, isn't related to the code (compiler error?)
- // but doesn't allways happen. as soon as it does, though, it doesn't
- // seem to want to go away.
- // This happened at various times on my two different debian systems
- // and i never found out how to really fix it. the following line seems to
- // prevent it from happening, but i wonder wether there's a better way
- // to fix it.
- // it looks as if the command forces alpha to take on correct values.
- // Until now I only knew of effects like that in quantum mechanics...
- if (i == 0) {
- String fix = "" + alpha;
- }
-
- if (alpha == 0 && addTransparency) {
- dst[i] = 0; // transparency color is at 0
- } else {
- // walk the tree to find the cube containing that color
- Node node = root;
- for (;;) {
- int id = (((red > node.midRed ? 1 : 0) << 0)
- | ((green > node.midGreen ? 1 : 0) << 1)
- | ((blue > node.midBlue ? 1 : 0) << 2) | ((alpha > node.midAlpha ? 1
- : 0) << 3));
- if (node.children[id] == null) {
- break;
- }
- node = node.children[id];
- }
-
- if (QUICK) {
- // if QUICK is set, just use that
- // node. Strictly speaking, this isn't
- // necessarily best match.
- dst[i] = (byte) node.colorIndex;
- } else {
- // Find the closest color.
- search.distance = Integer.MAX_VALUE;
- node.parent.closestColor(red, green, blue, alpha,
- search);
- dst[i] = (byte) search.colorIndex;
- }
- }
- }
- }
- return dest;
- }
-
- /**
- * A single Node in the tree.
- */
- static class Node {
- Cube cube;
-
- // parent node
- Node parent;
-
- // children nodes
- Node children[];
- int numChildren;
-
- // our index within our parent
- int id;
- // our level within the tree
- int level;
- // our color midpoint
- int midRed;
- int midGreen;
- int midBlue;
- int midAlpha;
-
- // the pixel count for this node and all children
- int numPixels;
-
- // the pixel count for this node
- int unique;
- // the sum of all pixels contained in this node
- int totalRed;
- int totalGreen;
- int totalBlue;
- int totalAlpha;
-
- // used to build the colorMap
- int colorIndex;
-
- Node(Cube cube) {
- this.cube = cube;
- this.parent = this;
- this.children = new Node[MAX_CHILDREN];
- this.id = 0;
- this.level = 0;
-
- this.numPixels = Integer.MAX_VALUE;
-
- this.midRed = (MAX_RGB + 1) >> 1;
- this.midGreen = (MAX_RGB + 1) >> 1;
- this.midBlue = (MAX_RGB + 1) >> 1;
- this.midAlpha = (MAX_RGB + 1) >> 1;
- }
-
- Node(Node parent, int id, int level) {
- this.cube = parent.cube;
- this.parent = parent;
- this.children = new Node[MAX_CHILDREN];
- this.id = id;
- this.level = level;
-
- // add to the cube
- ++cube.numNodes;
- if (level == cube.depth) {
- ++cube.numColors;
- }
-
- // add to the parent
- ++parent.numChildren;
- parent.children[id] = this;
-
- // figure out our midpoint
- int bi = (1 << (MAX_TREE_DEPTH - level)) >> 1;
- midRed = parent.midRed + ((id & 1) > 0 ? bi : -bi);
- midGreen = parent.midGreen + ((id & 2) > 0 ? bi : -bi);
- midBlue = parent.midBlue + ((id & 4) > 0 ? bi : -bi);
- midAlpha = parent.midAlpha + ((id & 8) > 0 ? bi : -bi);
- }
-
- /**
- * Remove this children node, and make sure our parent absorbs our
- * pixel statistics.
- */
- void pruneChild() {
- --parent.numChildren;
- parent.unique += unique;
- parent.totalRed += totalRed;
- parent.totalGreen += totalGreen;
- parent.totalBlue += totalBlue;
- parent.totalAlpha += totalAlpha;
- parent.children[id] = null;
- --cube.numNodes;
- cube = null;
- parent = null;
- }
-
- /**
- * Prune the lowest layer of the tree.
- */
- void pruneLevel() {
- if (numChildren != 0) {
- for (int id = 0; id < MAX_CHILDREN; id++) {
- if (children[id] != null) {
- children[id].pruneLevel();
- }
- }
- }
- if (level == cube.depth) {
- pruneChild();
- }
- }
-
- /**
- * Remove any nodes that have fewer than threshold pixels. Also, as
- * long as we're walking the tree: - figure out the color with the
- * fewest pixels - recalculate the total number of colors in the
- * tree
- */
- int reduce(int threshold, int nextThreshold) {
- if (numChildren != 0) {
- for (int id = 0; id < MAX_CHILDREN; id++) {
- if (children[id] != null) {
- nextThreshold = children[id].reduce(threshold,
- nextThreshold);
- }
- }
- }
- if (numPixels <= threshold) {
- pruneChild();
- } else {
- if (unique != 0) {
- cube.numColors++;
- }
- if (numPixels < nextThreshold) {
- nextThreshold = numPixels;
- }
- }
- return nextThreshold;
- }
-
- /*
- * mapColors traverses the color cube tree and notes each colorMap
- * entry. A colorMap entry is any node in the color cube tree where
- * the number of unique colors is not zero.
- */
- void mapColors() {
- if (numChildren != 0) {
- for (int id = 0; id < MAX_CHILDREN; id++) {
- if (children[id] != null) {
- children[id].mapColors();
- }
- }
- }
- if (unique != 0) {
- int add = unique >> 1;
- cube.colorMap[0][cube.numColors] = (byte) ((totalRed + add) / unique);
- cube.colorMap[1][cube.numColors] = (byte) ((totalGreen + add) / unique);
- cube.colorMap[2][cube.numColors] = (byte) ((totalBlue + add) / unique);
- cube.colorMap[3][cube.numColors] = (byte) ((totalAlpha + add) / unique);
- colorIndex = cube.numColors++;
- }
- }
-
- /*
- * ClosestColor traverses the color cube tree at a particular node
- * and determines which colorMap entry best represents the input
- * color.
- */
- void closestColor(int red, int green, int blue, int alpha,
- Search search) {
- if (numChildren != 0) {
- for (int id = 0; id < MAX_CHILDREN; id++) {
- if (children[id] != null) {
- children[id].closestColor(red, green, blue, alpha,
- search);
- }
- }
- }
-
- if (unique != 0) {
- int distance = distance(
- cube.colorMap[0][colorIndex] & 0xff,
- cube.colorMap[1][colorIndex] & 0xff,
- cube.colorMap[2][colorIndex] & 0xff,
- cube.colorMap[3][colorIndex] & 0xff, red, green, blue,
- alpha);
- if (distance < search.distance) {
- search.distance = distance;
- search.colorIndex = colorIndex;
- }
- }
- }
-
- /**
- * Figure out the distance between this node and som color.
- */
- final static int distance(int r1, int g1, int b1, int a1, int r2,
- int g2, int b2, int a2) {
- int da = a1 - a2;
- int dr = r1 - r2;
- int dg = g1 - g2;
- int db = b1 - b2;
-
- return da * da + dr * dr + dg * dg + db * db;
-// return (SQUARES[r1 - r2 + MAX_RGB] +
-// SQUARES[g1 - g2 + MAX_RGB] +
-// SQUARES[b1 - b2 + MAX_RGB] +
-// SQUARES[a1 - a2 + MAX_RGB]);
- }
-
- public String toString() {
- StringBuffer buf = new StringBuffer();
- if (parent == this) {
- buf.append("root");
- } else {
- buf.append("node");
- }
- buf.append(' ');
- buf.append(level);
- buf.append(" [");
- buf.append(midRed);
- buf.append(',');
- buf.append(midGreen);
- buf.append(',');
- buf.append(midBlue);
- buf.append(',');
- buf.append(midAlpha);
- buf.append(']');
- return new String(buf);
- }
- }
- }
-}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/RoundGradientContext.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/RoundGradientContext.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/RoundGradientContext.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,77 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.image;
-
-import java.awt.Color;
-import java.awt.PaintContext;
-import java.awt.geom.Point2D;
-import java.awt.image.ColorModel;
-import java.awt.image.Raster;
-import java.awt.image.WritableRaster;
-/**
- *
- * TODO: provide English Comments
- *
- *
- */
-public class RoundGradientContext implements PaintContext {
- protected Point2D mPoint;
- protected Point2D mRadius;
- protected Color mC1, mC2;
- public RoundGradientContext(Point2D p, Color c1, Point2D r, Color c2) {
- mPoint = p;
- mC1 = c1;
- mRadius = r;
- mC2 = c2;
- }
- public void dispose() {}
- public ColorModel getColorModel() { return ColorModel.getRGBdefault(); }
- /* The get-Raster() method iterates over each point in the requested rectangle,
- calculating the distance from the center point.
- It calculates a weighting factor, from 0.0 to 1.0, based on the ratio of this
- distance and the radius. */
- public Raster getRaster(int x, int y, int w, int h) {
- WritableRaster raster =
- getColorModel().createCompatibleWritableRaster(w, h);
- int[] data = new int[w * h * 4]; //k=4,
- double radius = mRadius.distance(0, 0);
- for (int j = 0; j < h; j++) {
- for (int i = 0; i < w; i++) {
- double distance = mPoint.distance(x + i, y + j);
-
- double ratio = distance/radius;
- if (ratio > 1.0){
- ratio = 1.0;
- }//if
- int base = (j * w + i) * 4;
- //it simply uses the weighting factor to linearly interpolate between the center color and the background color
- data[base] = (int)(mC1.getRed() + ratio * (mC2.getRed() - mC1.getRed()));
- data[base + 1] = (int)(mC1.getGreen() + ratio * (mC2.getGreen() - mC1.getGreen()));
- data[base + 2] = (int)(mC1.getBlue() + ratio * (mC2.getBlue() - mC1.getBlue()));
- data[base + 3] = (int)(mC1.getAlpha() + ratio * (mC2.getAlpha() - mC1.getAlpha()));
- }
- }
-
- raster.setPixels(0, 0, w, h, data);
- return raster;
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/RoundGradientPaint.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/RoundGradientPaint.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/RoundGradientPaint.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,58 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.image;
-
-import java.awt.Color;
-import java.awt.Paint;
-import java.awt.PaintContext;
-import java.awt.Rectangle;
-import java.awt.RenderingHints;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.ColorModel;
-
-import org.ajax4jsf.Messages;
-public class RoundGradientPaint implements Paint {
- protected Point2D mPoint;
- protected Point2D mRadius;
- protected Color mPointColor, mBackgroundColor;
- public RoundGradientPaint(double x, double y, Color pointColor,
- Point2D radius, Color backgroundColor) {
- if (radius.distance(0, 0) <= 0) throw new IllegalArgumentException(Messages.getMessage(Messages.INVALID_RADIUS));
- mPoint = new Point2D.Double(x, y);
- mPointColor = pointColor;
- mRadius = radius;
- mBackgroundColor = backgroundColor;
- }
- public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
- AffineTransform xform, RenderingHints hints) {
- Point2D transformedPoint = xform.transform(mPoint, null);
- Point2D transformedRadius = xform.deltaTransform(mRadius, null);
- return new RoundGradientContext(transformedPoint, mPointColor, transformedRadius, mBackgroundColor);
- }
- public int getTransparency() {
- int a1 = mPointColor.getAlpha();
- int a2 = mBackgroundColor.getAlpha();
- return (((a1 & a2) == 0xff) ? OPAQUE : TRANSLUCENT);
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/SimpleGIFEncoder.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/SimpleGIFEncoder.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/SimpleGIFEncoder.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,499 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.image;
-
-import java.awt.AWTException;
-import java.awt.Image;
-import java.awt.image.PixelGrabber;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.ajax4jsf.Messages;
-
-/**
- * GIFEncoder is a class which takes an image and saves it to a stream
- * using the GIF file format (<A
- * HREF="http://www.dcs.ed.ac.uk/%7Emxr/gfx/">Graphics Interchange
- * Format</A>). A GIFEncoder
- * is constructed with either an AWT Image (which must be fully
- * loaded) or a set of RGB arrays. The image can be written out with a
- * call to <CODE>Write</CODE>.<P>
- *
- * Three caveats:
- * <UL>
- * <LI>GIFEncoder will convert the image to indexed color upon
- * construction. This will take some time, depending on the size of
- * the image. Also, actually writing the image out (Write) will take
- * time.<P>
- *
- * <LI>The image cannot have more than 256 colors, since GIF is an 8
- * bit format. For a 24 bit to 8 bit quantization algorithm, see
- * Graphics Gems II III.2 by Xialoin Wu. Or check out his <A
- * HREF="http://www.csd.uwo.ca/faculty/wu/cq.c">C source</A>.<P>
- *
- * <LI>Since the image must be completely loaded into memory,
- * GIFEncoder may have problems with large images. Attempting to
- * encode an image which will not fit into memory will probably
- * result in the following exception:<P>
- * <CODE>java.awt.AWTException: Grabber returned false: 192</CODE><P>
- * </UL><P>
- *
- * GIFEncoder is based upon gifsave.c, which was written and released
- * by:<P>
- * <CENTER>
- * Sverre H. Huseby<BR>
- * Bjoelsengt. 17<BR>
- * N-0468 Oslo<BR>
- * Norway<P>
- *
- * Phone: +47 2 230539<BR>
- * sverrehu(a)ifi.uio.no<P>
- * </CENTER>
- * @version 0.90 21 Apr 1996
- * @author <A HREF="http://www.cs.brown.edu/people/amd/">Adam Doppelt</A> */
-public class SimpleGIFEncoder {
- short width_, height_;
- int numColors_;
- byte pixels_[], colors_[];
-
- ScreenDescriptor sd_;
- ImageDescriptor id_;
-
-/**
- * Construct a GIFEncoder. The constructor will convert the image to
- * an indexed color array. <B>This may take some time.</B><P>
- *
- * @param image The image to encode. The image <B>must</B> be
- * completely loaded.
- * @exception AWTException Will be thrown if the pixel grab fails. This
- * can happen if Java runs out of memory. It may also indicate that the image
- * contains more than 256 colors.
- * */
- public SimpleGIFEncoder(Image image) throws AWTException {
- width_ = (short)image.getWidth(null);
- height_ = (short)image.getHeight(null);
-
- int values[] = new int[width_ * height_];
- PixelGrabber grabber = new PixelGrabber(
- image, 0, 0, width_, height_, values, 0, width_);
-
- try {
- if(grabber.grabPixels() != true)
- throw new AWTException(Messages.getMessage(Messages.GRABBER_ERROR, "" + grabber.status()));
- }
- catch (InterruptedException e) {
- }
-
- byte r[][] = new byte[width_][height_];
- byte g[][] = new byte[width_][height_];
- byte b[][] = new byte[width_][height_];
- int index = 0;
- for (int y = 0; y < height_; ++y)
- for (int x = 0; x < width_; ++x) {
- r[x][y] = (byte)((values[index] >> 16) & 0xFF);
- g[x][y] = (byte)((values[index] >> 8) & 0xFF);
- b[x][y] = (byte)((values[index]) & 0xFF);
- ++index;
- }
- ToIndexedColor(r, g, b);
- }
-
-/**
- * Construct a GIFEncoder. The constructor will convert the image to
- * an indexed color array. <B>This may take some time.</B><P>
- *
- * Each array stores intensity values for the image. In other words,
- * r[x][y] refers to the red intensity of the pixel at column x, row
- * y.<P>
- *
- * @param r An array containing the red intensity values.
- * @param g An array containing the green intensity values.
- * @param b An array containing the blue intensity values.
- *
- * @exception AWTException Will be thrown if the image contains more than
- * 256 colors.
- * */
- public SimpleGIFEncoder(byte r[][], byte g[][], byte b[][]) throws AWTException {
- width_ = (short)(r.length);
- height_ = (short)(r[0].length);
-
- ToIndexedColor(r, g, b);
- }
-
-/**
- * Writes the image out to a stream in the GIF file format. This will
- * be a single GIF87a image, non-interlaced, with no background color.
- * <B>This may take some time.</B><P>
- *
- * @param output The stream to output to. This should probably be a
- * buffered stream.
- *
- * @exception IOException Will be thrown if a write operation fails.
- * */
- public void Write(OutputStream output) throws IOException {
- BitUtils.WriteString(output, "GIF87a");
-
- ScreenDescriptor sd = new ScreenDescriptor(width_, height_,
- numColors_);
- sd.Write(output);
-
- output.write(colors_, 0, colors_.length);
-
- ImageDescriptor id = new ImageDescriptor(width_, height_, ',');
- id.Write(output);
-
- byte codesize = BitUtils.BitsNeeded(numColors_);
- if (codesize == 1)
- ++codesize;
- output.write(codesize);
-
- LZWCompressor.LZWCompress(output, codesize, pixels_);
- output.write(0);
-
- id = new ImageDescriptor((byte)0, (byte)0, ';');
- id.Write(output);
- output.flush();
- }
-
- void ToIndexedColor(byte r[][], byte g[][],
- byte b[][]) throws AWTException {
- pixels_ = new byte[width_ * height_];
- colors_ = new byte[256 * 3];
- int colornum = 0;
- for (int x = 0; x < width_; ++x) {
- for (int y = 0; y < height_; ++y) {
- int search;
- for (search = 0; search < colornum; ++search)
- if (colors_[search * 3] == r[x][y] &&
- colors_[search * 3 + 1] == g[x][y] &&
- colors_[search * 3 + 2] == b[x][y])
- break;
-
- if (search > 255)
- throw new AWTException(Messages.getMessage(Messages.TOOMANY_COLORS_ERROR));
-
- pixels_[y * width_ + x] = (byte)search;
-
- if (search == colornum) {
- colors_[search * 3] = r[x][y];
- colors_[search * 3 + 1] = g[x][y];
- colors_[search * 3 + 2] = b[x][y];
- ++colornum;
- }
- }
- }
- numColors_ = 1 << BitUtils.BitsNeeded(colornum);
- byte copy[] = new byte[numColors_ * 3];
- System.arraycopy(colors_, 0, copy, 0, numColors_ * 3);
- colors_ = copy;
- }
-
-}
-
-class BitFile {
- OutputStream output_;
- byte buffer_[];
- int index_, bitsLeft_;
-
- public BitFile(OutputStream output) {
- output_ = output;
- buffer_ = new byte[256];
- index_ = 0;
- bitsLeft_ = 8;
- }
-
- public void Flush() throws IOException {
- int numBytes = index_ + (bitsLeft_ == 8 ? 0 : 1);
- if (numBytes > 0) {
- output_.write(numBytes);
- output_.write(buffer_, 0, numBytes);
- buffer_[0] = 0;
- index_ = 0;
- bitsLeft_ = 8;
- }
- }
-
- public void WriteBits(int bits, int numbits) throws IOException {
- int bitsWritten = 0;
- int numBytes = 255;
- do {
- if ((index_ == 254 && bitsLeft_ == 0) || index_ > 254) {
- output_.write(numBytes);
- output_.write(buffer_, 0, numBytes);
-
- buffer_[0] = 0;
- index_ = 0;
- bitsLeft_ = 8;
- }
-
- if (numbits <= bitsLeft_) {
- buffer_[index_] |= (bits & ((1 << numbits) - 1)) <<
- (8 - bitsLeft_);
- bitsWritten += numbits;
- bitsLeft_ -= numbits;
- numbits = 0;
- }
- else {
- buffer_[index_] |= (bits & ((1 << bitsLeft_) - 1)) <<
- (8 - bitsLeft_);
- bitsWritten += bitsLeft_;
- bits >>= bitsLeft_;
- numbits -= bitsLeft_;
- buffer_[++index_] = 0;
- bitsLeft_ = 8;
- }
- } while (numbits != 0);
- }
-}
-
-class LZWStringTable {
- private final static int RES_CODES = 2;
- private final static short HASH_FREE = (short)0xFFFF;
- private final static short NEXT_FIRST = (short)0xFFFF;
- private final static int MAXBITS = 12;
- private final static int MAXSTR = (1 << MAXBITS);
- private final static short HASHSIZE = 9973;
- private final static short HASHSTEP = 2039;
-
- byte strChr_[];
- short strNxt_[];
- short strHsh_[];
- short numStrings_;
-
- public LZWStringTable() {
- strChr_ = new byte[MAXSTR];
- strNxt_ = new short[MAXSTR];
- strHsh_ = new short[HASHSIZE];
- }
-
- public int AddCharString(short index, byte b) {
- int hshidx;
-
- if (numStrings_ >= MAXSTR)
- return 0xFFFF;
-
- hshidx = Hash(index, b);
- while (strHsh_[hshidx] != HASH_FREE)
- hshidx = (hshidx + HASHSTEP) % HASHSIZE;
-
- strHsh_[hshidx] = numStrings_;
- strChr_[numStrings_] = b;
- strNxt_[numStrings_] = (index != HASH_FREE) ? index : NEXT_FIRST;
-
- return numStrings_++;
- }
-
- public short FindCharString(short index, byte b) {
- int hshidx, nxtidx;
-
- if (index == HASH_FREE)
- return b;
-
- hshidx = Hash(index, b);
- while ((nxtidx = strHsh_[hshidx]) != HASH_FREE) {
- if (strNxt_[nxtidx] == index && strChr_[nxtidx] == b)
- return (short)nxtidx;
- hshidx = (hshidx + HASHSTEP) % HASHSIZE;
- }
-
- return (short)0xFFFF;
- }
-
- public void ClearTable(int codesize) {
- numStrings_ = 0;
-
- for (int q = 0; q < HASHSIZE; q++) {
- strHsh_[q] = HASH_FREE;
- }
-
- int w = (1 << codesize) + RES_CODES;
- for (int q = 0; q < w; q++)
- AddCharString((short)0xFFFF, (byte)q);
- }
-
- static public int Hash(short index, byte lastbyte) {
- return ((int)((short)(lastbyte << 8) ^ index) & 0xFFFF) % HASHSIZE;
- }
-}
-
-class LZWCompressor {
-
- public static void LZWCompress(OutputStream output, int codesize,
- byte toCompress[]) throws IOException {
- byte c;
- short index;
- int clearcode, endofinfo, numbits, limit, errcode;
- short prefix = (short)0xFFFF;
-
- BitFile bitFile = new BitFile(output);
- LZWStringTable strings = new LZWStringTable();
-
- clearcode = 1 << codesize;
- endofinfo = clearcode + 1;
-
- numbits = codesize + 1;
- limit = (1 << numbits) - 1;
-
- strings.ClearTable(codesize);
- bitFile.WriteBits(clearcode, numbits);
-
- for (int loop = 0; loop < toCompress.length; ++loop) {
- c = toCompress[loop];
- if ((index = strings.FindCharString(prefix, c)) != -1)
- prefix = index;
- else {
- bitFile.WriteBits(prefix, numbits);
- if (strings.AddCharString(prefix, c) > limit) {
- if (++numbits > 12) {
- bitFile.WriteBits(clearcode, numbits - 1);
- strings.ClearTable(codesize);
- numbits = codesize + 1;
- }
- limit = (1 << numbits) - 1;
- }
-
- prefix = (short)((short)c & 0xFF);
- }
- }
-
- if (prefix != -1)
- bitFile.WriteBits(prefix, numbits);
-
- bitFile.WriteBits(endofinfo, numbits);
- bitFile.Flush();
- }
-}
-
-class ScreenDescriptor {
- public short localScreenWidth_, localScreenHeight_;
- private byte byte_;
- public byte backgroundColorIndex_, pixelAspectRatio_;
-
- public ScreenDescriptor(short width, short height, int numColors) {
- localScreenWidth_ = width;
- localScreenHeight_ = height;
- SetGlobalColorTableSize((byte)(BitUtils.BitsNeeded(numColors) - 1));
- SetGlobalColorTableFlag((byte)1);
- SetSortFlag((byte)0);
- SetColorResolution((byte)7);
- backgroundColorIndex_ = 0;
- pixelAspectRatio_ = 0;
- }
-
- public void Write(OutputStream output) throws IOException {
- BitUtils.WriteWord(output, localScreenWidth_);
- BitUtils.WriteWord(output, localScreenHeight_);
- output.write(byte_);
- output.write(backgroundColorIndex_);
- output.write(pixelAspectRatio_);
- }
-
- public void SetGlobalColorTableSize(byte num) {
- byte_ |= (num & 7);
- }
-
- public void SetSortFlag(byte num) {
- byte_ |= (num & 1) << 3;
- }
-
- public void SetColorResolution(byte num) {
- byte_ |= (num & 7) << 4;
- }
-
- public void SetGlobalColorTableFlag(byte num) {
- byte_ |= (num & 1) << 7;
- }
-}
-
-class ImageDescriptor {
- public byte separator_;
- public short leftPosition_, topPosition_, width_, height_;
- private byte byte_;
-
- public ImageDescriptor(short width, short height, char separator) {
- separator_ = (byte)separator;
- leftPosition_ = 0;
- topPosition_ = 0;
- width_ = width;
- height_ = height;
- SetLocalColorTableSize((byte)0);
- SetReserved((byte)0);
- SetSortFlag((byte)0);
- SetInterlaceFlag((byte)0);
- SetLocalColorTableFlag((byte)0);
- }
-
- public void Write(OutputStream output) throws IOException {
- output.write(separator_);
- BitUtils.WriteWord(output, leftPosition_);
- BitUtils.WriteWord(output, topPosition_);
- BitUtils.WriteWord(output, width_);
- BitUtils.WriteWord(output, height_);
- output.write(byte_);
- }
-
- public void SetLocalColorTableSize(byte num) {
- byte_ |= (num & 7);
- }
-
- public void SetReserved(byte num) {
- byte_ |= (num & 3) << 3;
- }
-
- public void SetSortFlag(byte num) {
- byte_ |= (num & 1) << 5;
- }
-
- public void SetInterlaceFlag(byte num) {
- byte_ |= (num & 1) << 6;
- }
-
- public void SetLocalColorTableFlag(byte num) {
- byte_ |= (num & 1) << 7;
- }
-}
-
-class BitUtils {
- public static byte BitsNeeded(int n) {
- byte ret = 1;
-
- if (n-- == 0)
- return 0;
-
- while ((n >>= 1) != 0)
- ++ret;
-
- return ret;
- }
-
- public static void WriteWord(OutputStream output,
- short w) throws IOException {
- output.write(w & 0xFF);
- output.write((w >> 8) & 0xFF);
- }
-
- static void WriteString(OutputStream output,
- String string) throws IOException {
- for (int loop = 0; loop < string.length(); ++loop)
- output.write((byte)(string.charAt(loop)));
- }
-}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/imageio/ImageIOGenerator.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/imageio/ImageIOGenerator.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/util/image/imageio/ImageIOGenerator.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,175 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Helma License Notice
- *
- * The contents of this file are subject to the Helma License
- * Version 2.0 (the "License"). You may not use this file except in
- * compliance with the License. A copy of the License is available at
- * http://adele.helma.org/download/helma/license.txt
- *
- * Copyright 1998-2003 Helma Software. All Rights Reserved.
- *
- * $RCSfile: ImageIOGenerator.java,v $
- * $Author: alexsmirnov $
- * $Revision: 1.1.2.1 $
- * $Date: 2007/01/09 19:00:17 $
- */
-
-/*
- * ImageIOGenerator defines it's own functions for reading from various
- * resources. These return BufferedImages, therefore all the images
- * are from the beginning in that format when working with ImageIO
- */
-
-package org.ajax4jsf.framework.util.image.imageio;
-
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.awt.image.DirectColorModel;
-import java.awt.image.WritableRaster;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Iterator;
-
-import javax.imageio.IIOImage;
-import javax.imageio.ImageIO;
-import javax.imageio.ImageWriteParam;
-import javax.imageio.ImageWriter;
-import javax.imageio.stream.ImageOutputStream;
-
-import org.ajax4jsf.framework.util.image.ImageGenerator;
-import org.ajax4jsf.framework.util.image.ImageWrapper;
-
-
-
-/**
- * A wrapper for an image that uses the ImageIO Framework.
- */
-public class ImageIOGenerator extends ImageGenerator {
- /**
- * @param filename the filename of the image to create
- *
- * @return the newly created image
- * @throws IOException
- */
- public Image read(String filename)
- throws IOException {
- return ImageIO.read(new File(filename));
- }
-
- /**
- * @param url the URL the filename of the image to create
- *
- * @return the newly created image
- * @throws IOException
- */
- public Image read(URL url)
- throws IOException {
- return ImageIO.read(url);
- }
-
- /**
- * @param src the data of the image to create
- *
- * @return the newly created image
- * @throws IOException
- */
- public Image read(byte[] src)
- throws IOException {
- return ImageIO.read(new ByteArrayInputStream(src));
- }
-
- /**
- * Saves the image. Image format is deduced from filename.
- *
- * @param filename ...
- * @param quality ...
- * @param alpha ...
- * @throws IOException
- * @see helma.image.ImageGenerator#write(helma.image.ImageWrapper, java.lang.String, float, boolean)
- */
- public void write(ImageWrapper wrapper, String filename, float quality, boolean alpha) throws IOException {
- int pos = filename.lastIndexOf('.');
- if (pos != -1) {
- String extension = filename.substring(pos + 1,
- filename.length()).toLowerCase();
-
- // Find a writer for that file extensions
- ImageWriter writer = null;
- Iterator iter = ImageIO.getImageWritersByFormatName(extension);
- if (iter.hasNext())
- writer = (ImageWriter) iter.next();
- if (writer != null) {
- ImageOutputStream ios = null;
- try {
- BufferedImage bi = wrapper.getBufferedImage();
- // Prepare output file
- File file = new File(filename);
- if (file.exists())
- file.delete();
- ios = ImageIO.createImageOutputStream(file);
- writer.setOutput(ios);
- // Set some parameters
- ImageWriteParam param = writer.getDefaultWriteParam();
- if (param.canWriteCompressed() &&
- quality >= 0.0 && quality <= 1.0) {
- param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
- param.setCompressionQuality(quality);
- }
- if (param.canWriteProgressive())
- param.setProgressiveMode(ImageWriteParam.MODE_DISABLED);
- // if bi has type ARGB and alpha is false, we have to tell the writer to not use the alpha channel:
- // this is especially needed for jpeg files where imageio seems to produce wrong jpeg files right now...
- if (bi.getType() == BufferedImage.TYPE_INT_ARGB
- && !alpha) {
- // create a new BufferedImage that uses a WritableRaster of bi, with all the bands except the alpha band:
- WritableRaster raster = bi.getRaster();
- WritableRaster newRaster = raster.createWritableChild(
- 0, 0, wrapper.getWidth(), wrapper.getHeight(),
- 0, 0, new int[] {0, 1, 2 }
- );
- // create a ColorModel that represents the one of the ARGB except the alpha channel:
- DirectColorModel cm = (DirectColorModel) bi.getColorModel();
- DirectColorModel newCM = new DirectColorModel(
- cm.getPixelSize(), cm.getRedMask(),
- cm.getGreenMask(), cm.getBlueMask());
- // now create the new buffer that is used ot write the image:
- BufferedImage rgbBuffer = new BufferedImage(newCM,
- newRaster, false, null);
- writer.write(null, new IIOImage(rgbBuffer, null,
- null), param);
- } else {
- writer.write(null, new IIOImage(bi, null, null),
- param);
- }
- } finally {
- if (ios != null)
- ios.close();
- writer.dispose();
- }
- }
- }
-}
-}
\ No newline at end of file
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -26,8 +26,7 @@
import java.io.DataOutputStream;
import java.io.IOException;
-import org.ajax4jsf.framework.util.image.GIFEncoder;
-import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.image.GIFEncoder;
/**
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
Added: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/DiffusionFilterOp.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/DiffusionFilterOp.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/DiffusionFilterOp.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -0,0 +1,268 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Helma License Notice
+ *
+ * The contents of this file are subject to the Helma License
+ * Version 2.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://adele.helma.org/download/helma/license.txt
+ *
+ * Copyright 1998-2003 Helma Software. All Rights Reserved.
+ *
+ * $RCSfile: DiffusionFilterOp.java,v $
+ * $Author: alexsmirnov $
+ * $Revision: 1.1.2.1 $
+ * $Date: 2007/01/09 18:59:06 $
+ */
+
+/*
+ * Code from com.jhlabs.image.DiffusionFilter, Java Image Processing
+ * Copyright (C) Jerry Huxtable 1998
+ * http://www.jhlabs.com/ip/
+ *
+ * Conversion to a BufferedImageOp inspired by:
+ * http://www.peter-cockerell.net:8080/java/FloydSteinberg/FloydSteinbergFil...
+ *
+ */
+
+package org.ajax4jsf.resource.image;
+
+import java.awt.RenderingHints;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.ColorModel;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferInt;
+import java.awt.image.IndexColorModel;
+
+import org.ajax4jsf.Messages;
+
+public class DiffusionFilterOp implements BufferedImageOp {
+
+ protected final static int[] diffusionMatrix = {
+ 0, 0, 0,
+ 0, 0, 7,
+ 3, 5, 1,
+ };
+
+ private int[] matrix;
+ private int sum;
+ private boolean serpentine = true;
+ private int[] colorMap;
+
+ /**
+ * Construct a DiffusionFilter
+ */
+ public DiffusionFilterOp() {
+ setMatrix(diffusionMatrix);
+ }
+
+ /**
+ * Set whether to use a serpentine pattern for return or not. This can reduce 'avalanche' artifacts in the output.
+ * @param serpentine true to use serpentine pattern
+ */
+ public void setSerpentine(boolean serpentine) {
+ this.serpentine = serpentine;
+ }
+
+ /**
+ * Return the serpentine setting
+ * @return the current setting
+ */
+ public boolean getSerpentine() {
+ return serpentine;
+ }
+
+ public void setMatrix(int[] matrix) {
+ this.matrix = matrix;
+ sum = 0;
+ for (int i = 0; i < matrix.length; i++)
+ sum += matrix[i];
+ }
+
+ public int[] getMatrix() {
+ return matrix;
+ }
+
+ /**
+ * Do the filter operation
+ *
+ * @param src The source BufferedImage. Can be any type.
+ * @param dst The destination image. If not null, must be of type TYPE_BYTE_INDEXED
+ * @return A dithered version of src in a BufferedImage of type TYPE_BYTE_INDEXED
+ */
+ public BufferedImage filter(BufferedImage src, BufferedImage dst) {
+
+ // If there's no dest. create one
+ if (dst == null)
+ dst = createCompatibleDestImage(src, null);
+
+ // Otherwise check that the provided dest is an indexed image
+ else if (dst.getType() != BufferedImage.TYPE_BYTE_INDEXED) {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.BUFFER_TYPE_ERROR));
+ }
+
+ DataBufferByte dstBuffer = (DataBufferByte) dst.getRaster().getDataBuffer();
+ byte dstData[] = dstBuffer.getData();
+
+ // Other things to test are pixel bit strides, scanline stride and transfer type
+ // Same goes for the source image
+
+ IndexColorModel icm = (IndexColorModel) dst.getColorModel();
+ colorMap = new int[icm.getMapSize()];
+ icm.getRGBs(colorMap);
+
+ int width = src.getWidth();
+ int height = src.getHeight();
+
+ DataBufferInt srcBuffer = (DataBufferInt) src.getRaster().getDataBuffer();
+ int srcData[] = srcBuffer.getData();
+
+ // This is the offset into the buffer of the current source pixel
+ int index = 0;
+
+ // Loop through each pixel
+ for (int y = 0; y < height; y++) {
+ boolean reverse = serpentine && (y & 1) == 1;
+ int direction;
+ if (reverse) {
+ index = y * width + width - 1;
+ direction = -1;
+ } else {
+ index = y * width;
+ direction = 1;
+ }
+ for (int x = 0; x < width; x++) {
+ int rgb1 = srcData[index];
+ int a1 = (rgb1 >> 24) & 0xff;
+ int r1 = (rgb1 >> 16) & 0xff;
+ int g1 = (rgb1 >> 8) & 0xff;
+ int b1 = rgb1 & 0xff;
+
+ int idx = findIndex(r1, g1, b1, a1);
+ dstData[index] = (byte) idx;
+
+ int rgb2 = colorMap[idx];
+ int a2 = (rgb2 >> 24) & 0xff;
+ int r2 = (rgb2 >> 16) & 0xff;
+ int g2 = (rgb2 >> 8) & 0xff;
+ int b2 = rgb2 & 0xff;
+
+ int er = r1 - r2;
+ int eg = g1 - g2;
+ int eb = b1 - b2;
+ int ea = a1 - a2;
+
+ for (int i = -1; i <= 1; i++) {
+ int iy = i + y;
+ if (0 <= iy && iy < height) {
+ for (int j = -1; j <= 1; j++) {
+ int jx = j + x;
+ if (0 <= jx && jx < width) {
+ int w;
+ if (reverse)
+ w = matrix[(i + 1) * 3 - j + 1];
+ else
+ w = matrix[(i + 1) * 3 + j + 1];
+ if (w != 0) {
+ int k = reverse ? index - j : index + j;
+ rgb1 = srcData[k];
+ a1 = ((rgb1 >> 24) & 0xff) + ea * w / sum;
+ r1 = ((rgb1 >> 16) & 0xff) + er * w / sum;
+ g1 = ((rgb1 >> 8) & 0xff) + eg * w / sum;
+ b1 = (rgb1 & 0xff) + eb * w / sum;
+
+ srcData[k] = ((clamp(a1) << 24) | clamp(r1) << 16)
+ | (clamp(g1) << 8) | clamp(b1);
+ }
+ }
+ }
+ }
+ }
+ index += direction;
+ }
+ }
+
+ return dst;
+ }
+
+ private static int clamp(int c) {
+ if (c < 0)
+ return 0;
+ if (c > 255)
+ return 255;
+ return c;
+ }
+
+ int findIndex(int r1, int g1, int b1, int a1)
+ throws ArrayIndexOutOfBoundsException {
+ int idx = 0;
+ long dist = Long.MAX_VALUE;
+ for (int i = 0; i < colorMap.length; i++) {
+ int rgb2 = colorMap[i];
+ int a2 = (rgb2 >> 24) & 0xff;
+ int r2 = (rgb2 >> 16) & 0xff;
+ int g2 = (rgb2 >> 8) & 0xff;
+ int b2 = rgb2 & 0xff;
+
+ int da = a1 - a2;
+ int dr = r1 - r2;
+ int dg = g1 - g2;
+ int db = b1 - b2;
+
+ long newdist = da * da + dr * dr + dg * dg + db * db;
+ if (newdist < dist) {
+ idx = i;
+ dist = newdist;
+ }
+ }
+ return idx;
+ }
+
+ // This always returns an indexed image
+ public BufferedImage createCompatibleDestImage(BufferedImage src,
+ ColorModel destCM) {
+ return new BufferedImage(src.getWidth(), src.getHeight(),
+ BufferedImage.TYPE_BYTE_INDEXED);
+ }
+
+ // There are no rendering hints
+ public RenderingHints getRenderingHints() {
+ return null;
+ }
+
+ // No transformation, so return the source point
+ public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
+ if (dstPt == null)
+ dstPt = new Point2D.Float();
+ dstPt.setLocation(srcPt.getX(), srcPt.getY());
+ return dstPt;
+ }
+
+ // No transformation, so return the source bounds
+ public Rectangle2D getBounds2D(BufferedImage src) {
+ return src.getRaster().getBounds();
+ }
+}
\ No newline at end of file
Added: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/GIFEncoder.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/GIFEncoder.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/GIFEncoder.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -0,0 +1,554 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Helma License Notice
+ *
+ * The contents of this file are subject to the Helma License
+ * Version 2.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://adele.helma.org/download/helma/license.txt
+ *
+ * Copyright 1998-2003 Helma Software. All Rights Reserved.
+ *
+ * $RCSfile: GIFEncoder.java,v $
+ * $Author: alexsmirnov $
+ * $Revision: 1.1.2.1 $
+ * $Date: 2007/01/09 18:59:03 $
+ */
+
+/*
+ * The GIF encoding routines are based on the Acme libary
+ *
+ * The following addaptions and extensions were added by Joerg Lehni:
+ *
+ * - encode now directly works on BufferedImage objects, the ImageEncoder
+ * and ImageConsumer oriented frameworks has been removed.
+ * - Only BufferedImages with IndexColorModel are taken, so no more
+ * palette optimization with IntHashtable objects are necessary. If the
+ * BufferedImage is in wrong format, helma.image.Quantizie is used to
+ * convert it into a index based image.
+ * - This version is much less space consuming as it only takes one sample
+ * row of the rastered image at a time into memory during compression.
+ * - The overall time for color reduction and gif compression should
+ * therefore be greatly reduced.
+ *
+ * Acme Disclaimer:
+ *
+ * Transparency handling and variable bit size courtesy of Jack Palevich.
+ *
+ * Copyright (C)1996,1998 by Jef Poskanzer <jef(a)acme.com>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Visit the ACME Labs Java page for up-to-date versions of this and other
+ * fine Java utilities: http://www.acme.com/java/
+ *
+ * GifEncoder is adapted from ppmtogif, which is based on GIFENCOD by David
+ * Rowley <mgardi(a)watdscu.waterloo.edu>. Lempel-Zim compression
+ * based on "compress".
+ *
+ */
+
+package org.ajax4jsf.resource.image;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
+import java.awt.image.Raster;
+import java.io.DataOutput;
+import java.io.IOException;
+
+public class GIFEncoder {
+ private boolean interlace = false;
+
+ private int width, height;
+ private Raster raster;
+ // DataOutput is used for compatibility with ImageIO (see helma.image.imageio.gif.GIFImageWriter)
+ // otherwise, OutputStream would make much more sense here:
+ private DataOutput out;
+
+ private int curx, cury;
+ private int countdown;
+ private int pass;
+ private int[] row;
+
+ public void encode(BufferedImage bi, DataOutput out) throws IOException {
+ encode(bi, out, false, null);
+ }
+
+ public void encode(BufferedImage bi, DataOutput out, boolean interlace,
+ String comment) throws IOException {
+ this.out = out;
+ this.interlace = interlace;
+
+ // make sure it's index colors:
+ if (bi.getType() != BufferedImage.TYPE_BYTE_INDEXED)
+ bi = Quantize.process(bi, 256, false, true);
+
+ raster = bi.getRaster();
+
+ width = bi.getWidth();
+ height = bi.getHeight();
+
+ int numPixels = width * height;
+
+ IndexColorModel icm = (IndexColorModel) bi.getColorModel();
+ int transparentIndex = icm.getTransparentPixel();
+ int numColors = icm.getMapSize();
+
+ // Figure out how many bits to use.
+ int bitsPerPixel;
+ if (numColors <= 2)
+ bitsPerPixel = 1;
+ else if (numColors <= 4)
+ bitsPerPixel = 2;
+ else if (numColors <= 16)
+ bitsPerPixel = 4;
+ else
+ bitsPerPixel = 8;
+
+ int initCodeSize;
+
+ // Calculate number of bits we are expecting
+ countdown = numPixels;
+
+ // Indicate which pass we are on (if interlace)
+ pass = 0;
+
+ // The initial code size
+ if (bitsPerPixel <= 1)
+ initCodeSize = 2;
+ else
+ initCodeSize = bitsPerPixel;
+
+ // Set up the current x and y position
+ curx = 0;
+ cury = 0;
+ row = new int[width];
+
+ // Write the Magic header
+ writeString("GIF89a");
+
+ // Write out the screen width and height
+ writeWord(width);
+ writeWord(height);
+
+ // Indicate that there is a global colour map
+ byte flags = (byte) 0x80; // Yes, there is a color map
+ // OR in the resolution
+ flags |= (byte) ((8 - 1) << 4);
+ // Not sorted
+ // OR in the Bits per Pixel
+ flags |= (byte) ((bitsPerPixel - 1));
+ // Write it out
+ out.write(flags);
+
+ // Write out the Background colour
+ out.write((byte) 0);
+
+ // Pixel aspect ratio - 1:1.
+ //out.write((byte) 49);
+ // Java's GIF reader currently has a bug, if the aspect ratio byte is
+ // not zero it throws an ImageFormatException. It doesn't know that
+ // 49 means a 1:1 aspect ratio. Well, whatever, zero works with all
+ // the other decoders I've tried so it probably doesn't hurt.
+ out.write((byte) 0);
+
+ // Write out the Global Colour Map
+ // Turn colors into colormap entries.
+ int mapSize = 1 << bitsPerPixel;
+ byte[] reds = new byte[mapSize], greens = new byte[mapSize], blues = new byte[mapSize];
+ icm.getReds(reds);
+ icm.getGreens(greens);
+ icm.getBlues(blues);
+
+ for (int i = 0; i < mapSize; ++i) {
+ out.write(reds[i]);
+ out.write(greens[i]);
+ out.write(blues[i]);
+ }
+
+ // Write out extension for transparent colour index, if necessary.
+ if (transparentIndex != -1) {
+ out.write((byte) '!');
+ out.write((byte) 0xf9);
+ out.write((byte) 4);
+ out.write((byte) 1);
+ out.write((byte) 0);
+ out.write((byte) 0);
+ out.write((byte) transparentIndex);
+ out.write((byte) 0);
+ }
+
+ // Write an Image separator
+ out.write((byte) ',');
+
+ // Write the Image header
+ writeWord(0); // leftOfs
+ writeWord(0); // topOfs
+ writeWord(width);
+ writeWord(height);
+
+ // Write out whether or not the image is interlaced
+ if (interlace)
+ out.write((byte) 0x40);
+ else
+ out.write((byte) 0x00);
+
+ // Write out the initial code size
+ out.write((byte) initCodeSize);
+
+ // Go and actually compress the data
+ compress(initCodeSize + 1);
+
+ // Write out a Zero-length packet (to end the series)
+ out.write((byte) 0);
+
+ // Write out the comment
+ if (comment != null && comment.length() > 0) {
+ out.write((byte) 0x21);
+ out.write((byte) 0xFE);
+ out.write((byte) comment.length());
+ writeString(comment);
+ out.write((byte) 0);
+ }
+
+ // Write the GIF file terminator
+ out.write((byte) ';');
+ }
+
+ // Return the next pixel from the image
+ int getNextPixel() throws IOException {
+ if (countdown == 0)
+ return -1;
+
+ --countdown;
+
+ if (curx == 0)
+ row = raster.getSamples(0, cury, width, 1, 0, row);
+ int index = row[curx];
+
+ // Bump the current X position
+ ++curx;
+
+ // If we are at the end of a scan line, set curx back to the beginning
+ // If we are interlaced, bump the cury to the appropriate spot,
+ // otherwise, just increment it.
+ if (curx == width) {
+ curx = 0;
+
+ if (!interlace) {
+ ++cury;
+ } else {
+ switch (pass) {
+ case 0:
+ cury += 8;
+ if (cury >= height) {
+ ++pass;
+ cury = 4;
+ }
+ break;
+
+ case 1:
+ cury += 8;
+ if (cury >= height) {
+ ++pass;
+ cury = 2;
+ }
+ break;
+
+ case 2:
+ cury += 4;
+ if (cury >= height) {
+ ++pass;
+ cury = 1;
+ }
+ break;
+
+ case 3:
+ cury += 2;
+ break;
+ }
+ }
+ }
+ return index;
+ }
+
+ void writeString(String str) throws IOException {
+ byte[] buf = str.getBytes();
+ out.write(buf);
+ }
+
+ // Write out a word to the GIF file
+ void writeWord(int w) throws IOException {
+ out.write((byte) (w & 0xff));
+ out.write((byte) ((w >> 8) & 0xff));
+ }
+
+ // GIFCOMPR.C - GIF Image compression routines
+ //
+ // Lempel-Ziv compression based on 'compress'. GIF modifications by
+ // David Rowley (mgardi(a)watdcsu.waterloo.edu)
+
+ // General DEFINEs
+
+ static final int BITS = 12;
+
+ static final int HASH_SIZE = 5003; // 80% occupancy
+
+ // GIF Image compression - modified 'compress'
+ //
+ // Based on: compress.c - File compression ala IEEE Computer, June 1984.
+ //
+ // By Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
+ // Jim McKie (decvax!mcvax!jim)
+ // Steve Davies (decvax!vax135!petsd!peora!srd)
+ // Ken Turkowski (decvax!decwrl!turtlevax!ken)
+ // James A. Woods (decvax!ihnp4!ames!jaw)
+ // Joe Orost (decvax!vax135!petsd!joe)
+
+ private int numBits; // number of bits/code
+ private int maxBits = BITS; // user settable max # bits/code
+ private int maxCode; // maximum code, given numBits
+ private int maxMaxCode = 1 << BITS; // should NEVER generate this code
+
+ final int getMaxCode(int numBits) {
+ return (1 << numBits) - 1;
+ }
+
+ private int[] hashTable = new int[HASH_SIZE];
+ private int[] codeTable = new int[HASH_SIZE];
+
+ private int freeEntry = 0; // first unused entry
+
+ // block compression parameters -- after all codes are used up,
+ // and compression rate changes, start over.
+ private boolean clearFlag = false;
+
+ // Algorithm: use open addressing double hashing (no chaining) on the
+ // prefix code / next character combination. We do a variant of Knuth's
+ // algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
+ // secondary probe. Here, the modular division first probe is gives way
+ // to a faster exclusive-or manipulation. Also do block compression with
+ // an adaptive reset, whereby the code table is cleared when the compression
+ // ratio decreases, but after the table fills. The variable-length output
+ // codes are re-sized at this point, and a special CLEAR code is generated
+ // for the decompressor. Late addition: construct the table according to
+ // file size for noticeable speed improvement on small files. Please direct
+ // questions about this implementation to ames!jaw.
+
+ private int initBits;
+
+ private int clearCode;
+ private int EOFCode;
+
+ void compress(int initBits) throws IOException {
+ // Set up the globals: initBits - initial number of bits
+ this.initBits = initBits;
+
+ // Set up the necessary values
+ clearFlag = false;
+ numBits = initBits;
+ maxCode = getMaxCode(numBits);
+
+ clearCode = 1 << (initBits - 1);
+ EOFCode = clearCode + 1;
+ freeEntry = clearCode + 2;
+
+ charInit();
+
+ int ent = getNextPixel();
+
+ int hashShift = 0;
+ for (int fcode = HASH_SIZE; fcode < 65536; fcode *= 2)
+ ++hashShift;
+ hashShift = 8 - hashShift; // set hash code range bound
+
+ clearHash(); // clear hash table
+
+ output(clearCode);
+
+ int c;
+ outerLoop: while ((c = getNextPixel()) != -1) {
+ int fcode = (c << maxBits) + ent;
+ int i = (c << hashShift) ^ ent; // xor hashing
+
+ if (hashTable[i] == fcode) {
+ ent = codeTable[i];
+ continue;
+ } else if (hashTable[i] >= 0) { // non-empty slot
+ int disp = HASH_SIZE - i; // secondary hash (after G. Knott)
+ if (i == 0)
+ disp = 1;
+ do {
+ if ((i -= disp) < 0)
+ i += HASH_SIZE;
+
+ if (hashTable[i] == fcode) {
+ ent = codeTable[i];
+ continue outerLoop;
+ }
+ } while (hashTable[i] >= 0);
+ }
+ output(ent);
+ ent = c;
+ if (freeEntry < maxMaxCode) {
+ codeTable[i] = freeEntry++; // code -> hashtable
+ hashTable[i] = fcode;
+ } else
+ clearBlock();
+ }
+ // Put out the final code.
+ output(ent);
+ output(EOFCode);
+ }
+
+ // output
+ //
+ // Output the given code.
+ // Inputs:
+ // code: A numBits-bit integer. If == -1, then EOF. This assumes
+ // that numBits =< wordsize - 1.
+ // Outputs:
+ // Outputs code to the file.
+ // Assumptions:
+ // Chars are 8 bits long.
+ // Algorithm:
+ // Maintain a BITS character long buffer (so that 8 codes will
+ // fit in it exactly). Use the VAX insv instruction to insert each
+ // code in turn. When the buffer fills up empty it and start over.
+
+ int curAccum = 0;
+ int curBits = 0;
+
+ int masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F,
+ 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF,
+ 0x7FFF, 0xFFFF };
+
+ void output(int code) throws IOException {
+ curAccum &= masks[curBits];
+
+ if (curBits > 0)
+ curAccum |= (code << curBits);
+ else
+ curAccum = code;
+
+ curBits += numBits;
+
+ while (curBits >= 8) {
+ charOut((byte) (curAccum & 0xff));
+ curAccum >>= 8;
+ curBits -= 8;
+ }
+
+ // If the next entry is going to be too big for the code size,
+ // then increase it, if possible.
+ if (freeEntry > maxCode || clearFlag) {
+ if (clearFlag) {
+ maxCode = getMaxCode(numBits = initBits);
+ clearFlag = false;
+ } else {
+ ++numBits;
+ if (numBits == maxBits)
+ maxCode = maxMaxCode;
+ else
+ maxCode = getMaxCode(numBits);
+ }
+ }
+
+ if (code == EOFCode) {
+ // At EOF, write the rest of the buffer.
+ while (curBits > 0) {
+ charOut((byte) (curAccum & 0xff));
+ curAccum >>= 8;
+ curBits -= 8;
+ }
+
+ charFlush();
+ }
+ }
+
+ // Clear out the hash table
+
+ // table clear for block compress
+ void clearBlock() throws IOException {
+ clearHash();
+ freeEntry = clearCode + 2;
+ clearFlag = true;
+
+ output(clearCode);
+ }
+
+ // reset code table
+ void clearHash() {
+ for (int i = 0; i < HASH_SIZE; ++i)
+ hashTable[i] = -1;
+ }
+
+ // GIF Specific routines
+
+ // Number of characters so far in this 'packet'
+ private int a_count;
+
+ // Set up the 'byte output' routine
+ void charInit() {
+ a_count = 0;
+ }
+
+ // Define the storage for the packet accumulator
+ private byte[] accum = new byte[256];
+
+ // Add a character to the end of the current packet, and if it is 254
+ // characters, flush the packet to disk.
+ void charOut(byte c) throws IOException {
+ accum[a_count++] = c;
+ if (a_count >= 254)
+ charFlush();
+ }
+
+ // Flush the packet to disk, and reset the accumulator
+ void charFlush() throws IOException {
+ if (a_count > 0) {
+ out.write(a_count);
+ out.write(accum, 0, a_count);
+ a_count = 0;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/ImageInfo.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/ImageInfo.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/ImageInfo.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -0,0 +1,1309 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * ImageInfo.java
+ *
+ * Version 1.5
+ *
+ * A Java class to determine image width, height and color depth for
+ * a number of image file formats.
+ *
+ * Written by Marco Schmidt
+ * <http://www.geocities.com/marcoschmidt.geo/contact.html>.
+ *
+ * Contributed to the Public Domain.
+ *
+ * Last modification 2004-02-29
+ */
+
+package org.ajax4jsf.resource.image;
+
+import java.io.DataInput;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Vector;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * Get file format, image resolution, number of bits per pixel and optionally
+ * number of images, comments and physical resolution from
+ * JPEG, GIF, BMP, PCX, PNG, IFF, RAS, PBM, PGM, PPM, PSD and SWF files
+ * (or input streams).
+ * <p>
+ * Use the class like this:
+ * <pre>
+ * ImageInfo ii = new ImageInfo();
+ * ii.setInput(in); // in can be InputStream or RandomAccessFile
+ * ii.setDetermineImageNumber(true); // default is false
+ * ii.setCollectComments(true); // default is false
+ * if (!ii.check()) {
+ * System.err.println("Not a supported image file format.");
+ * return;
+ * }
+ * System.out.println(ii.getFormatName() + ", " + ii.getMimeType() +
+ * ", " + ii.getWidth() + " x " + ii.getHeight() + " pixels, " +
+ * ii.getBitsPerPixel() + " bits per pixel, " + ii.getNumberOfImages() +
+ * " image(s), " + ii.getNumberOfComments() + " comment(s).");
+ * // there are other properties, check out the API documentation
+ * </pre>
+ * You can also use this class as a command line program.
+ * Call it with a number of image file names and URLs as parameters:
+ * <pre>
+ * java ImageInfo *.jpg *.png *.gif http://somesite.tld/image.jpg
+ * </pre>
+ * or call it without parameters and pipe data to it:
+ * <pre>
+ * java ImageInfo < image.jpg
+ * </pre>
+ * <p>
+ * Known limitations:
+ * <ul>
+ * <li>When the determination of the number of images is turned off, GIF bits
+ * per pixel are only read from the global header.
+ * For some GIFs, local palettes change this to a typically larger
+ * value. To be certain to get the correct color depth, call
+ * setDetermineImageNumber(true) before calling check().
+ * The complete scan over the GIF file will take additional time.</li>
+ * <li>Transparency information is not included in the bits per pixel count.
+ * Actually, it was my decision not to include those bits, so it's a feature! ;-)</li>
+ * </ul>
+ * <p>
+ * Requirements:
+ * <ul>
+ * <li>Java 1.1 or higher</li>
+ * </ul>
+ * <p>
+ * The latest version can be found at <a href="http://www.geocities.com/marcoschmidt.geo/image-info.html">http://www.geocities.com/marcoschmidt.geo/image-info.html</a>.
+ * <p>
+ * Written by <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">Marco Schmidt</a>.
+ * <p>
+ * This class is contributed to the Public Domain.
+ * Use it at your own risk.
+ * <p>
+ * Last modification 2004-02-29.
+ * <p>
+ * History:
+ * <ul>
+ * <li><strong>2001-08-24</strong> Initial version.</li>
+ * <li><strong>2001-10-13</strong> Added support for the file formats BMP and PCX.</li>
+ * <li><strong>2001-10-16</strong> Fixed bug in read(int[], int, int) that returned
+ * <li><strong>2002-01-22</strong> Added support for file formats Amiga IFF and Sun Raster (RAS).</li>
+ * <li><strong>2002-01-24</strong> Added support for file formats Portable Bitmap / Graymap / Pixmap (PBM, PGM, PPM) and Adobe Photoshop (PSD).
+ * Added new method getMimeType() to return the MIME type associated with a particular file format.</li>
+ * <li><strong>2002-03-15</strong> Added support to recognize number of images in file. Only works with GIF.
+ * Use {@link #setDetermineImageNumber} with <code>true</code> as argument to identify animated GIFs
+ * ({@link #getNumberOfImages()} will return a value larger than <code>1</code>).</li>
+ * <li><strong>2002-04-10</strong> Fixed a bug in the feature 'determine number of images in animated GIF' introduced with version 1.1.
+ * Thanks to Marcelo P. Lima for sending in the bug report.
+ * Released as 1.1.1.</li>
+ * <li><strong>2002-04-18</strong> Added {@link #setCollectComments(boolean)}.
+ * That new method lets the user specify whether textual comments are to be
+ * stored in an internal list when encountered in an input image file / stream.
+ * Added two methods to return the physical width and height of the image in dpi:
+ * {@link #getPhysicalWidthDpi()} and {@link #getPhysicalHeightDpi()}.
+ * If the physical resolution could not be retrieved, these methods return <code>-1</code>.
+ * </li>
+ * <li><strong>2002-04-23</strong> Added support for the new properties physical resolution and
+ * comments for some formats. Released as 1.2.</li>
+ * <li><strong>2002-06-17</strong> Added support for SWF, sent in by Michael Aird.
+ * Changed checkJpeg() so that other APP markers than APP0 will not lead to a failure anymore.
+ * Released as 1.3.</li>
+ * <li><strong>2003-07-28</strong> Bug fix - skip method now takes return values into consideration.
+ * Less bytes than necessary may have been skipped, leading to flaws in the retrieved information in some cases.
+ * Thanks to Bernard Bernstein for pointing that out.
+ * Released as 1.4.</li>
+ * <li><strong>2004-02-29</strong> Added support for recognizing progressive JPEG and
+ * interlaced PNG and GIF. A new method {@link #isProgressive()} returns whether ImageInfo
+ * has found that the storage type is progressive (or interlaced).
+ * Thanks to Joe Germuska for suggesting the feature.
+ * Bug fix: BMP physical resolution is now correctly determined.
+ * Released as 1.5.</li>
+ * </ul>
+ */
+public class ImageInfo {
+ /**
+ * Return value of {@link #getFormat()} for JPEG streams.
+ * ImageInfo can extract physical resolution and comments
+ * from JPEGs (only from APP0 headers).
+ * Only one image can be stored in a file.
+ * It is determined whether the JPEG stream is progressive
+ * (see {@link #isProgressive()}).
+ */
+ public static final int FORMAT_JPEG = 0;
+
+ /**
+ * Return value of {@link #getFormat()} for GIF streams.
+ * ImageInfo can extract comments from GIFs and count the number
+ * of images (GIFs with more than one image are animations).
+ * If you know of a place where GIFs store the physical resolution
+ * of an image, please
+ * <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">send me a mail</a>!
+ * It is determined whether the GIF stream is interlaced (see {@link #isProgressive()}).
+ */
+ public static final int FORMAT_GIF = 1;
+
+ /**
+ * Return value of {@link #getFormat()} for PNG streams.
+ * PNG only supports one image per file.
+ * Both physical resolution and comments can be stored with PNG,
+ * but ImageInfo is currently not able to extract those.
+ * It is determined whether the PNG stream is interlaced (see {@link #isProgressive()}).
+ */
+ public static final int FORMAT_PNG = 2;
+
+ /**
+ * Return value of {@link #getFormat()} for BMP streams.
+ * BMP only supports one image per file.
+ * BMP does not allow for comments.
+ * The physical resolution can be stored.
+ */
+ public static final int FORMAT_BMP = 3;
+
+ /**
+ * Return value of {@link #getFormat()} for PCX streams.
+ * PCX does not allow for comments or more than one image per file.
+ * However, the physical resolution can be stored.
+ */
+ public static final int FORMAT_PCX = 4;
+
+ /**
+ * Return value of {@link #getFormat()} for IFF streams.
+ */
+ public static final int FORMAT_IFF = 5;
+
+ /**
+ * Return value of {@link #getFormat()} for RAS streams.
+ * Sun Raster allows for one image per file only and is not able to
+ * store physical resolution or comments.
+ */
+ public static final int FORMAT_RAS = 6;
+
+ /** Return value of {@link #getFormat()} for PBM streams. */
+ public static final int FORMAT_PBM = 7;
+
+ /** Return value of {@link #getFormat()} for PGM streams. */
+ public static final int FORMAT_PGM = 8;
+
+ /** Return value of {@link #getFormat()} for PPM streams. */
+ public static final int FORMAT_PPM = 9;
+
+ /** Return value of {@link #getFormat()} for PSD streams. */
+ public static final int FORMAT_PSD = 10;
+
+ /** Return value of {@link #getFormat()} for SWF (Shockwave) streams. */
+ public static final int FORMAT_SWF = 11;
+
+ public static final int COLOR_TYPE_UNKNOWN = -1;
+ public static final int COLOR_TYPE_TRUECOLOR_RGB = 0;
+ public static final int COLOR_TYPE_PALETTED = 1;
+ public static final int COLOR_TYPE_GRAYSCALE= 2;
+ public static final int COLOR_TYPE_BLACK_AND_WHITE = 3;
+
+ /**
+ * The names of all supported file formats.
+ * The FORMAT_xyz int constants can be used as index values for
+ * this array.
+ */
+ private static final String[] FORMAT_NAMES =
+ {"JPEG", "GIF", "PNG", "BMP", "PCX",
+ "IFF", "RAS", "PBM", "PGM", "PPM",
+ "PSD", "SWF"};
+
+ /**
+ * The names of the MIME types for all supported file formats.
+ * The FORMAT_xyz int constants can be used as index values for
+ * this array.
+ */
+ private static final String[] MIME_TYPE_STRINGS =
+ {"image/jpeg", "image/gif", "image/png", "image/bmp", "image/pcx",
+ "image/iff", "image/ras", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap",
+ "image/psd", "application/x-shockwave-flash"};
+
+ private int width;
+ private int height;
+ private int bitsPerPixel;
+ private int colorType = COLOR_TYPE_UNKNOWN;
+ private boolean progressive;
+ private int format;
+ private InputStream in;
+ private DataInput din;
+ private boolean collectComments = true;
+ private Vector comments;
+ private boolean determineNumberOfImages;
+ private int numberOfImages;
+ private int physicalHeightDpi;
+ private int physicalWidthDpi;
+ private int bitBuf;
+ private int bitPos;
+
+ private void addComment(String s) {
+ if (comments == null) {
+ comments = new Vector();
+ }
+ comments.addElement(s);
+ }
+
+ /**
+ * Call this method after you have provided an input stream or file
+ * using {@link #setInput(InputStream)} or {@link #setInput(DataInput)}.
+ * If true is returned, the file format was known and information
+ * on the file's content can be retrieved using the various getXyz methods.
+ * @return if information could be retrieved from input
+ */
+ public boolean check() {
+ format = -1;
+ width = -1;
+ height = -1;
+ bitsPerPixel = -1;
+ numberOfImages = 1;
+ physicalHeightDpi = -1;
+ physicalWidthDpi = -1;
+ comments = null;
+ try {
+ int b1 = read() & 0xff;
+ int b2 = read() & 0xff;
+ if (b1 == 0x47 && b2 == 0x49) {
+ return checkGif();
+ }
+ else
+ if (b1 == 0x89 && b2 == 0x50) {
+ return checkPng();
+ }
+ else
+ if (b1 == 0xff && b2 == 0xd8) {
+ return checkJpeg();
+ }
+ else
+ if (b1 == 0x42 && b2 == 0x4d) {
+ return checkBmp();
+ }
+ else
+ if (b1 == 0x0a && b2 < 0x06) {
+ return checkPcx();
+ }
+ else
+ if (b1 == 0x46 && b2 == 0x4f) {
+ return checkIff();
+ }
+ else
+ if (b1 == 0x59 && b2 == 0xa6) {
+ return checkRas();
+ }
+ else
+ if (b1 == 0x50 && b2 >= 0x31 && b2 <= 0x36) {
+ return checkPnm(b2 - '0');
+ }
+ else
+ if (b1 == 0x38 && b2 == 0x42) {
+ return checkPsd();
+ }
+ else
+ if (b1 == 0x46 && b2 == 0x57) {
+ return checkSwf();
+ }
+ else {
+ return false;
+ }
+ } catch (IOException ioe) {
+ return false;
+ }
+ }
+
+ private boolean checkBmp() throws IOException {
+ byte[] a = new byte[44];
+ if (read(a) != a.length) {
+ return false;
+ }
+ width = getIntLittleEndian(a, 16);
+ height = getIntLittleEndian(a, 20);
+ if (width < 1 || height < 1) {
+ return false;
+ }
+ bitsPerPixel = getShortLittleEndian(a, 26);
+ if (bitsPerPixel != 1 && bitsPerPixel != 4 &&
+ bitsPerPixel != 8 && bitsPerPixel != 16 &&
+ bitsPerPixel != 24 && bitsPerPixel != 32) {
+ return false;
+ }
+ int x = (int)(getIntLittleEndian(a, 36) * 0.0254);
+ if (x > 0) {
+ setPhysicalWidthDpi(x);
+ }
+ int y = (int)(getIntLittleEndian(a, 40) * 0.0254);
+ if (y > 0) {
+ setPhysicalHeightDpi(y);
+ }
+ format = FORMAT_BMP;
+ return true;
+ }
+
+ private boolean checkGif() throws IOException {
+ final byte[] GIF_MAGIC_87A = {0x46, 0x38, 0x37, 0x61};
+ final byte[] GIF_MAGIC_89A = {0x46, 0x38, 0x39, 0x61};
+ byte[] a = new byte[11]; // 4 from the GIF signature + 7 from the global header
+ if (read(a) != 11) {
+ return false;
+ }
+ if ((!equals(a, 0, GIF_MAGIC_89A, 0, 4)) &&
+ (!equals(a, 0, GIF_MAGIC_87A, 0, 4))) {
+ return false;
+ }
+ format = FORMAT_GIF;
+ width = getShortLittleEndian(a, 4);
+ height = getShortLittleEndian(a, 6);
+ int flags = a[8] & 0xff;
+ bitsPerPixel = ((flags >> 4) & 0x07) + 1;
+ progressive = (flags & 0x02) != 0;
+ if (!determineNumberOfImages) {
+ return true;
+ }
+ // skip global color palette
+ if ((flags & 0x80) != 0) {
+ int tableSize = (1 << ((flags & 7) + 1)) * 3;
+ skip(tableSize);
+ }
+ numberOfImages = 0;
+ int blockType;
+ do
+ {
+ blockType = read();
+ switch(blockType)
+ {
+ case(0x2c): // image separator
+ {
+ if (read(a, 0, 9) != 9) {
+ return false;
+ }
+ flags = a[8] & 0xff;
+ int localBitsPerPixel = (flags & 0x07) + 1;
+ if (localBitsPerPixel > bitsPerPixel) {
+ bitsPerPixel = localBitsPerPixel;
+ }
+ if ((flags & 0x80) != 0) {
+ skip((1 << localBitsPerPixel) * 3);
+ }
+ skip(1); // initial code length
+ int n;
+ do
+ {
+ n = read();
+ if (n > 0) {
+ skip(n);
+ }
+ else
+ if (n == -1) {
+ return false;
+ }
+ }
+ while (n > 0);
+ numberOfImages++;
+ break;
+ }
+ case(0x21): // extension
+ {
+ int extensionType = read();
+ if (collectComments && extensionType == 0xfe) {
+ StringBuffer sb = new StringBuffer();
+ int n;
+ do
+ {
+ n = read();
+ if (n == -1) {
+ return false;
+ }
+ if (n > 0) {
+ for (int i = 0; i < n; i++) {
+ int ch = read();
+ if (ch == -1) {
+ return false;
+ }
+ sb.append((char)ch);
+ }
+ }
+ }
+ while (n > 0);
+ } else {
+ int n;
+ do
+ {
+ n = read();
+ if (n > 0) {
+ skip(n);
+ }
+ else
+ if (n == -1) {
+ return false;
+ }
+ }
+ while (n > 0);
+ }
+ break;
+ }
+ case(0x3b): // end of file
+ {
+ break;
+ }
+ default:
+ {
+ return false;
+ }
+ }
+ }
+ while (blockType != 0x3b);
+ return true;
+ }
+
+ private boolean checkIff() throws IOException {
+ byte[] a = new byte[10];
+ // read remaining 2 bytes of file id, 4 bytes file size
+ // and 4 bytes IFF subformat
+ if (read(a, 0, 10) != 10) {
+ return false;
+ }
+ final byte[] IFF_RM = {0x52, 0x4d};
+ if (!equals(a, 0, IFF_RM, 0, 2)) {
+ return false;
+ }
+ int type = getIntBigEndian(a, 6);
+ if (type != 0x494c424d && // type must be ILBM...
+ type != 0x50424d20) { // ...or PBM
+ return false;
+ }
+ // loop chunks to find BMHD chunk
+ do {
+ if (read(a, 0, 8) != 8) {
+ return false;
+ }
+ int chunkId = getIntBigEndian(a, 0);
+ int size = getIntBigEndian(a, 4);
+ if ((size & 1) == 1) {
+ size++;
+ }
+ if (chunkId == 0x424d4844) { // BMHD chunk
+ if (read(a, 0, 9) != 9) {
+ return false;
+ }
+ format = FORMAT_IFF;
+ width = getShortBigEndian(a, 0);
+ height = getShortBigEndian(a, 2);
+ bitsPerPixel = a[8] & 0xff;
+ return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel < 33);
+ } else {
+ skip(size);
+ }
+ } while (true);
+ }
+
+ private boolean checkJpeg() throws IOException {
+ byte[] data = new byte[12];
+ while (true) {
+ if (read(data, 0, 4) != 4) {
+ return false;
+ }
+ int marker = getShortBigEndian(data, 0);
+ int size = getShortBigEndian(data, 2);
+ if ((marker & 0xff00) != 0xff00) {
+ return false; // not a valid marker
+ }
+ if (marker == 0xffe0) { // APPx
+ if (size < 14) {
+ return false; // APPx header must be >= 14 bytes
+ }
+ if (read(data, 0, 12) != 12) {
+ return false;
+ }
+ final byte[] APP0_ID = {0x4a, 0x46, 0x49, 0x46, 0x00};
+ if (equals(APP0_ID, 0, data, 0, 5)) {
+ //System.out.println("data 7=" + data[7]);
+ if (data[7] == 1) {
+ setPhysicalWidthDpi(getShortBigEndian(data, 8));
+ setPhysicalHeightDpi(getShortBigEndian(data, 10));
+ }
+ else
+ if (data[7] == 2) {
+ int x = getShortBigEndian(data, 8);
+ int y = getShortBigEndian(data, 10);
+ setPhysicalWidthDpi((int)(x * 2.54f));
+ setPhysicalHeightDpi((int)(y * 2.54f));
+ }
+ }
+ skip(size - 14);
+ }
+ else
+ if (collectComments && size > 2 && marker == 0xfffe) { // comment
+ size -= 2;
+ byte[] chars = new byte[size];
+ if (read(chars, 0, size) != size) {
+ return false;
+ }
+ String comment = new String(chars, "iso-8859-1");
+ comment = comment.trim();
+ addComment(comment);
+ }
+ else
+ if (marker >= 0xffc0 && marker <= 0xffcf && marker != 0xffc4 && marker != 0xffc8) {
+ if (read(data, 0, 6) != 6) {
+ return false;
+ }
+ format = FORMAT_JPEG;
+ bitsPerPixel = (data[0] & 0xff) * (data[5] & 0xff);
+ progressive = marker == 0xffc2 || marker == 0xffc6 ||
+ marker == 0xffca || marker == 0xffce;
+ width = getShortBigEndian(data, 3);
+ height = getShortBigEndian(data, 1);
+ return true;
+ } else {
+ skip(size - 2);
+ }
+ }
+ }
+
+ private boolean checkPcx() throws IOException {
+ byte[] a = new byte[64];
+ if (read(a) != a.length) {
+ return false;
+ }
+ if (a[0] != 1) { // encoding, 1=RLE is only valid value
+ return false;
+ }
+ // width / height
+ int x1 = getShortLittleEndian(a, 2);
+ int y1 = getShortLittleEndian(a, 4);
+ int x2 = getShortLittleEndian(a, 6);
+ int y2 = getShortLittleEndian(a, 8);
+ if (x1 < 0 || x2 < x1 || y1 < 0 || y2 < y1) {
+ return false;
+ }
+ width = x2 - x1 + 1;
+ height = y2 - y1 + 1;
+ // color depth
+ int bits = a[1];
+ int planes = a[63];
+ if (planes == 1 &&
+ (bits == 1 || bits == 2 || bits == 4 || bits == 8)) {
+ // paletted
+ bitsPerPixel = bits;
+ } else
+ if (planes == 3 && bits == 8) {
+ // RGB truecolor
+ bitsPerPixel = 24;
+ } else {
+ return false;
+ }
+ setPhysicalWidthDpi(getShortLittleEndian(a, 10));
+ setPhysicalHeightDpi(getShortLittleEndian(a, 10));
+ format = FORMAT_PCX;
+ return true;
+ }
+
+ private boolean checkPng() throws IOException {
+ final byte[] PNG_MAGIC = {0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a};
+ byte[] a = new byte[27];
+ if (read(a) != 27) {
+ return false;
+ }
+ if (!equals(a, 0, PNG_MAGIC, 0, 6)) {
+ return false;
+ }
+ format = FORMAT_PNG;
+ width = getIntBigEndian(a, 14);
+ height = getIntBigEndian(a, 18);
+ bitsPerPixel = a[22] & 0xff;
+ int colorType = a[23] & 0xff;
+ if (colorType == 2 || colorType == 6) {
+ bitsPerPixel *= 3;
+ }
+ progressive = (a[26] & 0xff) != 0;
+ return true;
+ }
+
+ private boolean checkPnm(int id) throws IOException {
+ if (id < 1 || id > 6) {
+ return false;
+ }
+ final int[] PNM_FORMATS = {FORMAT_PBM, FORMAT_PGM, FORMAT_PPM};
+ format = PNM_FORMATS[(id - 1) % 3];
+ boolean hasPixelResolution = false;
+ String s;
+ while (true)
+ {
+ s = readLine();
+ if (s != null) {
+ s = s.trim();
+ }
+ if (s == null || s.length() < 1) {
+ continue;
+ }
+ if (s.charAt(0) == '#') { // comment
+ if (collectComments && s.length() > 1) {
+ addComment(s.substring(1));
+ }
+ continue;
+ }
+ if (!hasPixelResolution) { // split "343 966" into width=343, height=966
+ int spaceIndex = s.indexOf(' ');
+ if (spaceIndex == -1) {
+ return false;
+ }
+ String widthString = s.substring(0, spaceIndex);
+ spaceIndex = s.lastIndexOf(' ');
+ if (spaceIndex == -1) {
+ return false;
+ }
+ String heightString = s.substring(spaceIndex + 1);
+ try {
+ width = Integer.parseInt(widthString);
+ height = Integer.parseInt(heightString);
+ } catch (NumberFormatException nfe) {
+ return false;
+ }
+ if (width < 1 || height < 1) {
+ return false;
+ }
+ if (format == FORMAT_PBM) {
+ bitsPerPixel = 1;
+ return true;
+ }
+ hasPixelResolution = true;
+ }
+ else
+ {
+ int maxSample;
+ try {
+ maxSample = Integer.parseInt(s);
+ } catch (NumberFormatException nfe) {
+ return false;
+ }
+ if (maxSample < 0) {
+ return false;
+ }
+ for (int i = 0; i < 25; i++) {
+ if (maxSample < (1 << (i + 1))) {
+ bitsPerPixel = i + 1;
+ if (format == FORMAT_PPM) {
+ bitsPerPixel *= 3;
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+ }
+
+ private boolean checkPsd() throws IOException {
+ byte[] a = new byte[24];
+ if (read(a) != a.length) {
+ return false;
+ }
+ final byte[] PSD_MAGIC = {0x50, 0x53};
+ if (!equals(a, 0, PSD_MAGIC, 0, 2)) {
+ return false;
+ }
+ format = FORMAT_PSD;
+ width = getIntBigEndian(a, 16);
+ height = getIntBigEndian(a, 12);
+ int channels = getShortBigEndian(a, 10);
+ int depth = getShortBigEndian(a, 20);
+ bitsPerPixel = channels * depth;
+ return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel <= 64);
+ }
+
+ private boolean checkRas() throws IOException {
+ byte[] a = new byte[14];
+ if (read(a) != a.length) {
+ return false;
+ }
+ final byte[] RAS_MAGIC = {0x6a, (byte)0x95};
+ if (!equals(a, 0, RAS_MAGIC, 0, 2)) {
+ return false;
+ }
+ format = FORMAT_RAS;
+ width = getIntBigEndian(a, 2);
+ height = getIntBigEndian(a, 6);
+ bitsPerPixel = getIntBigEndian(a, 10);
+ return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel <= 24);
+ }
+
+ // Written by Michael Aird.
+ private boolean checkSwf() throws IOException {
+ //get rid of the last byte of the signature, the byte of the version and 4 bytes of the size
+ byte[] a = new byte[6];
+ if (read(a) != a.length) {
+ return false;
+ }
+ format = FORMAT_SWF;
+ int bitSize = (int)readUBits( 5 );
+ int minX = (int)readSBits( bitSize );
+ int maxX = (int)readSBits( bitSize );
+ int minY = (int)readSBits( bitSize );
+ int maxY = (int)readSBits( bitSize );
+ width = maxX/20; //cause we're in twips
+ height = maxY/20; //cause we're in twips
+ setPhysicalWidthDpi(72);
+ setPhysicalHeightDpi(72);
+ return (width > 0 && height > 0);
+ }
+
+ /**
+ * Run over String list, return false iff at least one of the arguments
+ * equals <code>-c</code>.
+ */
+ private static boolean determineVerbosity(String[] args) {
+ if (args != null && args.length > 0) {
+ for (int i = 0; i < args.length; i++) {
+ if ("-c".equals(args[i])) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private boolean equals(byte[] a1, int offs1, byte[] a2, int offs2, int num) {
+ while (num-- > 0) {
+ if (a1[offs1++] != a2[offs2++]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * If {@link #check()} was successful, returns the image's number of bits per pixel.
+ * Does not include transparency information like the alpha channel.
+ * @return number of bits per image pixel
+ */
+ public int getBitsPerPixel() {
+ return bitsPerPixel;
+ }
+
+ /**
+ * Returns the index'th comment retrieved from the image.
+ * @throws IllegalArgumentException if index is smaller than 0 or larger than or equal
+ * to the number of comments retrieved
+ * @see #getNumberOfComments
+ */
+ public String getComment(int index) {
+ if (comments == null || index < 0 || index >= comments.size()) {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.INVALID_COMMENT_INDEX, "" + index));
+ }
+ return (String)comments.elementAt(index);
+ }
+
+ /**
+ * If {@link #check()} was successful, returns the image format as one
+ * of the FORMAT_xyz constants from this class.
+ * Use {@link #getFormatName()} to get a textual description of the file format.
+ * @return file format as a FORMAT_xyz constant
+ */
+ public int getFormat() {
+ return format;
+ }
+
+ /**
+ * If {@link #check()} was successful, returns the image format's name.
+ * Use {@link #getFormat()} to get a unique number.
+ * @return file format name
+ */
+ public String getFormatName() {
+ if (format >= 0 && format < FORMAT_NAMES.length) {
+ return FORMAT_NAMES[format];
+ } else {
+ return "?";
+ }
+ }
+
+ /**
+ * If {@link #check()} was successful, returns one the image's vertical
+ * resolution in pixels.
+ * @return image height in pixels
+ */
+ public int getHeight() {
+ return height;
+ }
+
+ private int getIntBigEndian(byte[] a, int offs) {
+ return
+ (a[offs] & 0xff) << 24 |
+ (a[offs + 1] & 0xff) << 16 |
+ (a[offs + 2] & 0xff) << 8 |
+ a[offs + 3] & 0xff;
+ }
+
+ private int getIntLittleEndian(byte[] a, int offs) {
+ return
+ (a[offs + 3] & 0xff) << 24 |
+ (a[offs + 2] & 0xff) << 16 |
+ (a[offs + 1] & 0xff) << 8 |
+ a[offs] & 0xff;
+ }
+
+ /**
+ * If {@link #check()} was successful, returns a String with the
+ * MIME type of the format.
+ * @return MIME type, e.g. <code>image/jpeg</code>
+ */
+ public String getMimeType() {
+ if (format >= 0 && format < MIME_TYPE_STRINGS.length) {
+ if (format == FORMAT_JPEG && progressive)
+ {
+ return "image/pjpeg";
+ }
+ return MIME_TYPE_STRINGS[format];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * If {@link #check()} was successful and {@link #setCollectComments(boolean)} was called with
+ * <code>true</code> as argument, returns the number of comments retrieved
+ * from the input image stream / file.
+ * Any number >= 0 and smaller than this number of comments is then a
+ * valid argument for the {@link #getComment(int)} method.
+ * @return number of comments retrieved from input image
+ */
+ public int getNumberOfComments()
+ {
+ if (comments == null) {
+ return 0;
+ } else {
+ return comments.size();
+ }
+ }
+
+ /**
+ * Returns the number of images in the examined file.
+ * Assumes that <code>setDetermineImageNumber(true);</code> was called before
+ * a successful call to {@link #check()}.
+ * This value can currently be only different from <code>1</code> for GIF images.
+ * @return number of images in file
+ */
+ public int getNumberOfImages()
+ {
+ return numberOfImages;
+ }
+
+ /**
+ * Returns the physical height of this image in dots per inch (dpi).
+ * Assumes that {@link #check()} was successful.
+ * Returns <code>-1</code> on failure.
+ * @return physical height (in dpi)
+ * @see #getPhysicalWidthDpi()
+ * @see #getPhysicalHeightInch()
+ */
+ public int getPhysicalHeightDpi() {
+ return physicalHeightDpi;
+ }
+
+ /**
+ * If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
+ * or -1 if no value could be found.
+ * @return physical height (in dpi)
+ * @see #getPhysicalHeightDpi()
+ * @see #getPhysicalWidthDpi()
+ * @see #getPhysicalWidthInch()
+ */
+ public float getPhysicalHeightInch() {
+ int h = getHeight();
+ int ph = getPhysicalHeightDpi();
+ if (h > 0 && ph > 0) {
+ return ((float)h) / ((float)ph);
+ } else {
+ return -1.0f;
+ }
+ }
+
+ /**
+ * If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
+ * or -1 if no value could be found.
+ * @return physical width (in dpi)
+ * @see #getPhysicalHeightDpi()
+ * @see #getPhysicalWidthInch()
+ * @see #getPhysicalHeightInch()
+ */
+ public int getPhysicalWidthDpi() {
+ return physicalWidthDpi;
+ }
+
+ /**
+ * Returns the physical width of an image in inches, or
+ * <code>-1.0f</code> if width information is not available.
+ * Assumes that {@link #check} has been called successfully.
+ * @return physical width in inches or <code>-1.0f</code> on failure
+ * @see #getPhysicalWidthDpi
+ * @see #getPhysicalHeightInch
+ */
+ public float getPhysicalWidthInch() {
+ int w = getWidth();
+ int pw = getPhysicalWidthDpi();
+ if (w > 0 && pw > 0) {
+ return ((float)w) / ((float)pw);
+ } else {
+ return -1.0f;
+ }
+ }
+
+ private int getShortBigEndian(byte[] a, int offs) {
+ return
+ (a[offs] & 0xff) << 8 |
+ (a[offs + 1] & 0xff);
+ }
+
+ private int getShortLittleEndian(byte[] a, int offs) {
+ return (a[offs] & 0xff) | (a[offs + 1] & 0xff) << 8;
+ }
+
+ /**
+ * If {@link #check()} was successful, returns one the image's horizontal
+ * resolution in pixels.
+ * @return image width in pixels
+ */
+ public int getWidth() {
+ return width;
+ }
+
+ /**
+ * Returns whether the image is stored in a progressive (also called: interlaced) way.
+ * @return true for progressive/interlaced, false otherwise
+ */
+ public boolean isProgressive()
+ {
+ return progressive;
+ }
+
+ /**
+ * To use this class as a command line application, give it either
+ * some file names as parameters (information on them will be
+ * printed to standard output, one line per file) or call
+ * it with no parameters. It will then check data given to it
+ * via standard input.
+ * @param args the program arguments which must be file names
+ */
+ public static void main(String[] args) {
+ ImageInfo imageInfo = new ImageInfo();
+ imageInfo.setDetermineImageNumber(true);
+ boolean verbose = determineVerbosity(args);
+ if (args.length == 0) {
+ run(null, System.in, imageInfo, verbose);
+ } else {
+ int index = 0;
+ while (index < args.length) {
+ InputStream in = null;
+ try {
+ String name = args[index++];
+ System.out.print(name + ";");
+ if (name.startsWith("http://")) {
+ in = new URL(name).openConnection().getInputStream();
+ } else {
+ in = new FileInputStream(name);
+ }
+ run(name, in, imageInfo, verbose);
+ in.close();
+ } catch (Exception e) {
+ System.out.println(e);
+ try {
+ in.close();
+ } catch (Exception ee) {
+ }
+ }
+ }
+ }
+ }
+
+ private static void print(String sourceName, ImageInfo ii, boolean verbose) {
+ if (verbose) {
+ printVerbose(sourceName, ii);
+ } else {
+ printCompact(sourceName, ii);
+ }
+ }
+
+ private static void printCompact(String sourceName, ImageInfo imageInfo) {
+ System.out.println(
+ imageInfo.getFormatName() + ";" +
+ imageInfo.getMimeType() + ";" +
+ imageInfo.getWidth() + ";" +
+ imageInfo.getHeight() + ";" +
+ imageInfo.getBitsPerPixel() + ";" +
+ imageInfo.getNumberOfImages() + ";" +
+ imageInfo.getPhysicalWidthDpi() + ";" +
+ imageInfo.getPhysicalHeightDpi() + ";" +
+ imageInfo.getPhysicalWidthInch() + ";" +
+ imageInfo.getPhysicalHeightInch() + ";" +
+ imageInfo.isProgressive()
+ );
+ }
+
+ private static void printLine(int indentLevels, String text, float value, float minValidValue) {
+ if (value < minValidValue) {
+ return;
+ }
+ printLine(indentLevels, text, Float.toString(value));
+ }
+
+ private static void printLine(int indentLevels, String text, int value, int minValidValue) {
+ if (value >= minValidValue) {
+ printLine(indentLevels, text, Integer.toString(value));
+ }
+ }
+
+ private static void printLine(int indentLevels, String text, String value) {
+ if (value == null || value.length() == 0) {
+ return;
+ }
+ while (indentLevels-- > 0) {
+ System.out.print("\t");
+ }
+ if (text != null && text.length() > 0) {
+ System.out.print(text);
+ System.out.print(" ");
+ }
+ System.out.println(value);
+ }
+
+ private static void printVerbose(String sourceName, ImageInfo ii) {
+ printLine(0, null, sourceName);
+ printLine(1, "File format: ", ii.getFormatName());
+ printLine(1, "MIME type: ", ii.getMimeType());
+ printLine(1, "Width (pixels): ", ii.getWidth(), 1);
+ printLine(1, "Height (pixels): ", ii.getHeight(), 1);
+ printLine(1, "Bits per pixel: ", ii.getBitsPerPixel(), 1);
+ printLine(1, "Progressive: ", Boolean.toString(ii.isProgressive()));
+ printLine(1, "Number of images: ", ii.getNumberOfImages(), 1);
+ printLine(1, "Physical width (dpi): ", ii.getPhysicalWidthDpi(), 1);
+ printLine(1, "Physical height (dpi): ", ii.getPhysicalHeightDpi(), 1);
+ printLine(1, "Physical width (inches): ", ii.getPhysicalWidthInch(), 1.0f);
+ printLine(1, "Physical height (inches): ", ii.getPhysicalHeightInch(), 1.0f);
+ int numComments = ii.getNumberOfComments();
+ printLine(1, "Number of textual comments: ", numComments, 1);
+ if (numComments > 0) {
+ for (int i = 0; i < numComments; i++) {
+ printLine(2, null, ii.getComment(i));
+ }
+ }
+ }
+
+ private int read() throws IOException {
+ if (in != null) {
+ return in.read();
+ } else {
+ return din.readByte();
+ }
+ }
+
+ private int read(byte[] a) throws IOException {
+ if (in != null) {
+ return in.read(a);
+ } else {
+ din.readFully(a);
+ return a.length;
+ }
+ }
+
+ private int read(byte[] a, int offset, int num) throws IOException {
+ if (in != null) {
+ return in.read(a, offset, num);
+ } else {
+ din.readFully(a, offset, num);
+ return num;
+ }
+ }
+
+ private String readLine() throws IOException {
+ return readLine(new StringBuffer());
+ }
+
+ private String readLine(StringBuffer sb) throws IOException {
+ boolean finished;
+ do {
+ int value = read();
+ finished = (value == -1 || value == 10);
+ if (!finished) {
+ sb.append((char)value);
+ }
+ } while (!finished);
+ return sb.toString();
+ }
+
+ private long readUBits( int numBits ) throws IOException
+ {
+ if (numBits == 0) {
+ return 0;
+ }
+ int bitsLeft = numBits;
+ long result = 0;
+ if (bitPos == 0) { //no value in the buffer - read a byte
+ if (in != null) {
+ bitBuf = in.read();
+ } else {
+ bitBuf = din.readByte();
+ }
+ bitPos = 8;
+ }
+
+ while( true )
+ {
+ int shift = bitsLeft - bitPos;
+ if( shift > 0 )
+ {
+ // Consume the entire buffer
+ result |= bitBuf << shift;
+ bitsLeft -= bitPos;
+
+ // Get the next byte from the input stream
+ if (in != null) {
+ bitBuf = in.read();
+ } else {
+ bitBuf = din.readByte();
+ }
+ bitPos = 8;
+ }
+ else
+ {
+ // Consume a portion of the buffer
+ result |= bitBuf >> -shift;
+ bitPos -= bitsLeft;
+ bitBuf &= 0xff >> (8 - bitPos); // mask off the consumed bits
+
+ return result;
+ }
+ }
+ }
+
+ /**
+ * Read a signed value from the given number of bits
+ */
+ private int readSBits( int numBits ) throws IOException
+ {
+ // Get the number as an unsigned value.
+ long uBits = readUBits( numBits );
+
+ // Is the number negative?
+ if( ( uBits & (1L << (numBits - 1))) != 0 )
+ {
+ // Yes. Extend the sign.
+ uBits |= -1L << numBits;
+ }
+
+ return (int)uBits;
+ }
+
+ private void synchBits()
+ {
+ bitBuf = 0;
+ bitPos = 0;
+ }
+
+ private String readLine(int firstChar) throws IOException {
+ StringBuffer result = new StringBuffer();
+ result.append((char)firstChar);
+ return readLine(result);
+ }
+
+ private static void run(String sourceName, InputStream in, ImageInfo imageInfo, boolean verbose) {
+ imageInfo.setInput(in);
+ imageInfo.setDetermineImageNumber(false);
+ imageInfo.setCollectComments(verbose);
+ if (imageInfo.check()) {
+ print(sourceName, imageInfo, verbose);
+ }
+ }
+
+ /**
+ * Specify whether textual comments are supposed to be extracted from input.
+ * Default is <code>false</code>.
+ * If enabled, comments will be added to an internal list.
+ * @param newValue if <code>true</code>, this class will read comments
+ * @see #getNumberOfComments
+ * @see #getComment
+ */
+ public void setCollectComments(boolean newValue)
+ {
+ collectComments = newValue;
+ }
+
+ /**
+ * Specify whether the number of images in a file is to be
+ * determined - default is <code>false</code>.
+ * This is a special option because some file formats require running over
+ * the entire file to find out the number of images, a rather time-consuming
+ * task.
+ * Not all file formats support more than one image.
+ * If this method is called with <code>true</code> as argument,
+ * the actual number of images can be queried via
+ * {@link #getNumberOfImages()} after a successful call to
+ * {@link #check()}.
+ * @param newValue will the number of images be determined?
+ * @see #getNumberOfImages
+ */
+ public void setDetermineImageNumber(boolean newValue)
+ {
+ determineNumberOfImages = newValue;
+ }
+
+ /**
+ * Set the input stream to the argument stream (or file).
+ * Note that {@link java.io.RandomAccessFile} implements
+ * {@link java.io.DataInput}.
+ * @param dataInput the input stream to read from
+ */
+ public void setInput(DataInput dataInput) {
+ din = dataInput;
+ in = null;
+ }
+
+ /**
+ * Set the input stream to the argument stream (or file).
+ * @param inputStream the input stream to read from
+ */
+ public void setInput(InputStream inputStream) {
+ in = inputStream;
+ din = null;
+ }
+
+ private void setPhysicalHeightDpi(int newValue) {
+ physicalWidthDpi = newValue;
+ }
+
+ private void setPhysicalWidthDpi(int newValue) {
+ physicalHeightDpi = newValue;
+ }
+
+ private void skip(int num) throws IOException {
+ while (num > 0) {
+ long result;
+ if (in != null) {
+ result = in.skip(num);
+ } else {
+ result = din.skipBytes(num);
+ }
+ if (result > 0) {
+ num -= result;
+ }
+ }
+ }
+}
Added: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/Quantize.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/Quantize.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/image/Quantize.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -0,0 +1,840 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Helma License Notice
+ *
+ * The contents of this file are subject to the Helma License
+ * Version 2.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://adele.helma.org/download/helma/license.txt
+ *
+ * Copyright 1998-2003 Helma Software. All Rights Reserved.
+ *
+ * $RCSfile: Quantize.java,v $
+ * $Author: alexsmirnov $
+ * $Revision: 1.1.2.1 $
+ * $Date: 2007/01/09 18:59:05 $
+ */
+
+package org.ajax4jsf.resource.image;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferInt;
+import java.awt.image.IndexColorModel;
+
+/*
+ * @(#)Quantize.java 0.90 9/19/00 Adam Doppelt
+ *
+ * Modifications by Joerg Lehni:
+ *
+ * - Support for alpha-channels.
+ * - Returns a BufferedImage of TYPE_BYTE_INDEXED with a IndexColorModel.
+ * - Dithering of images through helma.image.DiffusionFilterOp by setting
+ * the dither parameter to true.
+ * - Support for a transparent color, which is correctly rendered by GIFEncoder.
+ * All pixels with alpha < 0x80 are converted to this color when the parameter
+ * alphaToBitmask is set to true.
+ * - Removed the SQUARES lookup tables as multiplications of integer values
+ * shouldn't take more than one clock nowadays anyhow.
+ */
+
+/**
+ * An efficient color quantization algorithm, adapted from the C++
+ * implementation quantize.c in <a
+ * href="http://www.imagemagick.org/">ImageMagick</a>. The pixels for
+ * an image are placed into an oct tree. The oct tree is reduced in
+ * size, and the pixels from the original image are reassigned to the
+ * nodes in the reduced tree.<p>
+ *
+ * Here is the copyright notice from ImageMagick:
+ *
+ * <pre>
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Permission is hereby granted, free of charge, to any person obtaining a %
+% copy of this software and associated documentation files ("ImageMagick"), %
+% to deal in ImageMagick without restriction, including without limitation %
+% the rights to use, copy, modify, merge, publish, distribute, sublicense, %
+% and/or sell copies of ImageMagick, and to permit persons to whom the %
+% ImageMagick is furnished to do so, subject to the following conditions: %
+% %
+% The above copyright notice and this permission notice shall be included in %
+% all copies or substantial portions of ImageMagick. %
+% %
+% The software is provided "as is", without warranty of any kind, express or %
+% implied, including but not limited to the warranties of merchantability, %
+% fitness for a particular purpose and noninfringement. In no event shall %
+% E. I. du Pont de Nemours and Company be liable for any claim, damages or %
+% other liability, whether in an action of contract, tort or otherwise, %
+% arising from, out of or in connection with ImageMagick or the use or other %
+% dealings in ImageMagick. %
+% %
+% Except as contained in this notice, the name of the E. I. du Pont de %
+% Nemours and Company shall not be used in advertising or otherwise to %
+% promote the sale, use or other dealings in ImageMagick without prior %
+% written authorization from the E. I. du Pont de Nemours and Company. %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+</pre>
+ *
+ *
+ * @version 0.90 19 Sep 2000
+ * @author <a href="http://www.gurge.com/amd/">Adam Doppelt</a>
+ */
+public class Quantize {
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% QQQ U U AAA N N TTTTT IIIII ZZZZZ EEEEE %
+% Q Q U U A A NN N T I ZZ E %
+% Q Q U U AAAAA N N N T I ZZZ EEEEE %
+% Q QQ U U A A N NN T I ZZ E %
+% QQQQ UUU A A N N T IIIII ZZZZZ EEEEE %
+% %
+% %
+% Reduce the Number of Unique Colors in an Image %
+% %
+% %
+% Software Design %
+% John Cristy %
+% July 1992 %
+% %
+% %
+% Copyright 1998 E. I. du Pont de Nemours and Company %
+% %
+% Permission is hereby granted, free of charge, to any person obtaining a %
+% copy of this software and associated documentation files ("ImageMagick"), %
+% to deal in ImageMagick without restriction, including without limitation %
+% the rights to use, copy, modify, merge, publish, distribute, sublicense, %
+% and/or sell copies of ImageMagick, and to permit persons to whom the %
+% ImageMagick is furnished to do so, subject to the following conditions: %
+% %
+% The above copyright notice and this permission notice shall be included in %
+% all copies or substantial portions of ImageMagick. %
+% %
+% The software is provided "as is", without warranty of any kind, express or %
+% implied, including but not limited to the warranties of merchantability, %
+% fitness for a particular purpose and noninfringement. In no event shall %
+% E. I. du Pont de Nemours and Company be liable for any claim, damages or %
+% other liability, whether in an action of contract, tort or otherwise, %
+% arising from, out of or in connection with ImageMagick or the use or other %
+% dealings in ImageMagick. %
+% %
+% Except as contained in this notice, the name of the E. I. du Pont de %
+% Nemours and Company shall not be used in advertising or otherwise to %
+% promote the sale, use or other dealings in ImageMagick without prior %
+% written authorization from the E. I. du Pont de Nemours and Company. %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Realism in computer graphics typically requires using 24 bits/pixel to
+% generate an image. Yet many graphic display devices do not contain
+% the amount of memory necessary to match the spatial and color
+% resolution of the human eye. The QUANTIZE program takes a 24 bit
+% image and reduces the number of colors so it can be displayed on
+% raster device with less bits per pixel. In most instances, the
+% quantized image closely resembles the original reference image.
+%
+% A reduction of colors in an image is also desirable for image
+% transmission and real-time animation.
+%
+% Function Quantize takes a standard RGB or monochrome images and quantizes
+% them down to some fixed number of colors.
+%
+% For purposes of color allocation, an image is a set of n pixels, where
+% each pixel is a point in RGB space. RGB space is a 3-dimensional
+% vector space, and each pixel, pi, is defined by an ordered triple of
+% red, green, and blue coordinates, (ri, gi, bi).
+%
+% Each primary color component (red, green, or blue) represents an
+% intensity which varies linearly from 0 to a maximum value, cmax, which
+% corresponds to full saturation of that color. Color allocation is
+% defined over a domain consisting of the cube in RGB space with
+% opposite vertices at (0,0,0) and (cmax,cmax,cmax). QUANTIZE requires
+% cmax = 255.
+%
+% The algorithm maps this domain onto a tree in which each node
+% represents a cube within that domain. In the following discussion
+% these cubes are defined by the coordinate of two opposite vertices:
+% The vertex nearest the origin in RGB space and the vertex farthest
+% from the origin.
+%
+% The tree's root node represents the the entire domain, (0,0,0) through
+% (cmax,cmax,cmax). Each lower level in the tree is generated by
+% subdividing one node's cube into eight smaller cubes of equal size.
+% This corresponds to bisecting the parent cube with planes passing
+% through the midpoints of each edge.
+%
+% The basic algorithm operates in three phases: Classification,
+% Reduction, and Assignment. Classification builds a color
+% description tree for the image. Reduction collapses the tree until
+% the number it represents, at most, the number of colors desired in the
+% output image. Assignment defines the output image's color map and
+% sets each pixel's color by reclassification in the reduced tree.
+% Our goal is to minimize the numerical discrepancies between the original
+% colors and quantized colors (quantization error).
+%
+% Classification begins by initializing a color description tree of
+% sufficient depth to represent each possible input color in a leaf.
+% However, it is impractical to generate a fully-formed color
+% description tree in the classification phase for realistic values of
+% cmax. If colors components in the input image are quantized to k-bit
+% precision, so that cmax= 2k-1, the tree would need k levels below the
+% root node to allow representing each possible input color in a leaf.
+% This becomes prohibitive because the tree's total number of nodes is
+% 1 + sum(i=1,k,8k).
+%
+% A complete tree would require 19,173,961 nodes for k = 8, cmax = 255.
+% Therefore, to avoid building a fully populated tree, QUANTIZE: (1)
+% Initializes data structures for nodes only as they are needed; (2)
+% Chooses a maximum depth for the tree as a function of the desired
+% number of colors in the output image (currently log2(colorMap size)).
+%
+% For each pixel in the input image, classification scans downward from
+% the root of the color description tree. At each level of the tree it
+% identifies the single node which represents a cube in RGB space
+% containing the pixel's color. It updates the following data for each
+% such node:
+%
+% n1: Number of pixels whose color is contained in the RGB cube
+% which this node represents;
+%
+% n2: Number of pixels whose color is not represented in a node at
+% lower depth in the tree; initially, n2 = 0 for all nodes except
+% leaves of the tree.
+%
+% Sr, Sg, Sb: Sums of the red, green, and blue component values for
+% all pixels not classified at a lower depth. The combination of
+% these sums and n2 will ultimately characterize the mean color of a
+% set of pixels represented by this node.
+%
+% E: The distance squared in RGB space between each pixel contained
+% within a node and the nodes' center. This represents the quantization
+% error for a node.
+%
+% Reduction repeatedly prunes the tree until the number of nodes with
+% n2 > 0 is less than or equal to the maximum number of colors allowed
+% in the output image. On any given iteration over the tree, it selects
+% those nodes whose E count is minimal for pruning and merges their
+% color statistics upward. It uses a pruning threshold, Ep, to govern
+% node selection as follows:
+%
+% Ep = 0
+% while number of nodes with (n2 > 0) > required maximum number of colors
+% prune all nodes such that E <= Ep
+% Set Ep to minimum E in remaining nodes
+%
+% This has the effect of minimizing any quantization error when merging
+% two nodes together.
+%
+% When a node to be pruned has offspring, the pruning procedure invokes
+% itself recursively in order to prune the tree from the leaves upward.
+% n2, Sr, Sg, and Sb in a node being pruned are always added to the
+% corresponding data in that node's parent. This retains the pruned
+% node's color characteristics for later averaging.
+%
+% For each node, n2 pixels exist for which that node represents the
+% smallest volume in RGB space containing those pixel's colors. When n2
+% > 0 the node will uniquely define a color in the output image. At the
+% beginning of reduction, n2 = 0 for all nodes except a the leaves of
+% the tree which represent colors present in the input image.
+%
+% The other pixel count, n1, indicates the total number of colors
+% within the cubic volume which the node represents. This includes n1 -
+% n2 pixels whose colors should be defined by nodes at a lower level in
+% the tree.
+%
+% Assignment generates the output image from the pruned tree. The
+% outpu t image consists of two parts: (1) A color map, which is an
+% array of color descriptions (RGB triples) for each color present in
+% the output image; (2) A pixel array, which represents each pixel as
+% an index into the color map array.
+%
+% First, the assignment phase makes one pass over the pruned color
+% description tree to establish the image's color map. For each node
+% with n2 > 0, it divides Sr, Sg, and Sb by n2 . This produces the
+% mean color of all pixels that classify no lower than this node. Each
+% of these colors becomes an entry in the color map.
+%
+% Finally, the assignment phase reclassifies each pixel in the pruned
+% tree to identify the deepest node containing the pixel's color. The
+% pixel's value in the pixel array becomes the index of this node's mean
+% color in the color map.
+%
+% With the permission of USC Information Sciences Institute, 4676 Admiralty
+% Way, Marina del Rey, California 90292, this code was adapted from module
+% ALCOLS written by Paul Raveling.
+%
+% The names of ISI and USC are not used in advertising or publicity
+% pertaining to distribution of the software without prior specific
+% written permission from ISI.
+%
+*/
+
+ final static boolean QUICK = false;
+
+ final static int MAX_RGB = 255;
+ final static int MAX_NODES = 266817;
+ final static int MAX_TREE_DEPTH = 8;
+ final static int MAX_CHILDREN = 16;
+
+ /**
+ * Reduce the image to the given number of colors. The pixels are reduced in
+ * place.
+ *
+ * @return The new color palette.
+ */
+ public static BufferedImage process(BufferedImage source, int maxColors,
+ boolean dither, boolean alphaToBitmask) {
+ int type = source.getType();
+ int[] pixels;
+ // try to get the direct pixels of the BufferedImage
+ // this works for images of type INT_RGB, INT_ARGB and INT_ARGB_PRE
+ // for all others, a new array with rgb pixels is created!
+ if (type == BufferedImage.TYPE_INT_RGB
+ || type == BufferedImage.TYPE_INT_ARGB
+ || type == BufferedImage.TYPE_INT_ARGB_PRE) {
+ pixels = ((DataBufferInt) source.getRaster().getDataBuffer()).getData();
+ } else {
+ pixels = source.getRGB(0, 0, source.getWidth(), source.getHeight(), null, 0, source.getWidth());
+ }
+ Cube cube = new Cube(source, pixels, maxColors, dither, alphaToBitmask);
+ cube.classification();
+ cube.reduction();
+ return cube.assignment();
+ }
+
+ static class Cube {
+ BufferedImage source;
+ int[] pixels;
+ int maxColors;
+ byte colorMap[][];
+
+ Node root;
+ int depth;
+
+ boolean dither;
+ boolean alphaToBitmask;
+ boolean addTransparency;
+ // firstColor is set to 1 when when addTransparency is true!
+ int firstColor = 0;
+
+ // counter for the number of colors in the cube. this gets
+ // recalculated often.
+ int numColors;
+
+ // counter for the number of nodes in the tree
+ int numNodes;
+
+ Cube(BufferedImage source, int[] pixels, int maxColors, boolean dither,
+ boolean alphaToBitmask) {
+ this.source = source;
+ this.pixels = pixels;
+ this.maxColors = maxColors;
+ this.dither = dither;
+ this.alphaToBitmask = alphaToBitmask;
+
+ int i = maxColors;
+ // tree_depth = log maxColors
+ // 4
+ for (depth = 1; i != 0; depth++) {
+ i /= 4;
+ }
+ if (depth > 1) {
+ --depth;
+ }
+ if (depth > MAX_TREE_DEPTH) {
+ depth = MAX_TREE_DEPTH;
+ } else if (depth < 2) {
+ depth = 2;
+ }
+
+ root = new Node(this);
+ }
+
+ /*
+ * Procedure Classification begins by initializing a color description
+ * tree of sufficient depth to represent each possible input color in a
+ * leaf. However, it is impractical to generate a fully-formed color
+ * description tree in the classification phase for realistic values of
+ * cmax. If colors components in the input image are quantized to k-bit
+ * precision, so that cmax= 2k-1, the tree would need k levels below the
+ * root node to allow representing each possible input color in a leaf.
+ * This becomes prohibitive because the tree's total number of nodes is
+ * 1 + sum(i=1,k,8k).
+ *
+ * A complete tree would require 19,173,961 nodes for k = 8, cmax = 255.
+ * Therefore, to avoid building a fully populated tree, QUANTIZE: (1)
+ * Initializes data structures for nodes only as they are needed; (2)
+ * Chooses a maximum depth for the tree as a function of the desired
+ * number of colors in the output image (currently log2(colorMap size)).
+ *
+ * For each pixel in the input image, classification scans downward from
+ * the root of the color description tree. At each level of the tree it
+ * identifies the single node which represents a cube in RGB space
+ * containing It updates the following data for each such node:
+ *
+ * numPixels : Number of pixels whose color is contained in the RGB cube
+ * which this node represents;
+ *
+ * unique : Number of pixels whose color is not represented in a node at
+ * lower depth in the tree; initially, n2 = 0 for all nodes except
+ * leaves of the tree.
+ *
+ * totalRed/green/blue : Sums of the red, green, and blue component
+ * values for all pixels not classified at a lower depth. The
+ * combination of these sums and n2 will ultimately characterize the
+ * mean color of a set of pixels represented by this node.
+ */
+ void classification() {
+ addTransparency = false;
+ firstColor = 0;
+ for (int i = 0; i < pixels.length; i++) {
+ int pixel = pixels[i];
+ int red = (pixel >> 16) & 0xff;
+ int green = (pixel >> 8) & 0xff;
+ int blue = (pixel >> 0) & 0xff;
+ int alpha = (pixel >> 24) & 0xff;
+ if (alphaToBitmask)
+ alpha = alpha < 0x80 ? 0 : 0xff;
+
+ if (alpha > 0) {
+ // a hard limit on the number of nodes in the tree
+ if (numNodes > MAX_NODES) {
+ // System.out.println("pruning");
+ root.pruneLevel();
+ --depth;
+ }
+
+ // walk the tree to depth, increasing the
+ // numPixels count for each node
+ Node node = root;
+ for (int level = 1; level <= depth; ++level) {
+ int id = (((red > node.midRed ? 1 : 0) << 0)
+ | ((green > node.midGreen ? 1 : 0) << 1)
+ | ((blue > node.midBlue ? 1 : 0) << 2) | ((alpha > node.midAlpha ? 1
+ : 0) << 3));
+ if (node.children[id] == null) {
+ node = new Node(node, id, level);
+ } else {
+ node = node.children[id];
+ }
+ node.numPixels++;
+ }
+
+ ++node.unique;
+ node.totalRed += red;
+ node.totalGreen += green;
+ node.totalBlue += blue;
+ node.totalAlpha += alpha;
+ } else if (!addTransparency) {
+ addTransparency = true;
+ numColors++;
+ firstColor = 1; // start at 1 as 0 will be the transparent
+ // color
+ }
+ }
+ }
+
+ /*
+ * reduction repeatedly prunes the tree until the number of nodes with
+ * unique > 0 is less than or equal to the maximum number of colors
+ * allowed in the output image.
+ *
+ * When a node to be pruned has offspring, the pruning procedure invokes
+ * itself recursively in order to prune the tree from the leaves upward.
+ * The statistics of the node being pruned are always added to the
+ * corresponding data in that node's parent. This retains the pruned
+ * node's color characteristics for later averaging.
+ */
+ void reduction() {
+ int threshold = 1;
+ while (numColors > maxColors) {
+ numColors = firstColor;
+ threshold = root.reduce(threshold, Integer.MAX_VALUE);
+ }
+ }
+
+ /**
+ * The result of a closest color search.
+ */
+ static class Search {
+ int distance;
+ int colorIndex;
+ }
+
+ /*
+ * Procedure assignment generates the output image from the pruned tree.
+ * The output image consists of two parts: (1) A color map, which is an
+ * array of color descriptions (RGB triples) for each color present in
+ * the output image; (2) A pixel array, which represents each pixel as
+ * an index into the color map array.
+ *
+ * First, the assignment phase makes one pass over the pruned color
+ * description tree to establish the image's color map. For each node
+ * with n2 > 0, it divides Sr, Sg, and Sb by n2. This produces the mean
+ * color of all pixels that classify no lower than this node. Each of
+ * these colors becomes an entry in the color map.
+ *
+ * Finally, the assignment phase reclassifies each pixel in the pruned
+ * tree to identify the deepest node containing the pixel's color. The
+ * pixel's value in the pixel array becomes the index of this node's
+ * mean color in the color map.
+ */
+ BufferedImage assignment() {
+ colorMap = new byte[4][numColors];
+
+ if (addTransparency) {
+ // if a transparency color is added, firstColor was set to 1,
+ // so color 0 can be used for this
+ colorMap[0][0] = 0;
+ colorMap[1][0] = 0;
+ colorMap[2][0] = 0;
+ colorMap[3][0] = 0;
+ }
+ numColors = firstColor;
+ root.mapColors();
+
+ // determine bit depth for palette
+ int depth;
+ for (depth = 1; depth <= 8; depth++)
+ if ((1 << depth) >= numColors)
+ break;
+
+ // create the right color model, depending on transparency settings:
+ IndexColorModel icm;
+ if (alphaToBitmask) {
+ if (addTransparency)
+ icm = new IndexColorModel(depth, numColors, colorMap[0],
+ colorMap[1], colorMap[2], 0);
+ else
+ icm = new IndexColorModel(depth, numColors, colorMap[0],
+ colorMap[1], colorMap[2]);
+ } else {
+ icm = new IndexColorModel(depth, numColors, colorMap[0],
+ colorMap[1], colorMap[2], colorMap[3]);
+ }
+ // create the indexed BufferedImage:
+ BufferedImage dest = new BufferedImage(source.getWidth(),
+ source.getHeight(), BufferedImage.TYPE_BYTE_INDEXED, icm);
+
+ boolean firstOut = true;
+ if (dither)
+ new DiffusionFilterOp().filter(source, dest);
+ else {
+ Search search = new Search();
+ // convert to indexed color
+ byte[] dst = ((DataBufferByte) dest.getRaster().getDataBuffer()).getData();
+
+ for (int i = 0; i < pixels.length; i++) {
+ int pixel = pixels[i];
+ int red = (pixel >> 16) & 0xff;
+ int green = (pixel >> 8) & 0xff;
+ int blue = (pixel >> 0) & 0xff;
+ int alpha = (pixel >> 24) & 0xff;
+
+ if (alphaToBitmask)
+ alpha = alpha < 128 ? 0 : 0xff;
+
+ // this is super weird: on some systems, transparent pixels are
+ // not calculated correctly if the following block is taken out.
+ // the bug is very strange, isn't related to the code (compiler error?)
+ // but doesn't allways happen. as soon as it does, though, it doesn't
+ // seem to want to go away.
+ // This happened at various times on my two different debian systems
+ // and i never found out how to really fix it. the following line seems to
+ // prevent it from happening, but i wonder wether there's a better way
+ // to fix it.
+ // it looks as if the command forces alpha to take on correct values.
+ // Until now I only knew of effects like that in quantum mechanics...
+ if (i == 0) {
+ String fix = "" + alpha;
+ }
+
+ if (alpha == 0 && addTransparency) {
+ dst[i] = 0; // transparency color is at 0
+ } else {
+ // walk the tree to find the cube containing that color
+ Node node = root;
+ for (;;) {
+ int id = (((red > node.midRed ? 1 : 0) << 0)
+ | ((green > node.midGreen ? 1 : 0) << 1)
+ | ((blue > node.midBlue ? 1 : 0) << 2) | ((alpha > node.midAlpha ? 1
+ : 0) << 3));
+ if (node.children[id] == null) {
+ break;
+ }
+ node = node.children[id];
+ }
+
+ if (QUICK) {
+ // if QUICK is set, just use that
+ // node. Strictly speaking, this isn't
+ // necessarily best match.
+ dst[i] = (byte) node.colorIndex;
+ } else {
+ // Find the closest color.
+ search.distance = Integer.MAX_VALUE;
+ node.parent.closestColor(red, green, blue, alpha,
+ search);
+ dst[i] = (byte) search.colorIndex;
+ }
+ }
+ }
+ }
+ return dest;
+ }
+
+ /**
+ * A single Node in the tree.
+ */
+ static class Node {
+ Cube cube;
+
+ // parent node
+ Node parent;
+
+ // children nodes
+ Node children[];
+ int numChildren;
+
+ // our index within our parent
+ int id;
+ // our level within the tree
+ int level;
+ // our color midpoint
+ int midRed;
+ int midGreen;
+ int midBlue;
+ int midAlpha;
+
+ // the pixel count for this node and all children
+ int numPixels;
+
+ // the pixel count for this node
+ int unique;
+ // the sum of all pixels contained in this node
+ int totalRed;
+ int totalGreen;
+ int totalBlue;
+ int totalAlpha;
+
+ // used to build the colorMap
+ int colorIndex;
+
+ Node(Cube cube) {
+ this.cube = cube;
+ this.parent = this;
+ this.children = new Node[MAX_CHILDREN];
+ this.id = 0;
+ this.level = 0;
+
+ this.numPixels = Integer.MAX_VALUE;
+
+ this.midRed = (MAX_RGB + 1) >> 1;
+ this.midGreen = (MAX_RGB + 1) >> 1;
+ this.midBlue = (MAX_RGB + 1) >> 1;
+ this.midAlpha = (MAX_RGB + 1) >> 1;
+ }
+
+ Node(Node parent, int id, int level) {
+ this.cube = parent.cube;
+ this.parent = parent;
+ this.children = new Node[MAX_CHILDREN];
+ this.id = id;
+ this.level = level;
+
+ // add to the cube
+ ++cube.numNodes;
+ if (level == cube.depth) {
+ ++cube.numColors;
+ }
+
+ // add to the parent
+ ++parent.numChildren;
+ parent.children[id] = this;
+
+ // figure out our midpoint
+ int bi = (1 << (MAX_TREE_DEPTH - level)) >> 1;
+ midRed = parent.midRed + ((id & 1) > 0 ? bi : -bi);
+ midGreen = parent.midGreen + ((id & 2) > 0 ? bi : -bi);
+ midBlue = parent.midBlue + ((id & 4) > 0 ? bi : -bi);
+ midAlpha = parent.midAlpha + ((id & 8) > 0 ? bi : -bi);
+ }
+
+ /**
+ * Remove this children node, and make sure our parent absorbs our
+ * pixel statistics.
+ */
+ void pruneChild() {
+ --parent.numChildren;
+ parent.unique += unique;
+ parent.totalRed += totalRed;
+ parent.totalGreen += totalGreen;
+ parent.totalBlue += totalBlue;
+ parent.totalAlpha += totalAlpha;
+ parent.children[id] = null;
+ --cube.numNodes;
+ cube = null;
+ parent = null;
+ }
+
+ /**
+ * Prune the lowest layer of the tree.
+ */
+ void pruneLevel() {
+ if (numChildren != 0) {
+ for (int id = 0; id < MAX_CHILDREN; id++) {
+ if (children[id] != null) {
+ children[id].pruneLevel();
+ }
+ }
+ }
+ if (level == cube.depth) {
+ pruneChild();
+ }
+ }
+
+ /**
+ * Remove any nodes that have fewer than threshold pixels. Also, as
+ * long as we're walking the tree: - figure out the color with the
+ * fewest pixels - recalculate the total number of colors in the
+ * tree
+ */
+ int reduce(int threshold, int nextThreshold) {
+ if (numChildren != 0) {
+ for (int id = 0; id < MAX_CHILDREN; id++) {
+ if (children[id] != null) {
+ nextThreshold = children[id].reduce(threshold,
+ nextThreshold);
+ }
+ }
+ }
+ if (numPixels <= threshold) {
+ pruneChild();
+ } else {
+ if (unique != 0) {
+ cube.numColors++;
+ }
+ if (numPixels < nextThreshold) {
+ nextThreshold = numPixels;
+ }
+ }
+ return nextThreshold;
+ }
+
+ /*
+ * mapColors traverses the color cube tree and notes each colorMap
+ * entry. A colorMap entry is any node in the color cube tree where
+ * the number of unique colors is not zero.
+ */
+ void mapColors() {
+ if (numChildren != 0) {
+ for (int id = 0; id < MAX_CHILDREN; id++) {
+ if (children[id] != null) {
+ children[id].mapColors();
+ }
+ }
+ }
+ if (unique != 0) {
+ int add = unique >> 1;
+ cube.colorMap[0][cube.numColors] = (byte) ((totalRed + add) / unique);
+ cube.colorMap[1][cube.numColors] = (byte) ((totalGreen + add) / unique);
+ cube.colorMap[2][cube.numColors] = (byte) ((totalBlue + add) / unique);
+ cube.colorMap[3][cube.numColors] = (byte) ((totalAlpha + add) / unique);
+ colorIndex = cube.numColors++;
+ }
+ }
+
+ /*
+ * ClosestColor traverses the color cube tree at a particular node
+ * and determines which colorMap entry best represents the input
+ * color.
+ */
+ void closestColor(int red, int green, int blue, int alpha,
+ Search search) {
+ if (numChildren != 0) {
+ for (int id = 0; id < MAX_CHILDREN; id++) {
+ if (children[id] != null) {
+ children[id].closestColor(red, green, blue, alpha,
+ search);
+ }
+ }
+ }
+
+ if (unique != 0) {
+ int distance = distance(
+ cube.colorMap[0][colorIndex] & 0xff,
+ cube.colorMap[1][colorIndex] & 0xff,
+ cube.colorMap[2][colorIndex] & 0xff,
+ cube.colorMap[3][colorIndex] & 0xff, red, green, blue,
+ alpha);
+ if (distance < search.distance) {
+ search.distance = distance;
+ search.colorIndex = colorIndex;
+ }
+ }
+ }
+
+ /**
+ * Figure out the distance between this node and som color.
+ */
+ final static int distance(int r1, int g1, int b1, int a1, int r2,
+ int g2, int b2, int a2) {
+ int da = a1 - a2;
+ int dr = r1 - r2;
+ int dg = g1 - g2;
+ int db = b1 - b2;
+
+ return da * da + dr * dr + dg * dg + db * db;
+// return (SQUARES[r1 - r2 + MAX_RGB] +
+// SQUARES[g1 - g2 + MAX_RGB] +
+// SQUARES[b1 - b2 + MAX_RGB] +
+// SQUARES[a1 - a2 + MAX_RGB]);
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ if (parent == this) {
+ buf.append("root");
+ } else {
+ buf.append("node");
+ }
+ buf.append(' ');
+ buf.append(level);
+ buf.append(" [");
+ buf.append(midRed);
+ buf.append(',');
+ buf.append(midGreen);
+ buf.append(',');
+ buf.append(midBlue);
+ buf.append(',');
+ buf.append(midAlpha);
+ buf.append(']');
+ return new String(buf);
+ }
+ }
+ }
+}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/resources/META-INF/services/javax.imageio.spi.ImageWriterSpi
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/services/javax.imageio.spi.ImageWriterSpi 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/impl/src/main/resources/META-INF/services/javax.imageio.spi.ImageWriterSpi 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,2 +0,0 @@
-org.ajax4jsf.framework.util.image.imageio.gif.GIFImageWriterSpi
-
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -26,11 +26,6 @@
import org.ajax4jsf.framework.util.config.WebXml;
import org.ajax4jsf.renderkit.compiler.TemplateContext;
-import org.ajax4jsf.resource.FacesResourceContext;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.TemplateCSSResource;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.shale.test.mock.MockPrintWriter;
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/resource/InternetResourceServiceTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/InternetResourceServiceTestCase.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/InternetResourceServiceTestCase.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -23,9 +23,6 @@
import java.io.IOException;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.InternetResourceService;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.shale.test.mock.MockServletOutputStream;
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockCacheableResource.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockCacheableResource.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockCacheableResource.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -24,10 +24,6 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import org.ajax4jsf.resource.InternetResourceBase;
-import org.ajax4jsf.resource.LogfileRenderer;
-import org.ajax4jsf.resource.ResourceContext;
-
/**
* @author shura
*
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/resource/ParametersEncodingTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/ParametersEncodingTestCase.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/ParametersEncodingTestCase.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -2,7 +2,6 @@
import java.util.Arrays;
-import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
public class ParametersEncodingTestCase extends AbstractAjax4JsfTestCase {
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -23,9 +23,6 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.InternetResourceService;
import org.ajax4jsf.tests.AbstractThreadedAjax4JsfTestCase;
import org.apache.shale.test.mock.MockHttpServletRequest;
import org.apache.shale.test.mock.MockHttpServletResponse;
Copied: trunk/framework/test/src/test/java/org/richfaces/skin (from rev 1585, trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin)
Deleted: trunk/framework/test/src/test/java/org/richfaces/skin/Bean.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/Bean.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/test/src/test/java/org/richfaces/skin/Bean.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,27 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.skin;
-
-public class Bean {
- public String getName(){return "bindedtest";}
- public String getBean(){return "binded.string";}
-}
\ No newline at end of file
Copied: trunk/framework/test/src/test/java/org/richfaces/skin/Bean.java (from rev 1587, trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/Bean.java)
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/skin/Bean.java (rev 0)
+++ trunk/framework/test/src/test/java/org/richfaces/skin/Bean.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -0,0 +1,27 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.skin;
+
+public class Bean {
+ public String getName(){return "bindedtest";}
+ public String getBean(){return "binded.string";}
+}
\ No newline at end of file
Deleted: trunk/framework/test/src/test/java/org/richfaces/skin/SkinTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/SkinTestCase.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/test/src/test/java/org/richfaces/skin/SkinTestCase.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,328 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.skin;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-import junit.framework.TestCase;
-
-import org.easymock.MockControl;
-import org.easymock.classextension.MockClassControl;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * Test for Skin/skin factory methods.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/10 14:28:13 $
- *
- */
-public class SkinTestCase extends TestCase {
- private MockControl contextControl;
- private FacesContext mockContext;
-
- private MockControl externalContextControl;
- private ExternalContext mockExternalContext;
-
- private TestApplicationFactory appFactory;
-
- private MockControl bindingControl;
- private ValueBinding mockBinding;
- private MockControl bindingSkinControl;
- private ValueBinding mockSkinBinding;
-
- public SkinTestCase(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- contextControl = MockClassControl.createControl(FacesContext.class);
- mockContext = (FacesContext) contextControl.getMock();
- externalContextControl = MockClassControl.createControl(ExternalContext.class);
- mockExternalContext = (ExternalContext) externalContextControl.getMock();
- bindingControl = MockClassControl.createNiceControl(ValueBinding.class);
- mockBinding = (ValueBinding) bindingControl.getMock();
- bindingSkinControl = MockClassControl.createNiceControl(ValueBinding.class);
- mockSkinBinding = (ValueBinding) bindingSkinControl.getMock();
- FactoryFinder.releaseFactories();
- FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, TestApplicationFactory.class.getName());
- appFactory = (TestApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- FactoryFinder.releaseFactories();
- SkinFactory.reset();
- super.tearDown();
- }
-
- /*
- * Test method for 'org.richfaces.skin.SkinFactory.getInstance()'
- */
- public void testGetInstance() {
- SkinFactory factory = SkinFactory.getInstance();
- SkinFactory factory1 = SkinFactory.getInstance();
- assertSame(factory,factory1);
- }
-
- /*
- * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
- */
- public void testGetSkin() {
- SkinFactory factory = SkinFactory.getInstance();
- // setup context mock
- mockContext.getExternalContext();
- contextControl.setReturnValue(mockExternalContext);
- contextControl.replay();
- // setup External context mock
- mockExternalContext.getInitParameter(SkinFactory.SKIN_PARAMETER);
- externalContextControl.setReturnValue("test");
- externalContextControl.replay();
- // setup Application mock
- Application app = appFactory.getApplication();
- app.createValueBinding("#{test.bean}");
- appFactory.getApplicationControl().setReturnValue(mockBinding);
- appFactory.getApplicationControl().replay();
- // setup Value binding mock.
- mockBinding.getValue(mockContext);
- bindingControl.setReturnValue("test.value");
- mockBinding.getValue(mockContext);
- bindingControl.setReturnValue("test.value1");
- bindingControl.setDefaultReturnValue("test.value");
- bindingControl.replay();
- // test call
- Skin skin = factory.getSkin(mockContext);
- // calls control
- contextControl.verify();
- externalContextControl.verify();
- appFactory.getApplicationControl().verify();
- assertNotNull("Null skin!",skin);
- // test properties
- assertEquals("string",skin.getParameter(mockContext,"string.property"));
- assertEquals("base.string",skin.getParameter(mockContext,"base.property"));
- assertEquals("test.value",skin.getParameter(mockContext,"bind.property"));
-// assertEquals("HTML_BASIC",skin.getRenderKitId(mockContext));
- }
-
- /*
- * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
- */
- public void testSkinReferences() {
- SkinFactory factory = SkinFactory.getInstance();
- // setup context mock
- mockContext.getExternalContext();
- contextControl.setReturnValue(mockExternalContext);
- contextControl.replay();
- // setup External context mock
- mockExternalContext.getInitParameter(SkinFactory.SKIN_PARAMETER);
- externalContextControl.setReturnValue("test");
- externalContextControl.replay();
- // setup Application mock
- Application app = appFactory.getApplication();
- app.createValueBinding("#{test.bean}");
- appFactory.getApplicationControl().setReturnValue(mockBinding);
- appFactory.getApplicationControl().replay();
- // setup Value binding mock.
- mockBinding.getValue(mockContext);
- bindingControl.setReturnValue("test.value");
- mockBinding.getValue(mockContext);
- bindingControl.setReturnValue("test.value1");
- bindingControl.setDefaultReturnValue("test.value");
- bindingControl.replay();
- // test call
- Skin skin = factory.getSkin(mockContext);
- // calls control
- contextControl.verify();
- externalContextControl.verify();
- appFactory.getApplicationControl().verify();
- assertNotNull("Null skin!",skin);
- assertEquals("default",skin.getParameter(mockContext,"c"));
- assertEquals("yyy",skin.getParameter(mockContext,"y"));
- }
-
- /*
- * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
- */
- public void testCyclicSkinReferences() {
- SkinFactory factory = SkinFactory.getInstance();
- // setup context mock
- mockContext.getExternalContext();
- contextControl.setReturnValue(mockExternalContext);
- contextControl.replay();
- // setup External context mock
- mockExternalContext.getInitParameter(SkinFactory.SKIN_PARAMETER);
- externalContextControl.setReturnValue("cyclic");
- externalContextControl.replay();
- // test call
- try {
- Skin skin = factory.getSkin(mockContext);
- } catch(FacesException e){
- return;
- }
- assertTrue(false);
- }
-
- /*
- * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
- */
- public void testBadSkinReferences() {
- SkinFactory factory = SkinFactory.getInstance();
- // setup context mock
- mockContext.getExternalContext();
- contextControl.setReturnValue(mockExternalContext);
- contextControl.replay();
- // setup External context mock
- mockExternalContext.getInitParameter(SkinFactory.SKIN_PARAMETER);
- externalContextControl.setReturnValue("noref");
- externalContextControl.replay();
- // test call
- try {
- Skin skin = factory.getSkin(mockContext);
- } catch(FacesException e){
- return;
- }
- assertTrue(false);
- }
- /*
- * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
- */
- public void testGetBindedSkin() {
- SkinFactory factory = SkinFactory.getInstance();
- // setup context mock
- mockContext.getExternalContext();
- contextControl.setReturnValue(mockExternalContext);
- mockContext.getApplication();
- contextControl.setReturnValue(appFactory.getApplication());
- contextControl.replay();
- // setup External context mock
- mockExternalContext.getInitParameter(SkinFactory.SKIN_PARAMETER);
- externalContextControl.setReturnValue("#{test.skin}");
- externalContextControl.replay();
- // setup Application mock
- Application app = appFactory.getApplication();
- app.createValueBinding("#{test.skin}");
- appFactory.getApplicationControl().setReturnValue(mockSkinBinding);
- app.createValueBinding("#{test.bean}");
- appFactory.getApplicationControl().setReturnValue(mockBinding);
- appFactory.getApplicationControl().replay();
- // setup Value binding mock.
- mockBinding.getValue(mockContext);
- bindingControl.setReturnValue("binded.test.value");
- bindingControl.replay();
- // skin EL binding.
- mockSkinBinding.getValue(mockContext);
- bindingSkinControl.setDefaultReturnValue("bindedtest");
- bindingSkinControl.replay();
- // test call
- Skin skin = factory.getSkin(mockContext);
- assertNotNull("Null skin!",skin);
- // test properties
- assertEquals("bindedstring",skin.getParameter(mockContext,"string.property"));
-// assertEquals("base.string",skin.getParameter(mockContext,"base.property"));
- assertEquals("binded.test.value",skin.getParameter(mockContext,"bind.property"));
- assertEquals("TEST",skin.getRenderKitId(mockContext));
-
-
- // calls control
-// contextControl.verify();
-// externalContextControl.verify();
-// appFactory.getApplicationControl().verify();
-// bindingControl.verify();
-// bindingSkinControl.verify();
-}
-
- public void testSkinHash() {
- SkinFactory factory = SkinFactory.getInstance();
- // setup context mock
- mockContext.getExternalContext();
- contextControl.setDefaultReturnValue(mockExternalContext);
- mockContext.getApplication();
- contextControl.setReturnValue(appFactory.getApplication());
- contextControl.replay();
- // setup External context mock
- mockExternalContext.getInitParameter(SkinFactory.SKIN_PARAMETER);
- externalContextControl.setReturnValue("#{test.skin}");
- Map params = new HashMap();
- mockExternalContext.getRequestMap();
- externalContextControl.setDefaultReturnValue(params);
- externalContextControl.replay();
- // setup Application mock
- Application app = appFactory.getApplication();
- app.createValueBinding("#{test.skin}");
- appFactory.getApplicationControl().setReturnValue(mockSkinBinding);
- app.createValueBinding("#{test.bean}");
- appFactory.getApplicationControl().setReturnValue(mockBinding);
- appFactory.getApplicationControl().replay();
- // setup Value binding mock.
- mockBinding.getValue(mockContext);
- bindingControl.setDefaultReturnValue("binded.test.value");
- bindingControl.replay();
- // skin EL binding.
- mockSkinBinding.getValue(mockContext);
- bindingSkinControl.setDefaultReturnValue("bindedtest");
- bindingSkinControl.replay();
- // test call
- Skin skin = factory.getSkin(mockContext);
- assertNotNull("Null skin!",skin);
- // test properties
- int hash = skin.hashCode(mockContext);
- assertTrue(params.containsKey(SkinImpl.REQUEST_HASH_CODE_PARAMETER));
- assertEquals(hash,skin.hashCode(mockContext));
- params.clear();
- assertEquals(hash,skin.hashCode(mockContext));
- // setup Value binding mock for different value - hash must differ.
- params.clear();
- bindingControl.reset();
- mockBinding.getValue(mockContext);
- bindingControl.setDefaultReturnValue("other.test.value");
- bindingControl.replay();
- assertFalse( hash==skin.hashCode(mockContext) );
-
- }
- /*
- * Test method for 'org.richfaces.skin.SkinFactory.getDefaultProperties()'
- */
- public void testGetDefaultProperties() {
- SkinFactoryImpl factory = (SkinFactoryImpl) SkinFactory.getInstance();
- Properties defaultProps = factory.getDefaultSkinProperties();
-// assertEquals("HTML_BASIC",defaultProps.getProperty("render.kit"));
- // Second default config
- assertEquals("default",defaultProps.getProperty("a"));
- }
-
- /*
- * Test method for 'org.richfaces.skin.SkinFactory.getSkinName(FacesContext)'
- */
- public void testGetSkinName() {
-
- }
-
-}
Copied: trunk/framework/test/src/test/java/org/richfaces/skin/SkinTestCase.java (from rev 1587, trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/SkinTestCase.java)
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/skin/SkinTestCase.java (rev 0)
+++ trunk/framework/test/src/test/java/org/richfaces/skin/SkinTestCase.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -0,0 +1,330 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.skin;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import junit.framework.TestCase;
+
+import org.easymock.MockControl;
+import org.easymock.classextension.MockClassControl;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+import org.richfaces.skin.SkinFactoryImpl;
+import org.richfaces.skin.SkinImpl;
+
+/**
+ * Test for Skin/skin factory methods.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/10 14:28:13 $
+ *
+ */
+public class SkinTestCase extends TestCase {
+ private MockControl contextControl;
+ private FacesContext mockContext;
+
+ private MockControl externalContextControl;
+ private ExternalContext mockExternalContext;
+
+ private TestApplicationFactory appFactory;
+
+ private MockControl bindingControl;
+ private ValueBinding mockBinding;
+ private MockControl bindingSkinControl;
+ private ValueBinding mockSkinBinding;
+
+ public SkinTestCase(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ contextControl = MockClassControl.createControl(FacesContext.class);
+ mockContext = (FacesContext) contextControl.getMock();
+ externalContextControl = MockClassControl.createControl(ExternalContext.class);
+ mockExternalContext = (ExternalContext) externalContextControl.getMock();
+ bindingControl = MockClassControl.createNiceControl(ValueBinding.class);
+ mockBinding = (ValueBinding) bindingControl.getMock();
+ bindingSkinControl = MockClassControl.createNiceControl(ValueBinding.class);
+ mockSkinBinding = (ValueBinding) bindingSkinControl.getMock();
+ FactoryFinder.releaseFactories();
+ FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, TestApplicationFactory.class.getName());
+ appFactory = (TestApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ FactoryFinder.releaseFactories();
+ SkinFactory.reset();
+ super.tearDown();
+ }
+
+ /*
+ * Test method for 'org.richfaces.skin.SkinFactory.getInstance()'
+ */
+ public void testGetInstance() {
+ SkinFactory factory = SkinFactory.getInstance();
+ SkinFactory factory1 = SkinFactory.getInstance();
+ assertSame(factory,factory1);
+ }
+
+ /*
+ * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
+ */
+ public void testGetSkin() {
+ SkinFactory factory = SkinFactory.getInstance();
+ // setup context mock
+ mockContext.getExternalContext();
+ contextControl.setReturnValue(mockExternalContext);
+ contextControl.replay();
+ // setup External context mock
+ mockExternalContext.getInitParameter(SkinFactory.SKIN_PARAMETER);
+ externalContextControl.setReturnValue("test");
+ externalContextControl.replay();
+ // setup Application mock
+ Application app = appFactory.getApplication();
+ app.createValueBinding("#{test.bean}");
+ appFactory.getApplicationControl().setReturnValue(mockBinding);
+ appFactory.getApplicationControl().replay();
+ // setup Value binding mock.
+ mockBinding.getValue(mockContext);
+ bindingControl.setReturnValue("test.value");
+ mockBinding.getValue(mockContext);
+ bindingControl.setReturnValue("test.value1");
+ bindingControl.setDefaultReturnValue("test.value");
+ bindingControl.replay();
+ // test call
+ Skin skin = factory.getSkin(mockContext);
+ // calls control
+ contextControl.verify();
+ externalContextControl.verify();
+ appFactory.getApplicationControl().verify();
+ assertNotNull("Null skin!",skin);
+ // test properties
+ assertEquals("string",skin.getParameter(mockContext,"string.property"));
+ assertEquals("base.string",skin.getParameter(mockContext,"base.property"));
+ assertEquals("test.value",skin.getParameter(mockContext,"bind.property"));
+// assertEquals("HTML_BASIC",skin.getRenderKitId(mockContext));
+ }
+
+ /*
+ * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
+ */
+ public void testSkinReferences() {
+ SkinFactory factory = SkinFactory.getInstance();
+ // setup context mock
+ mockContext.getExternalContext();
+ contextControl.setReturnValue(mockExternalContext);
+ contextControl.replay();
+ // setup External context mock
+ mockExternalContext.getInitParameter(SkinFactory.SKIN_PARAMETER);
+ externalContextControl.setReturnValue("test");
+ externalContextControl.replay();
+ // setup Application mock
+ Application app = appFactory.getApplication();
+ app.createValueBinding("#{test.bean}");
+ appFactory.getApplicationControl().setReturnValue(mockBinding);
+ appFactory.getApplicationControl().replay();
+ // setup Value binding mock.
+ mockBinding.getValue(mockContext);
+ bindingControl.setReturnValue("test.value");
+ mockBinding.getValue(mockContext);
+ bindingControl.setReturnValue("test.value1");
+ bindingControl.setDefaultReturnValue("test.value");
+ bindingControl.replay();
+ // test call
+ Skin skin = factory.getSkin(mockContext);
+ // calls control
+ contextControl.verify();
+ externalContextControl.verify();
+ appFactory.getApplicationControl().verify();
+ assertNotNull("Null skin!",skin);
+ assertEquals("default",skin.getParameter(mockContext,"c"));
+ assertEquals("yyy",skin.getParameter(mockContext,"y"));
+ }
+
+ /*
+ * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
+ */
+ public void testCyclicSkinReferences() {
+ SkinFactory factory = SkinFactory.getInstance();
+ // setup context mock
+ mockContext.getExternalContext();
+ contextControl.setReturnValue(mockExternalContext);
+ contextControl.replay();
+ // setup External context mock
+ mockExternalContext.getInitParameter(SkinFactory.SKIN_PARAMETER);
+ externalContextControl.setReturnValue("cyclic");
+ externalContextControl.replay();
+ // test call
+ try {
+ Skin skin = factory.getSkin(mockContext);
+ } catch(FacesException e){
+ return;
+ }
+ assertTrue(false);
+ }
+
+ /*
+ * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
+ */
+ public void testBadSkinReferences() {
+ SkinFactory factory = SkinFactory.getInstance();
+ // setup context mock
+ mockContext.getExternalContext();
+ contextControl.setReturnValue(mockExternalContext);
+ contextControl.replay();
+ // setup External context mock
+ mockExternalContext.getInitParameter(SkinFactory.SKIN_PARAMETER);
+ externalContextControl.setReturnValue("noref");
+ externalContextControl.replay();
+ // test call
+ try {
+ Skin skin = factory.getSkin(mockContext);
+ } catch(FacesException e){
+ return;
+ }
+ assertTrue(false);
+ }
+ /*
+ * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
+ */
+ public void testGetBindedSkin() {
+ SkinFactory factory = SkinFactory.getInstance();
+ // setup context mock
+ mockContext.getExternalContext();
+ contextControl.setReturnValue(mockExternalContext);
+ mockContext.getApplication();
+ contextControl.setReturnValue(appFactory.getApplication());
+ contextControl.replay();
+ // setup External context mock
+ mockExternalContext.getInitParameter(SkinFactory.SKIN_PARAMETER);
+ externalContextControl.setReturnValue("#{test.skin}");
+ externalContextControl.replay();
+ // setup Application mock
+ Application app = appFactory.getApplication();
+ app.createValueBinding("#{test.skin}");
+ appFactory.getApplicationControl().setReturnValue(mockSkinBinding);
+ app.createValueBinding("#{test.bean}");
+ appFactory.getApplicationControl().setReturnValue(mockBinding);
+ appFactory.getApplicationControl().replay();
+ // setup Value binding mock.
+ mockBinding.getValue(mockContext);
+ bindingControl.setReturnValue("binded.test.value");
+ bindingControl.replay();
+ // skin EL binding.
+ mockSkinBinding.getValue(mockContext);
+ bindingSkinControl.setDefaultReturnValue("bindedtest");
+ bindingSkinControl.replay();
+ // test call
+ Skin skin = factory.getSkin(mockContext);
+ assertNotNull("Null skin!",skin);
+ // test properties
+ assertEquals("bindedstring",skin.getParameter(mockContext,"string.property"));
+// assertEquals("base.string",skin.getParameter(mockContext,"base.property"));
+ assertEquals("binded.test.value",skin.getParameter(mockContext,"bind.property"));
+ assertEquals("TEST",skin.getRenderKitId(mockContext));
+
+
+ // calls control
+// contextControl.verify();
+// externalContextControl.verify();
+// appFactory.getApplicationControl().verify();
+// bindingControl.verify();
+// bindingSkinControl.verify();
+}
+
+ public void testSkinHash() {
+ SkinFactory factory = SkinFactory.getInstance();
+ // setup context mock
+ mockContext.getExternalContext();
+ contextControl.setDefaultReturnValue(mockExternalContext);
+ mockContext.getApplication();
+ contextControl.setReturnValue(appFactory.getApplication());
+ contextControl.replay();
+ // setup External context mock
+ mockExternalContext.getInitParameter(SkinFactory.SKIN_PARAMETER);
+ externalContextControl.setReturnValue("#{test.skin}");
+ Map params = new HashMap();
+ mockExternalContext.getRequestMap();
+ externalContextControl.setDefaultReturnValue(params);
+ externalContextControl.replay();
+ // setup Application mock
+ Application app = appFactory.getApplication();
+ app.createValueBinding("#{test.skin}");
+ appFactory.getApplicationControl().setReturnValue(mockSkinBinding);
+ app.createValueBinding("#{test.bean}");
+ appFactory.getApplicationControl().setReturnValue(mockBinding);
+ appFactory.getApplicationControl().replay();
+ // setup Value binding mock.
+ mockBinding.getValue(mockContext);
+ bindingControl.setDefaultReturnValue("binded.test.value");
+ bindingControl.replay();
+ // skin EL binding.
+ mockSkinBinding.getValue(mockContext);
+ bindingSkinControl.setDefaultReturnValue("bindedtest");
+ bindingSkinControl.replay();
+ // test call
+ Skin skin = factory.getSkin(mockContext);
+ assertNotNull("Null skin!",skin);
+ // test properties
+ int hash = skin.hashCode(mockContext);
+ assertTrue(params.containsKey(SkinImpl.REQUEST_HASH_CODE_PARAMETER));
+ assertEquals(hash,skin.hashCode(mockContext));
+ params.clear();
+ assertEquals(hash,skin.hashCode(mockContext));
+ // setup Value binding mock for different value - hash must differ.
+ params.clear();
+ bindingControl.reset();
+ mockBinding.getValue(mockContext);
+ bindingControl.setDefaultReturnValue("other.test.value");
+ bindingControl.replay();
+ assertFalse( hash==skin.hashCode(mockContext) );
+
+ }
+ /*
+ * Test method for 'org.richfaces.skin.SkinFactory.getDefaultProperties()'
+ */
+ public void testGetDefaultProperties() {
+ SkinFactoryImpl factory = (SkinFactoryImpl) SkinFactory.getInstance();
+ Properties defaultProps = factory.getDefaultSkinProperties();
+// assertEquals("HTML_BASIC",defaultProps.getProperty("render.kit"));
+ // Second default config
+ assertEquals("default",defaultProps.getProperty("a"));
+ }
+
+ /*
+ * Test method for 'org.richfaces.skin.SkinFactory.getSkinName(FacesContext)'
+ */
+ public void testGetSkinName() {
+
+ }
+
+}
Deleted: trunk/framework/test/src/test/java/org/richfaces/skin/SkinTests.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/SkinTests.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/test/src/test/java/org/richfaces/skin/SkinTests.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,39 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.skin;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class SkinTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for org.richfaces.skin");
- //$JUnit-BEGIN$
- suite.addTestSuite(SkinThreadsTestCase.class);
- suite.addTestSuite(SkinTestCase.class);
- //$JUnit-END$
- return suite;
- }
-
-}
Copied: trunk/framework/test/src/test/java/org/richfaces/skin/SkinTests.java (from rev 1587, trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/SkinTests.java)
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/skin/SkinTests.java (rev 0)
+++ trunk/framework/test/src/test/java/org/richfaces/skin/SkinTests.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -0,0 +1,39 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.skin;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class SkinTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.richfaces.skin");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(SkinThreadsTestCase.class);
+ suite.addTestSuite(SkinTestCase.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
Deleted: trunk/framework/test/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/SkinThreadsTestCase.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/test/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,112 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.skin;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.tests.AbstractThreadedAjax4JsfTestCase;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/20 20:58:11 $
- *
- */
-public class SkinThreadsTestCase extends AbstractThreadedAjax4JsfTestCase {
-
- /**
- * @param s
- */
- public SkinThreadsTestCase(String s) {
- super(s);
- // TODO Auto-generated constructor stub
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.exadel.vcp.tests.VcpJsfTestCase#setUp()
- */
-public void setUp() throws Exception {
- // TODO Auto-generated method stub
- super.setUp();
- servletContext.setAttribute("skin", new Bean());
- }
- /*
- * (non-Javadoc)
- *
- * @see com.exadel.vcp.tests.VcpJsfTestCase#tearDown()
- */
- public void tearDown() throws Exception {
- // TODO Auto-generated method stub
- super.tearDown();
- }
-
-
- public class SkinTestRunnable extends TestCaseRunnable {
-
-
- /**
- *
- */
- public SkinTestRunnable() {
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.tests.ThreadedVcpJsfTestCase.TestCaseRunnable#runTestCase(javax.faces.context.FacesContext)
- */
- public void runTestCase(FacesContext context) throws Throwable {
- context.getExternalContext().getRequestMap().put("test", new Bean());
- Skin skin = SkinFactory.getInstance().getSkin(context);
- assertNotNull(skin);
- assertEquals("TEST", skin.getRenderKitId(context));
- assertEquals("binded.string", skin.getParameter(context, "bind.property"));
- assertEquals("bindedstring", skin.getParameter(context, "string.property"));
- assertEquals("10", skin.getParameter(context, "int.property"));
- assertNull(skin.getParameter(context, "notexist"));
- }
-
- }
-
- /**
- * Test skin factory for thread-safe.
- */
- public void testThreadsafe() {
- TestCaseRunnable[] runnables = new TestCaseRunnable[20];
- for (int i = 0; i < runnables.length; i++) {
- runnables[i] = new SkinTestRunnable();
-
- }
- this.runTestCaseRunnables(runnables);
- }
- /*
- * (non-Javadoc)
- *
- * @see com.exadel.vcp.tests.VcpJsfTestCase#getSkinName()
- */
- protected String getSkinName() {
- // TODO Auto-generated method stub
- return "#{skin.name}";
- }
-}
Copied: trunk/framework/test/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java (from rev 1587, trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/SkinThreadsTestCase.java)
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java (rev 0)
+++ trunk/framework/test/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -0,0 +1,112 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.skin;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.tests.AbstractThreadedAjax4JsfTestCase;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/20 20:58:11 $
+ *
+ */
+public class SkinThreadsTestCase extends AbstractThreadedAjax4JsfTestCase {
+
+ /**
+ * @param s
+ */
+ public SkinThreadsTestCase(String s) {
+ super(s);
+ // TODO Auto-generated constructor stub
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.exadel.vcp.tests.VcpJsfTestCase#setUp()
+ */
+public void setUp() throws Exception {
+ // TODO Auto-generated method stub
+ super.setUp();
+ servletContext.setAttribute("skin", new Bean());
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.exadel.vcp.tests.VcpJsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ // TODO Auto-generated method stub
+ super.tearDown();
+ }
+
+
+ public class SkinTestRunnable extends TestCaseRunnable {
+
+
+ /**
+ *
+ */
+ public SkinTestRunnable() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.tests.ThreadedVcpJsfTestCase.TestCaseRunnable#runTestCase(javax.faces.context.FacesContext)
+ */
+ public void runTestCase(FacesContext context) throws Throwable {
+ context.getExternalContext().getRequestMap().put("test", new Bean());
+ Skin skin = SkinFactory.getInstance().getSkin(context);
+ assertNotNull(skin);
+ assertEquals("TEST", skin.getRenderKitId(context));
+ assertEquals("binded.string", skin.getParameter(context, "bind.property"));
+ assertEquals("bindedstring", skin.getParameter(context, "string.property"));
+ assertEquals("10", skin.getParameter(context, "int.property"));
+ assertNull(skin.getParameter(context, "notexist"));
+ }
+
+ }
+
+ /**
+ * Test skin factory for thread-safe.
+ */
+ public void testThreadsafe() {
+ TestCaseRunnable[] runnables = new TestCaseRunnable[20];
+ for (int i = 0; i < runnables.length; i++) {
+ runnables[i] = new SkinTestRunnable();
+
+ }
+ this.runTestCaseRunnables(runnables);
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.exadel.vcp.tests.VcpJsfTestCase#getSkinName()
+ */
+ protected String getSkinName() {
+ // TODO Auto-generated method stub
+ return "#{skin.name}";
+ }
+}
Deleted: trunk/framework/test/src/test/java/org/richfaces/skin/TestApplicationFactory.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/TestApplicationFactory.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/test/src/test/java/org/richfaces/skin/TestApplicationFactory.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -1,115 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.skin;
-
-
-
-import javax.faces.application.Application;
-
-import javax.faces.application.ApplicationFactory;
-
-
-
-import org.easymock.MockControl;
-
-import org.easymock.classextension.MockClassControl;
-
-
-
-/**
-
- * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
-
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/20 20:58:11 $
-
- *
-
- */
-
-public class TestApplicationFactory extends ApplicationFactory {
-
-
-
- private MockControl applicationControl;
-
- private Application mockApplication;
-
-
-
- public TestApplicationFactory(){
-
- applicationControl = MockClassControl.createControl(Application.class);
-
- mockApplication = (Application) applicationControl.getMock();
-
- }
-
-
-
- /* (non-Javadoc)
-
- * @see javax.faces.application.ApplicationFactory#getApplication()
-
- */
-
- public Application getApplication() {
-
- // TODO Auto-generated method stub
-
- return mockApplication;
-
- }
-
-
-
- /* (non-Javadoc)
-
- * @see javax.faces.application.ApplicationFactory#setApplication(javax.faces.application.Application)
-
- */
-
- public void setApplication(Application arg0) {
-
- // TODO Auto-generated method stub
-
-
-
- }
-
-
-
- /**
-
- * @return Returns the applicationControl.
-
- */
-
- public MockControl getApplicationControl() {
-
- return applicationControl;
-
- }
-
-
-
-}
-
Copied: trunk/framework/test/src/test/java/org/richfaces/skin/TestApplicationFactory.java (from rev 1587, trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/TestApplicationFactory.java)
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/skin/TestApplicationFactory.java (rev 0)
+++ trunk/framework/test/src/test/java/org/richfaces/skin/TestApplicationFactory.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -0,0 +1,115 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.skin;
+
+
+
+import javax.faces.application.Application;
+
+import javax.faces.application.ApplicationFactory;
+
+
+
+import org.easymock.MockControl;
+
+import org.easymock.classextension.MockClassControl;
+
+
+
+/**
+
+ * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
+
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/20 20:58:11 $
+
+ *
+
+ */
+
+public class TestApplicationFactory extends ApplicationFactory {
+
+
+
+ private MockControl applicationControl;
+
+ private Application mockApplication;
+
+
+
+ public TestApplicationFactory(){
+
+ applicationControl = MockClassControl.createControl(Application.class);
+
+ mockApplication = (Application) applicationControl.getMock();
+
+ }
+
+
+
+ /* (non-Javadoc)
+
+ * @see javax.faces.application.ApplicationFactory#getApplication()
+
+ */
+
+ public Application getApplication() {
+
+ // TODO Auto-generated method stub
+
+ return mockApplication;
+
+ }
+
+
+
+ /* (non-Javadoc)
+
+ * @see javax.faces.application.ApplicationFactory#setApplication(javax.faces.application.Application)
+
+ */
+
+ public void setApplication(Application arg0) {
+
+ // TODO Auto-generated method stub
+
+
+
+ }
+
+
+
+ /**
+
+ * @return Returns the applicationControl.
+
+ */
+
+ public MockControl getApplicationControl() {
+
+ return applicationControl;
+
+ }
+
+
+
+}
+
Modified: trunk/samples/useCases/src/main/java/control/test/ControlBackingBean.java
===================================================================
--- trunk/samples/useCases/src/main/java/control/test/ControlBackingBean.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/samples/useCases/src/main/java/control/test/ControlBackingBean.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -13,9 +13,11 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import javax.faces.event.ActionEvent;
-import org.ajax4jsf.ajax.html.HtmlAjaxRepeat;
+import org.ajax4jsf.component.html.HtmlAjaxRepeat;
+
/**
*
* @author Administrador
Modified: trunk/samples/useCases/src/test/java/org/ajax4jsf/BeanTest.java
===================================================================
--- trunk/samples/useCases/src/test/java/org/ajax4jsf/BeanTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/samples/useCases/src/test/java/org/ajax4jsf/BeanTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -21,9 +21,7 @@
package org.ajax4jsf;
-import junit.framework.Test;
import junit.framework.TestCase;
-import junit.framework.TestSuite;
/**
*/
Modified: trunk/ui/dataFilterSlider/src/main/java/org/richfaces/component/UIDataFltrSlider.java
===================================================================
--- trunk/ui/dataFilterSlider/src/main/java/org/richfaces/component/UIDataFltrSlider.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/dataFilterSlider/src/main/java/org/richfaces/component/UIDataFltrSlider.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -21,23 +21,25 @@
package org.richfaces.component;
-import org.richfaces.event.DataFilterSliderEvent;
-import org.richfaces.event.DataFilterSliderListener;
-import org.richfaces.event.DataFilterSliderSource;
-import org.richfaces.event.DataFilterSliderAdapter;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.component.UIData;
import javax.faces.context.FacesContext;
-import javax.faces.event.*;
+import javax.faces.el.MethodBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
import javax.faces.model.ListDataModel;
-import javax.faces.el.MethodBinding;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import org.richfaces.event.DataFilterSliderAdapter;
+import org.richfaces.event.DataFilterSliderEvent;
+import org.richfaces.event.DataFilterSliderListener;
+import org.richfaces.event.DataFilterSliderSource;
+
/**
* JSF component class
*/
Modified: trunk/ui/dataFilterSlider/src/main/java/org/richfaces/taglib/DataFilterSliderListenerTagHandler.java
===================================================================
--- trunk/ui/dataFilterSlider/src/main/java/org/richfaces/taglib/DataFilterSliderListenerTagHandler.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/dataFilterSlider/src/main/java/org/richfaces/taglib/DataFilterSliderListenerTagHandler.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -21,17 +21,21 @@
package org.richfaces.taglib;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-import com.sun.facelets.tag.jsf.ComponentHandler;
-import com.sun.facelets.tag.*;
-import com.sun.facelets.FaceletContext;
-
+import javax.faces.component.UIComponent;
import javax.faces.el.MethodBinding;
-import javax.faces.component.UIComponent;
import org.richfaces.event.DataFilterSliderEvent;
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.jsf.ComponentHandler;
+
public class DataFilterSliderListenerTagHandler extends ComponentHandler {
private final static String SLIDER_LISTENER = "sliderListener";
Modified: trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
===================================================================
--- trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -31,7 +31,6 @@
import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
-import javax.faces.component.UIViewRoot;
import javax.faces.component.html.HtmlCommandLink;
import javax.faces.component.html.HtmlForm;
import javax.faces.context.FacesContext;
@@ -42,11 +41,11 @@
import javax.faces.el.ValueBinding;
import javax.servlet.http.HttpServletResponse;
-import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceBuilderImpl;
+import org.ajax4jsf.resource.image.ImageInfo;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
import org.richfaces.event.DataFilterSliderAdapter;
Modified: trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java
===================================================================
--- trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -22,27 +22,27 @@
package org.richfaces.component;
-import com.gargoylesoftware.htmlunit.Page;
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlScript;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
-import org.ajax4jsf.framework.util.image.ImageInfo;
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+import javax.servlet.http.HttpServletResponse;
+
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceBuilderImpl;
+import org.ajax4jsf.resource.image.ImageInfo;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
-import javax.faces.component.UIForm;
-import javax.faces.component.html.HtmlForm;
-import javax.servlet.http.HttpServletResponse;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
/**
* Unit test for Datascroller component.
*/
Modified: trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
===================================================================
--- trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -21,20 +21,11 @@
package org.richfaces.component;
-import com.gargoylesoftware.htmlunit.KeyValuePair;
-import com.gargoylesoftware.htmlunit.Page;
-import com.gargoylesoftware.htmlunit.html.*;
-import org.ajax4jsf.framework.util.image.ImageInfo;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.ResourceBuilderImpl;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.apache.commons.lang.StringUtils;
-import org.richfaces.renderkit.html.images.SliderArrowImage;
-import org.richfaces.renderkit.html.images.SliderArrowSelectedImage;
-import org.richfaces.renderkit.html.images.SliderFieldGradient;
-import org.richfaces.renderkit.html.images.SliderTrackGradient;
+import java.awt.Dimension;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
@@ -46,12 +37,28 @@
import javax.faces.el.PropertyNotFoundException;
import javax.faces.el.ValueBinding;
import javax.servlet.http.HttpServletResponse;
-import java.awt.*;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
+import org.ajax4jsf.resource.image.ImageInfo;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
+import org.richfaces.renderkit.html.images.SliderArrowImage;
+import org.richfaces.renderkit.html.images.SliderArrowSelectedImage;
+import org.richfaces.renderkit.html.images.SliderFieldGradient;
+import org.richfaces.renderkit.html.images.SliderTrackGradient;
+
+import com.gargoylesoftware.htmlunit.KeyValuePair;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.html.DomNode;
+import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+
/** Unit test for simple Component. */
public class InputNumberSliderComponentTest extends AbstractAjax4JsfTestCase {
Modified: trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/background/SpinnerButtonGradient.java
===================================================================
--- trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/background/SpinnerButtonGradient.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/background/SpinnerButtonGradient.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -21,11 +21,6 @@
package org.richfaces.renderkit.html.images.background;
-import java.awt.Dimension;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.renderkit.html.BaseGradient;
public class SpinnerButtonGradient extends BaseGradient {
Modified: trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/background/SpinnerFieldGradient.java
===================================================================
--- trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/background/SpinnerFieldGradient.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/background/SpinnerFieldGradient.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -21,11 +21,6 @@
package org.richfaces.renderkit.html.images.background;
-import java.awt.Dimension;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.renderkit.html.BaseGradient;
public class SpinnerFieldGradient extends BaseGradient {
Modified: trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
===================================================================
--- trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -21,20 +21,12 @@
package org.richfaces.component;
-import com.gargoylesoftware.htmlunit.KeyValuePair;
-import com.gargoylesoftware.htmlunit.Page;
-import com.gargoylesoftware.htmlunit.html.*;
-import org.ajax4jsf.framework.util.image.ImageInfo;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.ResourceBuilderImpl;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.apache.commons.lang.StringUtils;
-import org.richfaces.renderkit.html.images.background.SpinnerButtonGradient;
-import org.richfaces.renderkit.html.images.background.SpinnerFieldGradient;
-import org.richfaces.renderkit.html.images.buttons.SpinnerButtonDown;
-import org.richfaces.renderkit.html.images.buttons.SpinnerButtonUp;
+import java.awt.Dimension;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
@@ -46,10 +38,27 @@
import javax.faces.el.PropertyNotFoundException;
import javax.faces.el.ValueBinding;
import javax.servlet.http.HttpServletResponse;
-import java.awt.*;
-import java.util.*;
-import java.util.List;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
+import org.ajax4jsf.resource.image.ImageInfo;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
+import org.richfaces.renderkit.html.images.background.SpinnerButtonGradient;
+import org.richfaces.renderkit.html.images.background.SpinnerFieldGradient;
+import org.richfaces.renderkit.html.images.buttons.SpinnerButtonDown;
+import org.richfaces.renderkit.html.images.buttons.SpinnerButtonUp;
+
+import com.gargoylesoftware.htmlunit.KeyValuePair;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+
/** Unit test for simple Component. */
public class InputNumberSpinnerComponentTest extends AbstractAjax4JsfTestCase {
Modified: trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
===================================================================
--- trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -25,13 +25,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.ComponentVariables;
import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
-import org.richfaces.component.MenuComponent;
import org.richfaces.component.UIMenuGroup;
-import org.richfaces.component.UIMenuItem;
import org.richfaces.component.util.ViewUtil;
Modified: trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
===================================================================
--- trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -32,22 +32,20 @@
import javax.faces.component.html.HtmlOutputText;
import javax.servlet.http.HttpServletResponse;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
+import org.ajax4jsf.resource.image.ImageInfo;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
import org.richfaces.component.html.HtmlMenuGroup;
import org.richfaces.renderkit.html.images.MenuNodeImage;
import com.gargoylesoftware.htmlunit.Page;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlScript;
-import org.ajax4jsf.framework.util.image.ImageInfo;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceBuilderImpl;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-
-import org.apache.commons.lang.StringUtils;
-
/**
* Unit test for MenuGroup Component.
*/
Modified: trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
===================================================================
--- trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -33,24 +33,22 @@
import javax.faces.event.PhaseId;
import javax.servlet.http.HttpServletResponse;
-import org.richfaces.component.html.HtmlMenuItem;
-import org.richfaces.renderkit.html.images.background.MenuItemBackground;
-
-import com.gargoylesoftware.htmlunit.Page;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlScript;
-
-import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceBuilderImpl;
+import org.ajax4jsf.resource.image.ImageInfo;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.ajax4jsf.tests.MockViewRoot;
-
import org.apache.commons.collections.Buffer;
import org.apache.commons.lang.StringUtils;
+import org.richfaces.component.html.HtmlMenuItem;
+import org.richfaces.renderkit.html.images.background.MenuItemBackground;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+
/**
* Unit test for MenuItem Component.
*/
Modified: trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuSeparatorComponentTest.java
===================================================================
--- trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuSeparatorComponentTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuSeparatorComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -25,7 +25,6 @@
import javax.faces.component.html.HtmlForm;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.richfaces.component.html.HtmlMenuItem;
import org.richfaces.component.html.HtmlMenuSeparator;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
Modified: trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java
===================================================================
--- trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -21,6 +21,18 @@
package org.richfaces.renderkit.html.images;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.geom.Rectangle2D;
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.resource.GifRenderer;
@@ -31,12 +43,6 @@
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
-import javax.faces.context.FacesContext;
-import java.awt.*;
-import java.awt.geom.Rectangle2D;
-import java.io.Serializable;
-import java.util.Date;
-
/**
* @author Maksim Kaszynski, Filip Antonov
*/
Modified: trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java
===================================================================
--- trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -21,6 +21,16 @@
package org.richfaces.renderkit.html.images;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.resource.GifRenderer;
@@ -31,14 +41,6 @@
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.Serializable;
-import java.util.Date;
-
/**
* @author Konstantin Mishin, Filip Antonov
*/
Modified: trunk/ui/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java
===================================================================
--- trunk/ui/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -27,10 +27,10 @@
import javax.faces.component.html.HtmlOutputText;
import javax.servlet.http.HttpServletResponse;
-import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceBuilderImpl;
+import org.ajax4jsf.resource.image.ImageInfo;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import com.gargoylesoftware.htmlunit.Page;
Modified: trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java
===================================================================
--- trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -21,6 +21,15 @@
package org.richfaces.renderkit.images;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.Rectangle2D;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
@@ -29,11 +38,6 @@
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
-import javax.faces.context.FacesContext;
-import java.awt.*;
-import java.awt.geom.Rectangle2D;
-import java.util.Date;
-
/**
* @author Nick - mailto:nbelaevski@exadel.com
* created 02.02.2007
Modified: trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
===================================================================
--- trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -21,24 +21,26 @@
package org.richfaces.component;
-import com.gargoylesoftware.htmlunit.Page;
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlScript;
-import org.ajax4jsf.framework.util.image.ImageInfo;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+import javax.servlet.http.HttpServletResponse;
+
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceBuilderImpl;
+import org.ajax4jsf.resource.image.ImageInfo;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
-import javax.faces.component.UIForm;
-import javax.faces.component.html.HtmlForm;
-import javax.servlet.http.HttpServletResponse;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
/**
* Unit test for TabPanel component.
Modified: trunk/ui/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java
===================================================================
--- trunk/ui/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -21,23 +21,26 @@
package org.richfaces.component;
-import com.gargoylesoftware.htmlunit.Page;
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import junit.framework.Assert;
-import org.ajax4jsf.framework.util.image.ImageInfo;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceBuilderImpl;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import java.util.List;
import javax.faces.component.UICommand;
import javax.faces.component.UIForm;
import javax.faces.component.html.HtmlCommandButton;
import javax.faces.component.html.HtmlForm;
import javax.servlet.http.HttpServletResponse;
-import java.util.List;
+import junit.framework.Assert;
+
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
+import org.ajax4jsf.resource.image.ImageInfo;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
/**
* Unit test for ToolBar component.
*/
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -38,10 +38,10 @@
import javax.faces.event.PhaseId;
import javax.servlet.http.HttpServletResponse;
-import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceBuilderImpl;
+import org.ajax4jsf.resource.image.ImageInfo;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
import org.richfaces.component.state.events.ExpandAllCommandEvent;
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/state/events/CollapseAllCommandEventTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/state/events/CollapseAllCommandEventTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/state/events/CollapseAllCommandEventTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -22,14 +22,11 @@
package org.richfaces.component.state.events;
import javax.faces.FacesException;
-import javax.faces.component.UIOutput;
import javax.faces.event.FacesListener;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.richfaces.component.UITree;
-import junit.framework.TestCase;
-
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
* created 14.04.2007
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/state/events/CollapseNodeCommandEventTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/state/events/CollapseNodeCommandEventTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/state/events/CollapseNodeCommandEventTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import javax.faces.FacesException;
-import javax.faces.component.UIOutput;
import javax.faces.event.FacesListener;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
@@ -32,8 +31,6 @@
import org.richfaces.model.ListRowKey;
import org.richfaces.model.TreeRowKey;
-import junit.framework.TestCase;
-
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
* created 14.04.2007
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/state/events/ExpandAllCommandEventTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/state/events/ExpandAllCommandEventTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/state/events/ExpandAllCommandEventTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -22,14 +22,11 @@
package org.richfaces.component.state.events;
import javax.faces.FacesException;
-import javax.faces.component.UIOutput;
import javax.faces.event.FacesListener;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.richfaces.component.UITree;
-import junit.framework.TestCase;
-
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
* created 14.04.2007
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/state/events/ExpandNodeCommandEventTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/state/events/ExpandNodeCommandEventTest.java 2007-07-10 18:39:35 UTC (rev 1587)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/state/events/ExpandNodeCommandEventTest.java 2007-07-10 19:07:38 UTC (rev 1588)
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import javax.faces.FacesException;
-import javax.faces.component.UIOutput;
import javax.faces.event.FacesListener;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
@@ -32,8 +31,6 @@
import org.richfaces.model.ListRowKey;
import org.richfaces.model.TreeRowKey;
-import junit.framework.TestCase;
-
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
* created 14.04.2007
18 years, 2 months
JBoss Rich Faces SVN: r1586 - in trunk/framework: impl/src/main/java/org/ajax4jsf/dnd and 10 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-10 14:37:56 -0400 (Tue, 10 Jul 2007)
New Revision: 1586
Added:
trunk/framework/impl/src/main/java/org/richfaces/skin/
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/
trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/taglib/
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/skin/
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXHTMLStream.java
trunk/framework/impl/src/main/java/org/richfaces/skin/DummySkinConfiguration.java
trunk/framework/impl/src/main/java/org/richfaces/skin/SkinBean.java
trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
trunk/framework/impl/src/main/java/org/richfaces/skin/SkinImpl.java
trunk/framework/impl/src/main/java/org/richfaces/skin/SkinPropertyResolver.java
trunk/framework/impl/src/main/java/org/richfaces/skin/SkinVariableResolver.java
trunk/framework/impl/src/main/java/org/richfaces/skin/VersionBean.java
trunk/framework/impl/src/main/resources/org/ajax4jsf/xml/serializer/output_xhtml.properties
trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/SkinTestCase.java
Log:
packages and classes refactor
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -138,6 +138,7 @@
// If tidy not handle all requests, disable reorganising
// of html
// parser.setMoveElements(isForcexml());
+ parser.init();
}
// TODO - set header scripts/styles filter.
return parser;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -68,32 +68,34 @@
/**
* @author shura
- *
+ *
*/
-public class NekkoParser implements HtmlParser {
+public class NekkoParser implements HtmlParser {
private static final Log _log = LogFactory.getLog(NekkoParser.class);
-
+
private HtmlSAXParser _parser;
-
-// private HtmlWriter _writer= new HtmlWriter();
-
+
+ // private HtmlWriter _writer= new HtmlWriter();
+
private ElementRemover remover = new ElementRemover();
-
- private XMLDocumentFilter[] _filters = { new ViewStateFilter()/*,remover */, new HtmlCorrectionFilter(), new Purifier() /*, _writer*/ };
- private DOMFragmentParser viewStateParser ;//= new DOMFragmentParser();
+ private XMLDocumentFilter[] _filters = {
+ new ViewStateFilter()/* ,remover */, new HtmlCorrectionFilter(),
+ new Purifier() /* , _writer */};
- private Document viewStateDocument ;//= new HTMLDocumentImpl();
+ private DOMFragmentParser viewStateParser;// = new DOMFragmentParser();
+ private Document viewStateDocument;// = new HTMLDocumentImpl();
+
private DocumentFragment fragment = null;
private Set _scripts;
-
+
private Set _styles;
-
+
private String _viewState;
-
+
private String _encoding;
private Serializer _serializer;
@@ -103,68 +105,86 @@
private String _namespace = "http://www.w3.org/1999/xhtml";
private String _outputEncoding;
+
/**
*
*/
public NekkoParser() {
- _parser=new HtmlSAXParser(getHtmlConfig());
-// Properties properties = OutputPropertiesFactory.getDefaultMethodProperties(Method.XHTML);
- Properties properties = OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
-// properties.put("encoding",_encoding);
+ }
+
+ /**
+ *
+ */
+ public void init() {
+ _parser = new HtmlSAXParser(getHtmlConfig());
+ Properties properties = OutputPropertiesFactory
+ .getDefaultMethodProperties(Method.XHTML);
+ // Properties properties =
+ // OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
+ // properties.put("encoding",_encoding);
_serializer = SerializerFactory.getSerializer(properties);
-// serializer.setOutputStream(output);
-// _parser.setContentHandler(serializer.asContentHandler());
+ // serializer.setOutputStream(output);
+ // _parser.setContentHandler(serializer.asContentHandler());
viewStateParser = new DOMFragmentParser();
// Set parser features
try {
- viewStateParser.setProperty(
- "http://cyberneko.org/html/properties/names/elems",
- "lower");
- viewStateParser.setProperty(
- "http://cyberneko.org/html/properties/names/attrs",
- "lower");
+ viewStateParser
+ .setProperty(
+ "http://cyberneko.org/html/properties/names/elems",
+ "lower");
+ viewStateParser
+ .setProperty(
+ "http://cyberneko.org/html/properties/names/attrs",
+ "lower");
} catch (SAXException e) {
_log.error("Exception in DOM parser configuration", e);
- }
+ }
try {
// Create Document Builder Factory
DocumentBuilderFactory docFactory = DocumentBuilderFactory
- .newInstance();
+ .newInstance();
// Create Document Builder
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
viewStateDocument = docBuilder.newDocument();
} catch (ParserConfigurationException e) {
viewStateDocument = new HTMLDocumentImpl();
- _log.error("Error on create DOM Document by JAXP, use Xerxes implementation. Check JAXP configuration ",e);
+ _log
+ .error(
+ "Error on create DOM Document by JAXP, use Xerxes implementation. Check JAXP configuration ",
+ e);
}
-// viewStateDocument = new HTMLDocumentImpl();
+ // viewStateDocument = new HTMLDocumentImpl();
remover.removeElement("style");
}
-
+
/**
* Reset parser state
*/
- public void reset(){
- _scripts=null;
- _styles=null;
- _viewState=null;
+ public void reset() {
+ _scripts = null;
+ _styles = null;
+ _viewState = null;
_parser.reset();
_serializer.reset();
}
- /* (non-Javadoc)
- * @see org.ajax4jsf.webapp.HtmlParser#parseHtml(java.io.InputStream, java.io.OutputStream)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.HtmlParser#parseHtml(java.io.InputStream,
+ * java.io.OutputStream)
*/
public void parseHtml(InputStream input, java.io.Writer output)
throws IOException {
InputSource src = new InputSource(input);
- parseSAXSource(src,output);
+ parseSAXSource(src, output);
}
- private void parseSAXSource(InputSource src, java.io.Writer output) throws IOException {
-// PrintWriter printWriter = null;
+ private void parseSAXSource(InputSource src, java.io.Writer output)
+ throws IOException {
+ // PrintWriter printWriter = null;
fragment = null;
- if(null != _viewState){
+ if (null != _viewState) {
fragment = viewStateDocument.createDocumentFragment();
try {
viewStateParser.parse(new InputSource(new StringReader(
@@ -175,46 +195,60 @@
// TODO - parse view state to DOM Fragment.
}
try {
- _parser.setProperty("http://cyberneko.org/html/properties/default-encoding",
- _encoding);
+ if (null != _encoding) {
+ _parser
+ .setProperty(
+ "http://cyberneko.org/html/properties/default-encoding",
+ _encoding);
+
+ }
Properties properties = _serializer.getOutputFormat();
- properties.put("encoding",_outputEncoding);
+ if (null != _outputEncoding) {
+ properties.put("encoding", _outputEncoding);
+
+ }
_serializer.setOutputFormat(properties);
_serializer.setWriter(output);
-// _serializer.setOutputStream(new OutputStream(){
-//
-// public void write(int b) throws IOException {
-// // TODO Auto-generated method stub
-//
-// }});
+ // _serializer.setOutputStream(new OutputStream(){
+ //
+ // public void write(int b) throws IOException {
+ // // TODO Auto-generated method stub
+ //
+ // }});
_parser.setContentHandler(_serializer.asContentHandler());
-// printWriter = new PrintWriter(output);
-// _writer.setWriter(printWriter);
-// _writer.setEncoding(_encoding);
+ // printWriter = new PrintWriter(output);
+ // _writer.setWriter(printWriter);
+ // _writer.setEncoding(_encoding);
_parser.parse(src);
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
-// _writer.setWriter(null);
-// if(null != printWriter){
-// printWriter.flush();
-// printWriter.close();
-// }
-
+ // _writer.setWriter(null);
+ // if(null != printWriter){
+ // printWriter.flush();
+ // printWriter.close();
+ // }
+
}
-
+
}
- /* (non-Javadoc)
- * @see org.ajax4jsf.webapp.HtmlParser#parseHtml(java.io.Reader, java.io.OutputStream)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.HtmlParser#parseHtml(java.io.Reader,
+ * java.io.OutputStream)
*/
- public void parseHtml(Reader input, java.io.Writer output) throws IOException {
+ public void parseHtml(Reader input, java.io.Writer output)
+ throws IOException {
InputSource src = new InputSource(input);
- parseSAXSource(src,output);
+ parseSAXSource(src, output);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.ajax4jsf.webapp.HtmlParser#setEncoding(java.lang.String)
*/
public void setInputEncoding(String encoding) {
@@ -224,7 +258,10 @@
public void setOutputEncoding(String encoding) {
_outputEncoding = encoding;
}
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.ajax4jsf.webapp.HtmlParser#setMoveElements(boolean)
*/
public void setMoveElements(boolean move) {
@@ -232,7 +269,9 @@
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.ajax4jsf.webapp.HtmlParser#setScripts(java.util.Set)
*/
public void setScripts(Set scripts) {
@@ -240,7 +279,9 @@
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.ajax4jsf.webapp.HtmlParser#setStyles(java.util.Set)
*/
public void setStyles(Set styles) {
@@ -248,7 +289,9 @@
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.ajax4jsf.webapp.HtmlParser#setDoctype(java.lang.String)
*/
public void setDoctype(String doctype) {
@@ -256,35 +299,41 @@
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.ajax4jsf.webapp.HtmlParser#setViewState(java.lang.String)
*/
public void setViewState(String viewState) {
_viewState = viewState;
}
-
- private static class HtmlSAXParser extends AbstractSAXParser {
- /** Default constructor.
- * @throws ServletException */
- public HtmlSAXParser(HTMLConfiguration config) {
- super(config);
-
- }
+
+ private static class HtmlSAXParser extends AbstractSAXParser {
+ /**
+ * Default constructor.
+ *
+ * @throws ServletException
+ */
+ public HtmlSAXParser(HTMLConfiguration config) {
+ super(config);
+
+ }
}
-
- private class ViewStateFilter extends DefaultFilter{
+
+ private class ViewStateFilter extends DefaultFilter {
private boolean haveHtml = false;
private boolean haveHead = false;
private boolean headParsed = false;
private int stateMarkerLevel = -1;
-
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.cyberneko.html.filters.DefaultFilter#reset(org.apache.xerces.xni.parser.XMLComponentManager)
*/
- public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
+ public void reset(XMLComponentManager componentManager)
+ throws XMLConfigurationException {
haveHead = false;
haveHtml = false;
headParsed = false;
@@ -292,27 +341,31 @@
super.reset(componentManager);
}
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#startElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.cyberneko.html.filters.DefaultFilter#startElement(org.apache.xerces.xni.QName,
+ * org.apache.xerces.xni.XMLAttributes,
+ * org.apache.xerces.xni.Augmentations)
*/
- public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
- if(stateMarkerLevel >=0){
+ public void startElement(QName element, XMLAttributes attributes,
+ Augmentations augs) throws XNIException {
+ if (stateMarkerLevel >= 0) {
stateMarkerLevel++;
- if(null != fragment){
+ if (null != fragment) {
return;
}
}
if (!headParsed) {
- if("html".equalsIgnoreCase(element.rawname)){
+ if ("html".equalsIgnoreCase(element.rawname)) {
haveHtml = true;
- } else if("head".equalsIgnoreCase(element.rawname)){
+ } else if ("head".equalsIgnoreCase(element.rawname)) {
haveHead = true;
super.startElement(element, attributes, augs);
insertResources();
return;
} else {
- if(!haveHtml){
+ if (!haveHtml) {
insertStartElement("html");
}
insertStartElement("head");
@@ -321,82 +374,97 @@
}
}
- if(isStateMarker(element, attributes)){
+ if (isStateMarker(element, attributes)) {
stateMarkerLevel = 0;
return;
- };
+ }
+ ;
super.startElement(element, attributes, augs);
}
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#characters(org.apache.xerces.xni.XMLString, org.apache.xerces.xni.Augmentations)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.cyberneko.html.filters.DefaultFilter#characters(org.apache.xerces.xni.XMLString,
+ * org.apache.xerces.xni.Augmentations)
*/
- public void characters(XMLString text, Augmentations augs) throws XNIException {
- if(stateMarkerLevel >=0){
- if(null != fragment){
+ public void characters(XMLString text, Augmentations augs)
+ throws XNIException {
+ if (stateMarkerLevel >= 0) {
+ if (null != fragment) {
return;
}
}
super.characters(text, augs);
}
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#endElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.Augmentations)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.cyberneko.html.filters.DefaultFilter#endElement(org.apache.xerces.xni.QName,
+ * org.apache.xerces.xni.Augmentations)
*/
- public void endElement(QName element, Augmentations augs) throws XNIException {
- if(stateMarkerLevel >=0){
+ public void endElement(QName element, Augmentations augs)
+ throws XNIException {
+ if (stateMarkerLevel >= 0) {
stateMarkerLevel--;
- if(null != fragment || stateMarkerLevel == -1){
+ if (null != fragment || stateMarkerLevel == -1) {
return;
}
}
super.endElement(element, augs);
}
-
private void insertResources() {
headParsed = true;
- if(null != _styles){
+ if (null != _styles) {
for (Iterator iter = _styles.iterator(); iter.hasNext();) {
String style = (String) iter.next();
- QName element = new QName(null,"link","link",null);
+ QName element = new QName(null, "link", "link", null);
XMLAttributes attrs = new XMLAttributesImpl();
- attrs.addAttribute(new QName(null,"href","href",null), "CDATA", style);
- attrs.addAttribute(new QName(null,"type","type",null), "CDATA", "text/css");
- attrs.addAttribute(new QName(null,"rel","rel",null), "CDATA", "stylesheet");
+ attrs.addAttribute(new QName(null, "href", "href", null),
+ "CDATA", style);
+ attrs.addAttribute(new QName(null, "type", "type", null),
+ "CDATA", "text/css");
+ attrs.addAttribute(new QName(null, "rel", "rel", null),
+ "CDATA", "stylesheet");
Augmentations augs = new HTMLAugmentations();
- super.emptyElement(element,attrs,augs);
+ super.emptyElement(element, attrs, augs);
}
}
- if(null != _scripts){
+ if (null != _scripts) {
for (Iterator iter = _scripts.iterator(); iter.hasNext();) {
String script = (String) iter.next();
- QName element = new QName(null,"script","script",null);
+ QName element = new QName(null, "script", "script", null);
XMLAttributes attrs = new XMLAttributesImpl();
- attrs.addAttribute(new QName(null,"src","src",null), "CDATA", script);
- attrs.addAttribute(new QName(null,"type","type",null), "CDATA", "text/javascript");
+ attrs.addAttribute(new QName(null, "src", "src", null),
+ "CDATA", script);
+ attrs.addAttribute(new QName(null, "type", "type", null),
+ "CDATA", "text/javascript");
Augmentations augs = new HTMLAugmentations();
- super.startElement(element,attrs,augs);
+ super.startElement(element, attrs, augs);
super.endElement(element, augs);
}
}
-
+
}
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#emptyElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.cyberneko.html.filters.DefaultFilter#emptyElement(org.apache.xerces.xni.QName,
+ * org.apache.xerces.xni.XMLAttributes,
+ * org.apache.xerces.xni.Augmentations)
*/
- public void emptyElement(QName name, XMLAttributes attributes, Augmentations augmentation) throws XNIException {
- if(stateMarkerLevel >=0){
- if(null != fragment){
+ public void emptyElement(QName name, XMLAttributes attributes,
+ Augmentations augmentation) throws XNIException {
+ if (stateMarkerLevel >= 0) {
+ if (null != fragment) {
return;
}
}
if (!headParsed) {
- if("head".equalsIgnoreCase(name.rawname)){
+ if ("head".equalsIgnoreCase(name.rawname)) {
haveHead = true;
super.startElement(name, attributes, augmentation);
insertResources();
@@ -404,21 +472,23 @@
return;
}
}
- if(isStateMarker(name, attributes)){
+ if (isStateMarker(name, attributes)) {
return;
- };
+ }
+ ;
super.emptyElement(name, attributes, augmentation);
}
-
/**
* @param name
* @param attributes
*/
private boolean isStateMarker(QName name, XMLAttributes attributes) {
- if(name.rawname.equalsIgnoreCase("span") && AjaxViewHandler.STATE_MARKER_KEY.equals(attributes.getValue("id"))){
+ if (name.rawname.equalsIgnoreCase("span")
+ && AjaxViewHandler.STATE_MARKER_KEY.equals(attributes
+ .getValue("id"))) {
// STATE marker element - out real content.
- if(null != fragment){
+ if (null != fragment) {
try {
_serializer.asDOMSerializer().serialize(fragment);
} catch (IOException e) {
@@ -429,38 +499,36 @@
}
return false;
}
-
- void insertStartElement(String name) {
- QName element = new QName(null,name,name,null);
- XMLAttributes attrs = new XMLAttributesImpl();
- Augmentations augs = new HTMLAugmentations();
- super.startElement(element,attrs,augs);
- }
-
-
- void insertEndElement(String name) {
- QName element = new QName(null,name,name,null);
-// XMLAttributes attrs = new XMLAttributesImpl();
- Augmentations augs = new HTMLAugmentations();
- super.endElement(element,augs);
- }
+ void insertStartElement(String name) {
+ QName element = new QName(null, name, name, null);
+ XMLAttributes attrs = new XMLAttributesImpl();
+ Augmentations augs = new HTMLAugmentations();
+ super.startElement(element, attrs, augs);
+ }
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#endDocument(org.apache.xerces.xni.Augmentations)
- */
- public void endDocument(Augmentations augs) throws XNIException {
- if (!haveHtml) {
- insertEndElement("html");
- }
- super.endDocument(augs);
+ void insertEndElement(String name) {
+ QName element = new QName(null, name, name, null);
+ // XMLAttributes attrs = new XMLAttributesImpl();
+ Augmentations augs = new HTMLAugmentations();
+ super.endElement(element, augs);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.cyberneko.html.filters.DefaultFilter#endDocument(org.apache.xerces.xni.Augmentations)
+ */
+ public void endDocument(Augmentations augs) throws XNIException {
+ if (!haveHtml) {
+ insertEndElement("html");
}
-
-
+ super.endDocument(augs);
+ }
}
- private static class HtmlWriter extends Writer {
+ private static class HtmlWriter extends Writer {
/**
*
@@ -469,25 +537,32 @@
super();
fEncoding = "UTF-8";
}
-
- public void setEncoding(String encoding){
+
+ public void setEncoding(String encoding) {
this.fEncoding = encoding;
}
-
- public void setWriter( PrintWriter writer){
+
+ public void setWriter(PrintWriter writer) {
this.fPrinter = writer;
}
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.Writer#emptyElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.cyberneko.html.filters.Writer#emptyElement(org.apache.xerces.xni.QName,
+ * org.apache.xerces.xni.XMLAttributes,
+ * org.apache.xerces.xni.Augmentations)
*/
- public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
+ public void emptyElement(QName element, XMLAttributes attributes,
+ Augmentations augs) throws XNIException {
// TODO Auto-generated method stub
super.emptyElement(element, attributes, augs);
printEndElement(element);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.cyberneko.html.filters.DefaultFilter#endCDATA(org.apache.xerces.xni.Augmentations)
*/
public void endCDATA(Augmentations augs) throws XNIException {
@@ -495,7 +570,9 @@
super.endCDATA(augs);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.cyberneko.html.filters.DefaultFilter#startCDATA(org.apache.xerces.xni.Augmentations)
*/
public void startCDATA(Augmentations augs) throws XNIException {
@@ -503,147 +580,163 @@
super.startCDATA(augs);
}
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#textDecl(java.lang.String, java.lang.String, org.apache.xerces.xni.Augmentations)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.cyberneko.html.filters.DefaultFilter#textDecl(java.lang.String,
+ * java.lang.String, org.apache.xerces.xni.Augmentations)
*/
- public void textDecl(String version, String encoding, Augmentations augs) throws XNIException {
+ public void textDecl(String version, String encoding, Augmentations augs)
+ throws XNIException {
// TODO Auto-generated method stub
super.textDecl(version, encoding, augs);
}
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#xmlDecl(java.lang.String, java.lang.String, java.lang.String, org.apache.xerces.xni.Augmentations)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.cyberneko.html.filters.DefaultFilter#xmlDecl(java.lang.String,
+ * java.lang.String, java.lang.String,
+ * org.apache.xerces.xni.Augmentations)
*/
- public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException {
+ public void xmlDecl(String version, String encoding, String standalone,
+ Augmentations augs) throws XNIException {
// TODO Auto-generated method stub
super.xmlDecl(version, encoding, standalone, augs);
}
-
-
+
}
+
/**
- * Factory method for create and configure HTML parser configuration.
- * Create configuration for use in parsing, set nessesary features and properties
- * @return
- * @throws ServletException
- */
- protected HTMLConfiguration getHtmlConfig() {
- HTMLConfiguration _config = new HTMLConfiguration();
- try {
- if (this.getPublicid() != null || this.getSystemid() != null) {
- _config.setFeature(
- "http://cyberneko.org/html/features/insert-doctype",
+ * Factory method for create and configure HTML parser configuration. Create
+ * configuration for use in parsing, set nessesary features and properties
+ *
+ * @return
+ * @throws ServletException
+ */
+ protected HTMLConfiguration getHtmlConfig() {
+ HTMLConfiguration _config = new HTMLConfiguration();
+ try {
+ if (this.getPublicid() != null || this.getSystemid() != null) {
+ _config.setFeature(
+ "http://cyberneko.org/html/features/insert-doctype",
+ true);
+ _config.setFeature(
+ "http://cyberneko.org/html/features/override-doctype",
+ true);
+ }
+ if (this.getPublicid() != null) {
+ _config.setProperty(
+ "http://cyberneko.org/html/properties/doctype/pubid",
+ getPublicid());
+
+ }
+ if (this.getSystemid() != null) {
+ _config.setProperty(
+ "http://cyberneko.org/html/properties/doctype/sysid",
+ getSystemid());
+
+ }
+ if (this.getNamespace() != null) {
+ _config.setFeature("http://xml.org/sax/features/namespaces",
+ true);
+ _config
+ .setFeature(
+ "http://cyberneko.org/html/features/override-namespaces",
+ true);
+ _config.setFeature(
+ "http://cyberneko.org/html/features/insert-namespaces",
+ true);
+ _config.setProperty(
+ "http://cyberneko.org/html/properties/namespaces-uri",
+ getNamespace());
+
+ }
+ // config
+ // .setFeature(
+ // "http://cyberneko.org/html/features/balance-tags/ignore-outside-content",
+ // true);
+ _config
+ .setFeature(
+ "http://cyberneko.org/html/features/scanner/cdata-sections",
true);
- _config.setFeature(
- "http://cyberneko.org/html/features/override-doctype",
+ _config
+ .setFeature(
+ "http://cyberneko.org/html/features/scanner/script/strip-comment-delims",
true);
- }
- if (this.getPublicid() != null) {
- _config.setProperty(
- "http://cyberneko.org/html/properties/doctype/pubid",
- getPublicid());
-
- }
- if (this.getSystemid() != null) {
- _config.setProperty(
- "http://cyberneko.org/html/properties/doctype/sysid",
- getSystemid());
-
- }
- if (this.getNamespace() != null) {
- _config.setFeature(
- "http://xml.org/sax/features/namespaces",
+ _config
+ .setFeature(
+ "http://cyberneko.org/html/features/scanner/style/strip-comment-delims",
true);
- _config.setFeature(
- "http://cyberneko.org/html/features/override-namespaces",
- true);
- _config.setFeature(
- "http://cyberneko.org/html/features/insert-namespaces",
- true);
- _config.setProperty(
- "http://cyberneko.org/html/properties/namespaces-uri",
- getNamespace());
-
- }
- // config
- // .setFeature(
- // "http://cyberneko.org/html/features/balance-tags/ignore-outside-content",
- // true);
- _config
- .setFeature(
- "http://cyberneko.org/html/features/scanner/cdata-sections",
- true);
- _config
- .setFeature(
- "http://cyberneko.org/html/features/scanner/script/strip-comment-delims",
- true);
- _config
- .setFeature(
- "http://cyberneko.org/html/features/scanner/style/strip-comment-delims",
- true);
- _config.setFeature(
- "http://cyberneko.org/html/features/insert-doctype",
- true);
- _config.setFeature(
- "http://cyberneko.org/html/features/insert-namespaces",
- true);
- //
- // Set properties http://cyberneko.org/html/features/insert-namespaces
- // _config
- // .setProperty(
- // "http://cyberneko.org/html/properties/default-encoding",
- // encoding);
- _config.setProperty(
+ _config.setFeature(
+ "http://cyberneko.org/html/features/insert-doctype", true);
+ _config.setFeature(
+ "http://cyberneko.org/html/features/insert-namespaces",
+ true);
+ //
+ // Set properties
+ // http://cyberneko.org/html/features/insert-namespaces
+ // _config
+ // .setProperty(
+ // "http://cyberneko.org/html/properties/default-encoding",
+ // encoding);
+ _config
+ .setProperty(
"http://cyberneko.org/html/properties/names/elems",
"lower");
- _config.setProperty(
+ _config
+ .setProperty(
"http://cyberneko.org/html/properties/names/attrs",
"lower");
- _config.setProperty("http://cyberneko.org/html/properties/filters", _filters);
- } catch (XMLConfigurationException e) {
-// throw new ServletException("error set Neko feature ", e);
- }
- return _config;
- }
-
- private String getNamespace() {
- // TODO Auto-generated method stub
- return this._namespace;
+ _config.setProperty("http://cyberneko.org/html/properties/filters",
+ _filters);
+ } catch (XMLConfigurationException e) {
+ // throw new ServletException("error set Neko feature ", e);
}
+ return _config;
+ }
- private String getSystemid() {
- // TODO Auto-generated method stub
- return this._systemid;
- }
+ private String getNamespace() {
+ // TODO Auto-generated method stub
+ return this._namespace;
+ }
- private String getPublicid() {
- // TODO Auto-generated method stub
- return this._publicId;
- }
+ private String getSystemid() {
+ // TODO Auto-generated method stub
+ return this._systemid;
+ }
- /**
- * @param namespace The namespace to set.
- */
- public void setNamespace(String namespace) {
- _namespace = namespace;
- }
+ private String getPublicid() {
+ // TODO Auto-generated method stub
+ return this._publicId;
+ }
- /**
- * @param publicId The publicId to set.
- */
- public void setPublicId(String publicId) {
- _publicId = publicId;
- }
+ /**
+ * @param namespace
+ * The namespace to set.
+ */
+ public void setNamespace(String namespace) {
+ _namespace = namespace;
+ }
- /**
- * @param systemid The systemid to set.
- */
- public void setSystemid(String systemid) {
- _systemid = systemid;
- }
+ /**
+ * @param publicId
+ * The publicId to set.
+ */
+ public void setPublicId(String publicId) {
+ _publicId = publicId;
+ }
- public boolean setMime(String mimeType) {
- return false;
- }
+ /**
+ * @param systemid
+ * The systemid to set.
+ */
+ public void setSystemid(String systemid) {
+ _systemid = systemid;
+ }
+ public boolean setMime(String mimeType) {
+ return false;
+ }
+
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -88,6 +88,7 @@
parser.setNamespace(getNamespace());
// If tidy not handle all requests, disable reorganising of html
// parser.setMoveElements(isForcexml());
+ parser.init();
}
// TODO - set header scripts/styles filter.
return parser;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXHTMLStream.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXHTMLStream.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXHTMLStream.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -77,7 +77,8 @@
*/
private static final CharInfo m_htmlcharInfo =
// new CharInfo(CharInfo.HTML_ENTITIES_RESOURCE);
- CharInfo.getCharInfo(CharInfo.HTML_ENTITIES_RESOURCE, Method.HTML);
+ // Asmirnov - disable HTML Entities.
+ CharInfo.getCharInfo(CharInfo.XML_ENTITIES_RESOURCE, Method.XHTML);
/** A digital search trie for fast, case insensitive lookup of ElemDesc objects. */
static final Trie m_elementFlags = new Trie();
@@ -538,6 +539,8 @@
*/
static private final ElemDesc m_dummy = new ElemDesc(0 | ElemDesc.BLOCK);
+ public static final String XHTML_NAMESPACE_URI = "http://www.w3.org/1999/xhtml";
+
/** True if URLs should be specially escaped with the %xx form. */
private boolean m_specialEscapeURLs = true;
@@ -838,7 +841,7 @@
// if this element has a namespace then treat it like XML
- if (null != namespaceURI && namespaceURI.length() > 0)
+ if (null != namespaceURI && namespaceURI.length() > 0 && (!XHTML_NAMESPACE_URI.equals(namespaceURI)))
{
super.startElement(namespaceURI, localName, name, atts);
@@ -952,7 +955,7 @@
closeCDATA();
// if the element has a namespace, treat it like XML, not HTML
- if (null != namespaceURI && namespaceURI.length() > 0)
+ if (null != namespaceURI && namespaceURI.length() > 0 && (!XHTML_NAMESPACE_URI.equals(namespaceURI)))
{
super.endElement(namespaceURI, localName, name);
Copied: trunk/framework/impl/src/main/java/org/richfaces/skin (from rev 1585, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/skin)
Modified: trunk/framework/impl/src/main/java/org/richfaces/skin/DummySkinConfiguration.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/skin/DummySkinConfiguration.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/impl/src/main/java/org/richfaces/skin/DummySkinConfiguration.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.skin;
+package org.richfaces.skin;
import javax.faces.context.FacesContext;
Modified: trunk/framework/impl/src/main/java/org/richfaces/skin/SkinBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinBean.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/impl/src/main/java/org/richfaces/skin/SkinBean.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.skin;
+package org.richfaces.skin;
import java.nio.ByteBuffer;
import java.util.AbstractMap;
Modified: trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinFactoryImpl.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.skin;
+package org.richfaces.skin;
import java.io.IOException;
import java.io.InputStream;
Modified: trunk/framework/impl/src/main/java/org/richfaces/skin/SkinImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinImpl.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/impl/src/main/java/org/richfaces/skin/SkinImpl.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.skin;
+package org.richfaces.skin;
import java.util.HashMap;
import java.util.Iterator;
Modified: trunk/framework/impl/src/main/java/org/richfaces/skin/SkinPropertyResolver.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinPropertyResolver.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/impl/src/main/java/org/richfaces/skin/SkinPropertyResolver.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.skin;
+package org.richfaces.skin;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
Modified: trunk/framework/impl/src/main/java/org/richfaces/skin/SkinVariableResolver.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinVariableResolver.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/impl/src/main/java/org/richfaces/skin/SkinVariableResolver.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.skin;
+package org.richfaces.skin;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
Modified: trunk/framework/impl/src/main/java/org/richfaces/skin/VersionBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/skin/VersionBean.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/impl/src/main/java/org/richfaces/skin/VersionBean.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.skin;
+package org.richfaces.skin;
/**
* Vendor and version information for A4J project
Modified: trunk/framework/impl/src/main/resources/org/ajax4jsf/xml/serializer/output_xhtml.properties
===================================================================
--- trunk/framework/impl/src/main/resources/org/ajax4jsf/xml/serializer/output_xhtml.properties 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/impl/src/main/resources/org/ajax4jsf/xml/serializer/output_xhtml.properties 2007-07-10 18:37:56 UTC (rev 1586)
@@ -22,7 +22,8 @@
# XSLT properties do not need namespace qualification.
method=xhtml
-indent=yes
+indent=no
+omit-xml-declaration=yes
media-type=application/xml+xhtml
version=1.0
@@ -37,6 +38,8 @@
# Note that the colon after the protocol needs to be escaped.
{http\u003a//xml.apache.org/xalan}indent-amount=0
{http\u003a//xml.apache.org/xalan}content-handler=org.ajax4jsf.xml.serializer.ToXHTMLStream
-{http\u003a//xml.apache.org/xalan}entities=org/ajax4jsf/xml/serializer/HTMLEntities
+# XMLHttpRequest can't resolve HTTP entities.
+# {http\u003a//xml.apache.org/xalan}entities=org/ajax4jsf/xml/serializer/HTMLEntities
+{http\u003a//xml.apache.org/xalan}entities=org/ajax4jsf/xml/serializer/XMLEntities
{http\u003a//xml.apache.org/xalan}use-url-escaping=yes
{http\u003a//xml.apache.org/xalan}omit-meta-tag=yes
Modified: trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -46,8 +46,6 @@
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.context.AjaxContextImpl;
-import org.ajax4jsf.framework.skin.SkinBean;
-import org.ajax4jsf.framework.skin.VersionBean;
import org.ajax4jsf.framework.util.config.WebXml;
import org.ajax4jsf.renderkit.AjaxViewRootRenderer;
import org.ajax4jsf.renderkit.ChameleonRenderKitImpl;
@@ -58,7 +56,9 @@
import org.apache.shale.test.mock.MockPrintWriter;
import org.apache.shale.test.mock.MockResponseWriter;
import org.apache.shale.test.mock.MockServletOutputStream;
+import org.richfaces.skin.SkinBean;
import org.richfaces.skin.SkinFactory;
+import org.richfaces.skin.VersionBean;
import com.gargoylesoftware.htmlunit.MockWebConnection;
import com.gargoylesoftware.htmlunit.Page;
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/SkinTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/SkinTestCase.java 2007-07-10 16:14:12 UTC (rev 1585)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/framework/skin/SkinTestCase.java 2007-07-10 18:37:56 UTC (rev 1586)
@@ -38,6 +38,8 @@
import org.easymock.classextension.MockClassControl;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
+import org.richfaces.skin.SkinFactoryImpl;
+import org.richfaces.skin.SkinImpl;
/**
* Test for Skin/skin factory methods.
18 years, 2 months