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&quo...
-
- * 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&quo...
+
+ * 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;