incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r425268 [5/7] - in /incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src: main/java-templates/org/apache/myfaces/adf/component/ main/java/org/apache/myfaces/adf/change/ main/java/org/apache/myfaces/adf/component...
Date Tue, 25 Jul 2006 03:54:52 GMT
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/AggregatingResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/AggregatingResourceLoader.java?rev=425268&r1=425267&r2=425268&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/AggregatingResourceLoader.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/AggregatingResourceLoader.java Mon Jul 24 20:54:50 2006
@@ -1,421 +1,421 @@
-/*
- * Copyright  2004-2006 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.apache.myfaces.adf.resource;
-import java.io.InputStream;
-import java.io.SequenceInputStream;
-import java.net.URL;
-
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
-import java.util.ArrayList;
-
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-import org.apache.myfaces.adf.logging.ADFLogger;
-
-/**
- * A resource loader implementation which combines multiple resources
- * into a single stream.  This version leverages the DynamicResourceLoader.
- *
- * @author The Oracle ADF Faces Team
- */
-public class AggregatingResourceLoader extends DynamicResourceLoader
-{
-  /**
-   * Creates a new AggregatingResourceLoader.
-   *
-   * @param path    the aggregated resource path
-   * @param paths   the target resource paths to aggregate
-   * @param target  the resource loader use to find target resource paths
-   * @param parent  the parent resource loader
-   */
-  public AggregatingResourceLoader(
-    String         path,
-    String[]       paths,
-    ResourceLoader target,
-    ResourceLoader parent)
-  {
-    super(path, parent);
-    if (paths == null)
-      throw new NullPointerException();
-
-    if (target == null)
-      throw new NullPointerException();
-
-    _paths = paths;
-    _target = target;
-  }
-
-  /**
-   * Creates a new AggregatingResourceLoader.
-   *
-   * @param path    the aggregated resource path
-   * @param paths   the target resource paths to aggregate
-   * @param target  the resource loader use to find target resource paths
-   */
-  public AggregatingResourceLoader(
-    String         path,
-    String[]       paths,
-    ResourceLoader target)
-  {
-    this(path, paths, target, null);
-  }
-
-  /**
-   * Sets the separator to use in between streams.  This will typically contain a newline character.
-   * By default the value is <code>null</code> which implies no separator.
-   *
-   * @param separator a string containing the separator characters
-   */
-  public void setSeparator(String separator)
-  {
-    _separator = separator;
-  }
-
-  /**
-   * Returns a URL which is an aggregate of all the paths.
-   *
-   * @param path the current path
-   * @return a aggregate url
-   * @throws IOException when something bad happens
-   */
-  protected URL getURL(String path) throws IOException
-  {
-    int len = _paths.length;
-    ArrayList urls = new ArrayList(len);
-    for(int i = 0; i < len; i++)
-    {
-      URL u = _target.getResource(_paths[i]);
-      if(u != null)
-      {
-        urls.add(u);
-      }
-      else
-      {
-        _LOG.warning("Resource \"" + _paths[i] +
-                     "\" at path \"" + path + "\" not found");
-      }
-    }
-
-    urls.trimToSize();
-    URL[] urlArray = (URL[])urls.toArray(new URL[0]);
-
-    AggregatingURLStreamHandler handler = new AggregatingURLStreamHandler(urlArray, _separator);
-    return new URL("aggregating", null, -1, path, handler);
-  }
-
-  private String[] _paths;
-  private ResourceLoader _target;
-  private String _separator;
-  static private final ADFLogger _LOG = 	ADFLogger.createADFLogger(AggregatingResourceLoader.class);
-
-  /**
-   * This is a Stream Handler which can be used to construct a URL that is an Aggregate of a list of
-   * other urls.
-   *
-   */
-  public class AggregatingURLStreamHandler extends URLStreamHandler
-  {
-    /**
-     * Constructs and AggregatingURLStreamHandler from an array of URLs containing other data.
-     * This constructor assumes a null separator.
-     *
-     * @param urls the urls
-     */
-    public AggregatingURLStreamHandler(URL[] urls)
-    {
-      this(urls, null);
-    }
-
-    /**
-     * Constructs and AggregatingURLStreamHandler from an array of URLs containing other data.
-     *
-     * @param urls the urls
-     * @param separator a String containing a separator.  This will typically be an newline character
-     *                  or null.
-     */
-    public AggregatingURLStreamHandler(URL[] urls, String separator)
-    {
-      if(urls == null)
-      {
-        throw new NullPointerException();
-      }
-      _urls = urls;
-      _separator = separator;
-    }
-
-    /**
-     * Opens a connection containing all of the data from the provided urls.  The seperator character,
-     * if one is provided, will seperate the content of each seperate stream.
-     *
-     * @param u the parent URL object
-     * @return a URLConnection
-     * @throws IOException when something bad happens
-     */
-    protected URLConnection openConnection(URL u) throws IOException
-    {
-      int len = _urls.length;
-      URLConnection[] conn = new URLConnection[len];
-      for(int i = 0; i < len; i++)
-      {
-        conn[i] = _urls[i].openConnection();
-      }
-
-      return new AggregatingURLConnection(u, conn, _separator);
-    }
-
-    private URL[] _urls;
-    private String _separator;
-
-  }
-
-  private class AggregatingURLConnection extends URLConnection
-  {
-    public AggregatingURLConnection(URL url, URLConnection[] connections, String separator)
-    {
-      super(url);
-      _connections = connections;
-
-      if(separator != null)
-      {
-        _separator = separator.getBytes();
-      }
-    }
-
-    public void connect() throws IOException
-    {
-      for (int i=0, len = _connections.length; i < len; i++)
-      {
-        _connections[i].connect();
-      }
-    }
-
-    public InputStream getInputStream() throws IOException
-    {
-      boolean hasseparator = (_separator!=null);
-      InputStream[] streams;
-      if(hasseparator)
-      {
-        streams = new InputStream[(_connections.length *2)-1];
-      }
-      else
-      {
-        streams = new InputStream[_connections.length];
-      }
-
-      for (int i=0, len=_connections.length, sublen = len -1, streamCounter = 0; i < len; i++, streamCounter++)
-      {
-        streams[streamCounter] = _connections[i].getInputStream();
-
-        //Add the separator if needed
-        if(hasseparator && (i < sublen))
-        {
-          streams[++streamCounter] = new separatorInputStream(_separator);
-        }
-      }
-      return new SequenceInputStream(new ArrayEnumeration(streams));
-    }
-
-    public String getContentType()
-    {
-      return _connections[0].getContentType();
-    }
-
-    public int getContentLength()
-    {
-      int totalContentLength = _contentLength;
-
-      // Calculate the total content length
-      // If any piece is unknown in length, then the total is unknown also
-      if (totalContentLength == Integer.MIN_VALUE)
-      {
-        totalContentLength = 0;
-
-        URLConnection[] connects = _connections;
-
-        // Ensure that separator calculation happens first
-        // to avoid adding extra length in the case when
-        // the total content length is unknown.
-        if (_separator != null)
-        {
-          totalContentLength += ((connects.length - 1)*_separator.length);
-        }
-
-        for (int i=0, len = _connections.length; i < len; i++)
-        {
-          int contentLength = _connections[i].getContentLength();
-          if (contentLength < 0)
-          {
-            // Unknown content length for one part implies
-            // unknown content length for aggregated whole
-            totalContentLength = -1;
-            break;
-          }
-          totalContentLength += contentLength;
-        }
-
-        _contentLength = totalContentLength;
-      }
-
-      return totalContentLength;
-    }
-
-    public long getLastModified()
-    {
-      long maxLastModified = -1;
-
-      for (int i=0, len = _connections.length; i < len; i++)
-      {
-        long lastModified = _connections[i].getLastModified();
-        if (lastModified < 0)
-        {
-          maxLastModified = lastModified;
-          break;
-        }
-        maxLastModified = Math.max(maxLastModified, lastModified);
-      }
-
-      return maxLastModified;
-    }
-
-    public String getHeaderField(
-      String name)
-    {
-      if ("content-length".equals(name))
-      {
-        return String.valueOf(getContentLength());
-      }
-      else if ("content-type".equals(name))
-      {
-        return getContentType();
-      }
-      else if ("last-modified".equals(name))
-      {
-        return String.valueOf(getLastModified());
-      }
-      else
-      {
-        return super.getHeaderField(name);
-      }
-    }
-
-    private int _contentLength = Integer.MIN_VALUE;
-    private URLConnection[] _connections;
-    private byte[] _separator;
-
-  }
-
-  private class ArrayEnumeration implements Enumeration
-  {
-    private Object[] _array;
-    private int      _len;
-    private int      _pointer = 0;
-    public ArrayEnumeration(Object[] array)
-    {
-      _array = array;
-      _len = array.length;
-    }
-
-    public boolean hasNext()
-    {
-      return _pointer < _len;
-    }
-
-    public Object nextElement() throws NoSuchElementException
-    {
-      try
-      {
-        return _array[_pointer++];
-      }
-      catch (IndexOutOfBoundsException e)
-      {
-        throw new NoSuchElementException();
-      }
-    }
-
-    public boolean hasMoreElements()
-    {
-      return hasNext();
-    }
-  }
-
-  private class separatorInputStream extends InputStream
-  {
-    private byte[] _separator;
-    private int    _length;
-    private int    _index = 0;
-    public separatorInputStream (byte[] separatorBytes)
-    {
-      _separator = separatorBytes;
-      _length = _separator.length;
-    }
-
-    public int read() throws IOException
-    {
-      if(_index < _length)
-      {
-        return _separator[_index++];
-      }
-
-      return -1;
-    }
-
-    public int read(byte[] b, int off, int len) throws IOException
-    {
-      int bytesLeft = available();
-
-      if(len <= bytesLeft)
-      {
-        System.arraycopy(_separator,_index,b,off,len);
-        _index += len;
-        return len;
-      }
-      else
-      {
-        System.arraycopy(_separator, _index, b,off, bytesLeft);
-        _index += bytesLeft;
-        return bytesLeft;
-      }
-    }
-
-    public long skip(long n) throws IOException
-    {
-      int bytesLeft = available();
-
-      if(n < 0)
-      {
-        return 0;
-      }
-      else if(n < bytesLeft || n == bytesLeft)
-      {
-        _index += n;
-        return n;
-      }
-      else
-      {
-        _index += bytesLeft;
-        return bytesLeft;
-      }
-    }
-
-    public int available() throws IOException
-    {
-      return _length - _index;
-    }
-  }
+/*
+ * Copyright  2004-2006 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.apache.myfaces.adf.resource;
+import java.io.InputStream;
+import java.io.SequenceInputStream;
+import java.net.URL;
+
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.util.ArrayList;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+import org.apache.myfaces.adf.logging.ADFLogger;
+
+/**
+ * A resource loader implementation which combines multiple resources
+ * into a single stream.  This version leverages the DynamicResourceLoader.
+ *
+ * @author The Oracle ADF Faces Team
+ */
+public class AggregatingResourceLoader extends DynamicResourceLoader
+{
+  /**
+   * Creates a new AggregatingResourceLoader.
+   *
+   * @param path    the aggregated resource path
+   * @param paths   the target resource paths to aggregate
+   * @param target  the resource loader use to find target resource paths
+   * @param parent  the parent resource loader
+   */
+  public AggregatingResourceLoader(
+    String         path,
+    String[]       paths,
+    ResourceLoader target,
+    ResourceLoader parent)
+  {
+    super(path, parent);
+    if (paths == null)
+      throw new NullPointerException();
+
+    if (target == null)
+      throw new NullPointerException();
+
+    _paths = paths;
+    _target = target;
+  }
+
+  /**
+   * Creates a new AggregatingResourceLoader.
+   *
+   * @param path    the aggregated resource path
+   * @param paths   the target resource paths to aggregate
+   * @param target  the resource loader use to find target resource paths
+   */
+  public AggregatingResourceLoader(
+    String         path,
+    String[]       paths,
+    ResourceLoader target)
+  {
+    this(path, paths, target, null);
+  }
+
+  /**
+   * Sets the separator to use in between streams.  This will typically contain a newline character.
+   * By default the value is <code>null</code> which implies no separator.
+   *
+   * @param separator a string containing the separator characters
+   */
+  public void setSeparator(String separator)
+  {
+    _separator = separator;
+  }
+
+  /**
+   * Returns a URL which is an aggregate of all the paths.
+   *
+   * @param path the current path
+   * @return a aggregate url
+   * @throws IOException when something bad happens
+   */
+  protected URL getURL(String path) throws IOException
+  {
+    int len = _paths.length;
+    ArrayList urls = new ArrayList(len);
+    for(int i = 0; i < len; i++)
+    {
+      URL u = _target.getResource(_paths[i]);
+      if(u != null)
+      {
+        urls.add(u);
+      }
+      else
+      {
+        _LOG.warning("Resource \"" + _paths[i] +
+                     "\" at path \"" + path + "\" not found");
+      }
+    }
+
+    urls.trimToSize();
+    URL[] urlArray = (URL[])urls.toArray(new URL[0]);
+
+    AggregatingURLStreamHandler handler = new AggregatingURLStreamHandler(urlArray, _separator);
+    return new URL("aggregating", null, -1, path, handler);
+  }
+
+  private String[] _paths;
+  private ResourceLoader _target;
+  private String _separator;
+  static private final ADFLogger _LOG = 	ADFLogger.createADFLogger(AggregatingResourceLoader.class);
+
+  /**
+   * This is a Stream Handler which can be used to construct a URL that is an Aggregate of a list of
+   * other urls.
+   *
+   */
+  public class AggregatingURLStreamHandler extends URLStreamHandler
+  {
+    /**
+     * Constructs and AggregatingURLStreamHandler from an array of URLs containing other data.
+     * This constructor assumes a null separator.
+     *
+     * @param urls the urls
+     */
+    public AggregatingURLStreamHandler(URL[] urls)
+    {
+      this(urls, null);
+    }
+
+    /**
+     * Constructs and AggregatingURLStreamHandler from an array of URLs containing other data.
+     *
+     * @param urls the urls
+     * @param separator a String containing a separator.  This will typically be an newline character
+     *                  or null.
+     */
+    public AggregatingURLStreamHandler(URL[] urls, String separator)
+    {
+      if(urls == null)
+      {
+        throw new NullPointerException();
+      }
+      _urls = urls;
+      _separator = separator;
+    }
+
+    /**
+     * Opens a connection containing all of the data from the provided urls.  The seperator character,
+     * if one is provided, will seperate the content of each seperate stream.
+     *
+     * @param u the parent URL object
+     * @return a URLConnection
+     * @throws IOException when something bad happens
+     */
+    protected URLConnection openConnection(URL u) throws IOException
+    {
+      int len = _urls.length;
+      URLConnection[] conn = new URLConnection[len];
+      for(int i = 0; i < len; i++)
+      {
+        conn[i] = _urls[i].openConnection();
+      }
+
+      return new AggregatingURLConnection(u, conn, _separator);
+    }
+
+    private URL[] _urls;
+    private String _separator;
+
+  }
+
+  private class AggregatingURLConnection extends URLConnection
+  {
+    public AggregatingURLConnection(URL url, URLConnection[] connections, String separator)
+    {
+      super(url);
+      _connections = connections;
+
+      if(separator != null)
+      {
+        _separator = separator.getBytes();
+      }
+    }
+
+    public void connect() throws IOException
+    {
+      for (int i=0, len = _connections.length; i < len; i++)
+      {
+        _connections[i].connect();
+      }
+    }
+
+    public InputStream getInputStream() throws IOException
+    {
+      boolean hasseparator = (_separator!=null);
+      InputStream[] streams;
+      if(hasseparator)
+      {
+        streams = new InputStream[(_connections.length *2)-1];
+      }
+      else
+      {
+        streams = new InputStream[_connections.length];
+      }
+
+      for (int i=0, len=_connections.length, sublen = len -1, streamCounter = 0; i < len; i++, streamCounter++)
+      {
+        streams[streamCounter] = _connections[i].getInputStream();
+
+        //Add the separator if needed
+        if(hasseparator && (i < sublen))
+        {
+          streams[++streamCounter] = new separatorInputStream(_separator);
+        }
+      }
+      return new SequenceInputStream(new ArrayEnumeration(streams));
+    }
+
+    public String getContentType()
+    {
+      return _connections[0].getContentType();
+    }
+
+    public int getContentLength()
+    {
+      int totalContentLength = _contentLength;
+
+      // Calculate the total content length
+      // If any piece is unknown in length, then the total is unknown also
+      if (totalContentLength == Integer.MIN_VALUE)
+      {
+        totalContentLength = 0;
+
+        URLConnection[] connects = _connections;
+
+        // Ensure that separator calculation happens first
+        // to avoid adding extra length in the case when
+        // the total content length is unknown.
+        if (_separator != null)
+        {
+          totalContentLength += ((connects.length - 1)*_separator.length);
+        }
+
+        for (int i=0, len = _connections.length; i < len; i++)
+        {
+          int contentLength = _connections[i].getContentLength();
+          if (contentLength < 0)
+          {
+            // Unknown content length for one part implies
+            // unknown content length for aggregated whole
+            totalContentLength = -1;
+            break;
+          }
+          totalContentLength += contentLength;
+        }
+
+        _contentLength = totalContentLength;
+      }
+
+      return totalContentLength;
+    }
+
+    public long getLastModified()
+    {
+      long maxLastModified = -1;
+
+      for (int i=0, len = _connections.length; i < len; i++)
+      {
+        long lastModified = _connections[i].getLastModified();
+        if (lastModified < 0)
+        {
+          maxLastModified = lastModified;
+          break;
+        }
+        maxLastModified = Math.max(maxLastModified, lastModified);
+      }
+
+      return maxLastModified;
+    }
+
+    public String getHeaderField(
+      String name)
+    {
+      if ("content-length".equals(name))
+      {
+        return String.valueOf(getContentLength());
+      }
+      else if ("content-type".equals(name))
+      {
+        return getContentType();
+      }
+      else if ("last-modified".equals(name))
+      {
+        return String.valueOf(getLastModified());
+      }
+      else
+      {
+        return super.getHeaderField(name);
+      }
+    }
+
+    private int _contentLength = Integer.MIN_VALUE;
+    private URLConnection[] _connections;
+    private byte[] _separator;
+
+  }
+
+  private class ArrayEnumeration implements Enumeration
+  {
+    private Object[] _array;
+    private int      _len;
+    private int      _pointer = 0;
+    public ArrayEnumeration(Object[] array)
+    {
+      _array = array;
+      _len = array.length;
+    }
+
+    public boolean hasNext()
+    {
+      return _pointer < _len;
+    }
+
+    public Object nextElement() throws NoSuchElementException
+    {
+      try
+      {
+        return _array[_pointer++];
+      }
+      catch (IndexOutOfBoundsException e)
+      {
+        throw new NoSuchElementException();
+      }
+    }
+
+    public boolean hasMoreElements()
+    {
+      return hasNext();
+    }
+  }
+
+  private class separatorInputStream extends InputStream
+  {
+    private byte[] _separator;
+    private int    _length;
+    private int    _index = 0;
+    public separatorInputStream (byte[] separatorBytes)
+    {
+      _separator = separatorBytes;
+      _length = _separator.length;
+    }
+
+    public int read() throws IOException
+    {
+      if(_index < _length)
+      {
+        return _separator[_index++];
+      }
+
+      return -1;
+    }
+
+    public int read(byte[] b, int off, int len) throws IOException
+    {
+      int bytesLeft = available();
+
+      if(len <= bytesLeft)
+      {
+        System.arraycopy(_separator,_index,b,off,len);
+        _index += len;
+        return len;
+      }
+      else
+      {
+        System.arraycopy(_separator, _index, b,off, bytesLeft);
+        _index += bytesLeft;
+        return bytesLeft;
+      }
+    }
+
+    public long skip(long n) throws IOException
+    {
+      int bytesLeft = available();
+
+      if(n < 0)
+      {
+        return 0;
+      }
+      else if(n < bytesLeft || n == bytesLeft)
+      {
+        _index += n;
+        return n;
+      }
+      else
+      {
+        _index += bytesLeft;
+        return bytesLeft;
+      }
+    }
+
+    public int available() throws IOException
+    {
+      return _length - _index;
+    }
+  }
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/AggregatingResourceLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/ClassLoaderResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/ClassLoaderResourceLoader.java?rev=425268&r1=425267&r2=425268&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/ClassLoaderResourceLoader.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/ClassLoaderResourceLoader.java Mon Jul 24 20:54:50 2006
@@ -1,131 +1,131 @@
-/*
- * Copyright  2004-2006 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.apache.myfaces.adf.resource;
-
-import java.io.IOException;
-
-import java.net.URL;
-
-
-/**
- * A resource loader implementation which loads resources
- * using the context class loader.
- *
- * @author The Oracle ADF Faces Team
- */
-public class ClassLoaderResourceLoader extends ResourceLoader
-{
-  /**
-   * Constructs a new root ClassLoaderResourceLoader.
-   */
-  public ClassLoaderResourceLoader()
-  {
-    this((String)null);
-  }
-
-  /**
-   * Constructs a new ClassLoaderResourceLoader with specified parent.
-   *
-   * @param parent  the parent resource loader
-   */
-  public ClassLoaderResourceLoader(
-    ResourceLoader parent)
-  {
-    this(null, parent);
-  }
-
-  /**
-   * Constructs a new root ClassLoaderResourceLoader with specified top
-   * level resource package.
-   *
-   * @param rootPackage  the top level package used to interpret resource paths
-   */
-  public ClassLoaderResourceLoader(
-    String rootPackage)
-  {
-    _resourcePrefix = _getResourcePrefix(rootPackage);
-  }
-
-  /**
-   * Constructs a new root ClassLoaderResourceLoader with specified top
-   * level resource package and parent resource loader.
-   *
-   * @param rootPackage  the top level package used to interpret resource paths
-   * @param parent  the parent resource loader
-   */
-  public ClassLoaderResourceLoader(
-    String rootPackage,
-    ResourceLoader parent)
-  {
-    super(parent);
-    _resourcePrefix = _getResourcePrefix(rootPackage);
-  }
-
-  protected URL findResource(
-    String path) throws IOException
-  {
-    if (_resourcePrefix != null)
-    {
-      if (path.charAt(0) == '/')
-        path = _resourcePrefix + path;
-      else
-        path = _resourcePrefix + "/" + path;
-    }
-    else
-    {
-      // String off leading slash, since this can
-      // trip up ClassLoader.getResource()
-      if (path.charAt(0) == '/')
-        path = path.substring(1);
-    }
-
-    return getClassLoader().getResource(path);
-  }
-
-  /**
-   * Returns the ClassLoader to use when looking up resources under the top
-   * level package.  By default, this is the context class loader.
-   *
-   * @return the ClassLoader used to lookup resources
-   */
-  protected ClassLoader getClassLoader()
-  {
-    return Thread.currentThread().getContextClassLoader();
-  }
-
-  /**
-   * Converts root package into a resource prefix.  For example, converts
-   * the package "org.example" into resource prefix "org/example/".
-   *
-   * @param rootPackage  the root package
-   *
-   * @return the resource prefix
-   */
-  static private String _getResourcePrefix(
-    String rootPackage)
-  {
-    if (rootPackage == null ||
-        rootPackage.length() == 0)
-    {
-      return null;
-    }
-
-    return rootPackage.replace('.', '/');
-  }
-
-  private final String _resourcePrefix;
+/*
+ * Copyright  2004-2006 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.apache.myfaces.adf.resource;
+
+import java.io.IOException;
+
+import java.net.URL;
+
+
+/**
+ * A resource loader implementation which loads resources
+ * using the context class loader.
+ *
+ * @author The Oracle ADF Faces Team
+ */
+public class ClassLoaderResourceLoader extends ResourceLoader
+{
+  /**
+   * Constructs a new root ClassLoaderResourceLoader.
+   */
+  public ClassLoaderResourceLoader()
+  {
+    this((String)null);
+  }
+
+  /**
+   * Constructs a new ClassLoaderResourceLoader with specified parent.
+   *
+   * @param parent  the parent resource loader
+   */
+  public ClassLoaderResourceLoader(
+    ResourceLoader parent)
+  {
+    this(null, parent);
+  }
+
+  /**
+   * Constructs a new root ClassLoaderResourceLoader with specified top
+   * level resource package.
+   *
+   * @param rootPackage  the top level package used to interpret resource paths
+   */
+  public ClassLoaderResourceLoader(
+    String rootPackage)
+  {
+    _resourcePrefix = _getResourcePrefix(rootPackage);
+  }
+
+  /**
+   * Constructs a new root ClassLoaderResourceLoader with specified top
+   * level resource package and parent resource loader.
+   *
+   * @param rootPackage  the top level package used to interpret resource paths
+   * @param parent  the parent resource loader
+   */
+  public ClassLoaderResourceLoader(
+    String rootPackage,
+    ResourceLoader parent)
+  {
+    super(parent);
+    _resourcePrefix = _getResourcePrefix(rootPackage);
+  }
+
+  protected URL findResource(
+    String path) throws IOException
+  {
+    if (_resourcePrefix != null)
+    {
+      if (path.charAt(0) == '/')
+        path = _resourcePrefix + path;
+      else
+        path = _resourcePrefix + "/" + path;
+    }
+    else
+    {
+      // String off leading slash, since this can
+      // trip up ClassLoader.getResource()
+      if (path.charAt(0) == '/')
+        path = path.substring(1);
+    }
+
+    return getClassLoader().getResource(path);
+  }
+
+  /**
+   * Returns the ClassLoader to use when looking up resources under the top
+   * level package.  By default, this is the context class loader.
+   *
+   * @return the ClassLoader used to lookup resources
+   */
+  protected ClassLoader getClassLoader()
+  {
+    return Thread.currentThread().getContextClassLoader();
+  }
+
+  /**
+   * Converts root package into a resource prefix.  For example, converts
+   * the package "org.example" into resource prefix "org/example/".
+   *
+   * @param rootPackage  the root package
+   *
+   * @return the resource prefix
+   */
+  static private String _getResourcePrefix(
+    String rootPackage)
+  {
+    if (rootPackage == null ||
+        rootPackage.length() == 0)
+    {
+      return null;
+    }
+
+    return rootPackage.replace('.', '/');
+  }
+
+  private final String _resourcePrefix;
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/ClassLoaderResourceLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/DynamicResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/DynamicResourceLoader.java?rev=425268&r1=425267&r2=425268&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/DynamicResourceLoader.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/DynamicResourceLoader.java Mon Jul 24 20:54:50 2006
@@ -13,80 +13,80 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adf.resource;
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * A Dynamic Resource Loader that is capable of agregation and dynamic content via custom
- * URLConnection objects.
- * 
- * @author The Oracle ADF Faces Team
- */
-public abstract class DynamicResourceLoader extends ResourceLoader
-{  
-  /**
-   * Creates a DynamicResourceLoader for a specified path.  The dynamic resource loader will only
-   * respond to the specified path when findResource is executed with the same path.  If it is not
-   * the same, findResource will TRY to redirect the request to the parent if one is provided.  The
-   * parent ResourceLoader for this constructor is <code>null</code>
-   * 
-   * @param path the path that this ResourceLoader will respond to
-   */
-
-  public DynamicResourceLoader(String path)
-  {
-    this(path, null);
-  }
-  
-  /**
-   * Creates a CompositeResouceLoader for a specified path.  The dynamic resource loader will only
-   * respond to the specified path when findResource is executed with the same path.  If it is not
-   * the same, findResource will TRY to redirect the request to the parent if one is provided.
-   * 
-   * @param path the path that this ResourceLoader will respond to
-   * @param parent the parent resource loader
-   */
-  public DynamicResourceLoader(String path, ResourceLoader parent)
-  {
-    super(parent);
-    
-    if(path==null)
-    {
-      throw new NullPointerException();
-    }
-    
-    _path = path;
-  }
-  
-  /**
-   * Finds a resource.  If the path does not match the path that this object was constructed with
-   * then it will direct the request to the base ResourceLoader.  If the path is the same, it calls
-   * the getURL method.
-   * 
-   * @param path the path which the ResourceLoader is looking for.
-   * @return a URL for this resource
-   * @throws IOException when something bad happens
-   */
-  protected URL findResource(String path) throws IOException
-  {
-    if (_path.equals(path))
-    {
-      return getURL(path);
-    }
-
-    return super.findResource(path);
-  }
-  
-  /**
-   * Returns a URL to this resource.  This URL should have a valid connection.'
-   * 
-   * @param path the path of the findResourceCall
-   * @return a url for this Resource
-   * @throws IOException when something bad happens
-   */
-  protected abstract URL getURL(String path) throws IOException;
-  
-  private String _path;
- 
+package org.apache.myfaces.adf.resource;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * A Dynamic Resource Loader that is capable of agregation and dynamic content via custom
+ * URLConnection objects.
+ * 
+ * @author The Oracle ADF Faces Team
+ */
+public abstract class DynamicResourceLoader extends ResourceLoader
+{  
+  /**
+   * Creates a DynamicResourceLoader for a specified path.  The dynamic resource loader will only
+   * respond to the specified path when findResource is executed with the same path.  If it is not
+   * the same, findResource will TRY to redirect the request to the parent if one is provided.  The
+   * parent ResourceLoader for this constructor is <code>null</code>
+   * 
+   * @param path the path that this ResourceLoader will respond to
+   */
+
+  public DynamicResourceLoader(String path)
+  {
+    this(path, null);
+  }
+  
+  /**
+   * Creates a CompositeResouceLoader for a specified path.  The dynamic resource loader will only
+   * respond to the specified path when findResource is executed with the same path.  If it is not
+   * the same, findResource will TRY to redirect the request to the parent if one is provided.
+   * 
+   * @param path the path that this ResourceLoader will respond to
+   * @param parent the parent resource loader
+   */
+  public DynamicResourceLoader(String path, ResourceLoader parent)
+  {
+    super(parent);
+    
+    if(path==null)
+    {
+      throw new NullPointerException();
+    }
+    
+    _path = path;
+  }
+  
+  /**
+   * Finds a resource.  If the path does not match the path that this object was constructed with
+   * then it will direct the request to the base ResourceLoader.  If the path is the same, it calls
+   * the getURL method.
+   * 
+   * @param path the path which the ResourceLoader is looking for.
+   * @return a URL for this resource
+   * @throws IOException when something bad happens
+   */
+  protected URL findResource(String path) throws IOException
+  {
+    if (_path.equals(path))
+    {
+      return getURL(path);
+    }
+
+    return super.findResource(path);
+  }
+  
+  /**
+   * Returns a URL to this resource.  This URL should have a valid connection.'
+   * 
+   * @param path the path of the findResourceCall
+   * @return a url for this Resource
+   * @throws IOException when something bad happens
+   */
+  protected abstract URL getURL(String path) throws IOException;
+  
+  private String _path;
+ 
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/DynamicResourceLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/StringContentResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/StringContentResourceLoader.java?rev=425268&r1=425267&r2=425268&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/StringContentResourceLoader.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/StringContentResourceLoader.java Mon Jul 24 20:54:50 2006
@@ -13,130 +13,130 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adf.resource;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.net.URL;
-import java.io.IOException;
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
-
-public abstract class StringContentResourceLoader extends DynamicResourceLoader 
-{
-  public StringContentResourceLoader(String path)
-  {
-    super(path);
-  }
-  
-  public StringContentResourceLoader(String path, ResourceLoader parent)
-  {
-    super(path, parent);
-  }
-
-  protected URL getURL(String path) throws IOException
-  {
-    return new URL("dynamic", null, -1, path, new StringContentURLStreamHandler(getString(path), getContentType(path)));
-  }
-  
-  protected abstract String getString(String path) throws IOException;
-  
-  protected String getContentType(String path)
-  {
-    return "text";
-  }
-  
-  /**
-   * This is a stream handler that can be used to construct a URL whose connection will return content
-   * specified in a String.
-   * 
-   * @author The Oracle ADF Faces Team
-   */
-  private class StringContentURLStreamHandler extends URLStreamHandler
-  { 
-    /**
-     * Created a StringContentURLStreamHandler which will provide the specified content on the
-     * connection.
-     * 
-     * @param content the content of the connection
-     * @param contentType the content type of this connection (i.e. "text/javascript")
-     */
-    public StringContentURLStreamHandler(String content, String contentType)
-    {
-      _buff = content.getBytes();
-      _contentType = contentType;
-    }
-  
-    /**
-     * Returns a URLConnection containing the specified content.
-     * 
-     * @param u the URL for this connection
-     * @return a connection containing the string of data
-     * @throws IOException when something bad happens
-     */
-    protected URLConnection openConnection(URL u) throws IOException
-    {
-      return new StringContentURLConnection(u, _buff, _contentType); 
-    }
-  
-    private byte[] _buff;
-    private String _contentType;
-  }
-  
-  private class StringContentURLConnection extends URLConnection 
-  {
-    public StringContentURLConnection(URL url, byte[] buff, String contentType)
-    {
-      super(url);
-      connected = false;
-      _buff = buff;
-      _contentType = contentType;
-    }
-  
-    public void connect() throws IOException
-    {
-      connected = true;
-    }
-  
-    public String getContentEncoding()
-    {
-      //No content Encoding in Strings (like gzip or deflate)
-      return null;
-    }
-  
-    public int getContentLength()
-    {
-      return _buff.length;
-    }
-  
-    public String getContentType()
-    {
-      return _contentType;
-    }
-  
-    public String getHeaderField(String name)
-    {
-      if("content-encoding".equals(name))
-      {
-        return getContentEncoding();
-      }
-      else if ("content-length".equals(name))
-      {
-        return String.valueOf(getContentLength());
-      }
-      else if ("content-type".equals(name))
-      {
-        return getContentType();
-      }
-      
-      return null;
-    }
-  
-    public InputStream getInputStream() throws IOException
-    {
-      return new ByteArrayInputStream(_buff);
-    }
-    
-    private byte[] _buff;
-    private String _contentType;
-  }
-}
+package org.apache.myfaces.adf.resource;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.io.IOException;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+public abstract class StringContentResourceLoader extends DynamicResourceLoader 
+{
+  public StringContentResourceLoader(String path)
+  {
+    super(path);
+  }
+  
+  public StringContentResourceLoader(String path, ResourceLoader parent)
+  {
+    super(path, parent);
+  }
+
+  protected URL getURL(String path) throws IOException
+  {
+    return new URL("dynamic", null, -1, path, new StringContentURLStreamHandler(getString(path), getContentType(path)));
+  }
+  
+  protected abstract String getString(String path) throws IOException;
+  
+  protected String getContentType(String path)
+  {
+    return "text";
+  }
+  
+  /**
+   * This is a stream handler that can be used to construct a URL whose connection will return content
+   * specified in a String.
+   * 
+   * @author The Oracle ADF Faces Team
+   */
+  private class StringContentURLStreamHandler extends URLStreamHandler
+  { 
+    /**
+     * Created a StringContentURLStreamHandler which will provide the specified content on the
+     * connection.
+     * 
+     * @param content the content of the connection
+     * @param contentType the content type of this connection (i.e. "text/javascript")
+     */
+    public StringContentURLStreamHandler(String content, String contentType)
+    {
+      _buff = content.getBytes();
+      _contentType = contentType;
+    }
+  
+    /**
+     * Returns a URLConnection containing the specified content.
+     * 
+     * @param u the URL for this connection
+     * @return a connection containing the string of data
+     * @throws IOException when something bad happens
+     */
+    protected URLConnection openConnection(URL u) throws IOException
+    {
+      return new StringContentURLConnection(u, _buff, _contentType); 
+    }
+  
+    private byte[] _buff;
+    private String _contentType;
+  }
+  
+  private class StringContentURLConnection extends URLConnection 
+  {
+    public StringContentURLConnection(URL url, byte[] buff, String contentType)
+    {
+      super(url);
+      connected = false;
+      _buff = buff;
+      _contentType = contentType;
+    }
+  
+    public void connect() throws IOException
+    {
+      connected = true;
+    }
+  
+    public String getContentEncoding()
+    {
+      //No content Encoding in Strings (like gzip or deflate)
+      return null;
+    }
+  
+    public int getContentLength()
+    {
+      return _buff.length;
+    }
+  
+    public String getContentType()
+    {
+      return _contentType;
+    }
+  
+    public String getHeaderField(String name)
+    {
+      if("content-encoding".equals(name))
+      {
+        return getContentEncoding();
+      }
+      else if ("content-length".equals(name))
+      {
+        return String.valueOf(getContentLength());
+      }
+      else if ("content-type".equals(name))
+      {
+        return getContentType();
+      }
+      
+      return null;
+    }
+  
+    public InputStream getInputStream() throws IOException
+    {
+      return new ByteArrayInputStream(_buff);
+    }
+    
+    private byte[] _buff;
+    private String _contentType;
+  }
+}

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/resource/StringContentResourceLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/util/ErrorMessages.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/util/ErrorMessages.java?rev=425268&r1=425267&r2=425268&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/util/ErrorMessages.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/util/ErrorMessages.java Mon Jul 24 20:54:50 2006
@@ -13,29 +13,29 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adf.util;
-
-// CLASS  for way of sending back the translated string for 
-// given key. There are two messages for the key. One for the given 
-// key and other of key_detail.
-class ErrorMessages
-{
-  ErrorMessages(String message, String detailMessage)
-  {
-    _message = message;
-    _detailMessage = detailMessage;    
-  }
-  
-  public String getMessage()
-  {
-    return _message;
-  }
-  
-  public String getDetailMessage()
-  {
-    return _detailMessage;
-  }
-  
-  private String _message;
-  private String _detailMessage;
+package org.apache.myfaces.adf.util;
+
+// CLASS  for way of sending back the translated string for 
+// given key. There are two messages for the key. One for the given 
+// key and other of key_detail.
+class ErrorMessages
+{
+  ErrorMessages(String message, String detailMessage)
+  {
+    _message = message;
+    _detailMessage = detailMessage;    
+  }
+  
+  public String getMessage()
+  {
+    return _message;
+  }
+  
+  public String getDetailMessage()
+  {
+    return _detailMessage;
+  }
+  
+  private String _message;
+  private String _detailMessage;
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/util/ErrorMessages.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/validator/ValidatorUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/validator/ValidatorUtils.java?rev=425268&r1=425267&r2=425268&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/validator/ValidatorUtils.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/validator/ValidatorUtils.java Mon Jul 24 20:54:50 2006
@@ -1,112 +1,112 @@
-/*
- * Copyright  2003-2006 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.apache.myfaces.adf.validator;
-import javax.faces.component.UIComponent;
-import javax.faces.el.ValueBinding;
-
-import org.apache.myfaces.adf.bean.FacesBean;
-import org.apache.myfaces.adf.bean.FacesBeanImpl;
-import org.apache.myfaces.adf.bean.PropertyKey;
-
-/**
- * Utility class for Validators. 
- * 
- * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-api/src/main/java/oracle/adf/view/faces/validator/ValidatorUtils.java#0 $) $Date: 10-nov-2005.19:08:35 $
- * @author The Oracle ADF Faces Team
- */
-class ValidatorUtils 
-{
-  private ValidatorUtils()
-  {
-  }  
-  
-  /**
-   * Checks if the parameter is of String type. If not throws a 
-   * IllegalArgumentException
-   * @param value value to the validated for String type
-   * @param message The message to be used to create IllegalArgumentException
-   */
-  static final void assertIsString(   
-    Object value,
-    String message) throws IllegalArgumentException
-  {
-    if (!(value instanceof String))
-      throw new IllegalArgumentException(message);         
-  }
-  
-  static Object getComponentLabel(UIComponent component)
-  { 
-      Object label = component.getAttributes().get("label");
-      if ( null == label)
-       label = component.getValueBinding("label");
-       
-      return label;
-  }  
-  
-  static FacesBean getFacesBean(final FacesBean.Type type)
-  {
-    FacesBeanImpl bean = new FacesBeanImpl()
-                           {
-                             public FacesBean.Type getType()
-                             {
-                               return type;
-                             }
-                           };
-    return bean;
-  }  
- 
-  static void setValueBinding(FacesBean bean, String name, ValueBinding binding)
-  {   
-    PropertyKey key = _getPropertyKey(bean, name, true);
-    bean.setValueBinding(key, binding);
-  }
- 
-  static ValueBinding getValueBinding(FacesBean bean, String name)
-  {
-    PropertyKey key = _getPropertyKey(bean, name, true);
-    return bean.getValueBinding(key);
-  }
-  
-  static boolean equals(Object o1, Object o2)
-  {
-    return ( o1 == o2 || (o1 != null && o1.equals(o2)));
-  }
-  
-  private static PropertyKey _getPropertyKey(
-    FacesBean bean, 
-    String name,  
-    boolean isStrict)
-  {   
-    _assertNotNull(name, "attribute cannot be null");
-    FacesBean.Type type = bean.getType();
-    PropertyKey key = type.findKey(name);
-    if (isStrict && key == null)
-     throw new IllegalArgumentException("Invalid attribute name " + name);
-    else 
-    return key;
-  }
-
-  private static void _assertNotNull(Object object, String message)
-  {
-    if (object == null)
-    {
-       if (message == null)
-         throw new NullPointerException();
-       else 
-         throw new NullPointerException(message);
-    }
-  }
+/*
+ * Copyright  2003-2006 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.apache.myfaces.adf.validator;
+import javax.faces.component.UIComponent;
+import javax.faces.el.ValueBinding;
+
+import org.apache.myfaces.adf.bean.FacesBean;
+import org.apache.myfaces.adf.bean.FacesBeanImpl;
+import org.apache.myfaces.adf.bean.PropertyKey;
+
+/**
+ * Utility class for Validators. 
+ * 
+ * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-api/src/main/java/oracle/adf/view/faces/validator/ValidatorUtils.java#0 $) $Date: 10-nov-2005.19:08:35 $
+ * @author The Oracle ADF Faces Team
+ */
+class ValidatorUtils 
+{
+  private ValidatorUtils()
+  {
+  }  
+  
+  /**
+   * Checks if the parameter is of String type. If not throws a 
+   * IllegalArgumentException
+   * @param value value to the validated for String type
+   * @param message The message to be used to create IllegalArgumentException
+   */
+  static final void assertIsString(   
+    Object value,
+    String message) throws IllegalArgumentException
+  {
+    if (!(value instanceof String))
+      throw new IllegalArgumentException(message);         
+  }
+  
+  static Object getComponentLabel(UIComponent component)
+  { 
+      Object label = component.getAttributes().get("label");
+      if ( null == label)
+       label = component.getValueBinding("label");
+       
+      return label;
+  }  
+  
+  static FacesBean getFacesBean(final FacesBean.Type type)
+  {
+    FacesBeanImpl bean = new FacesBeanImpl()
+                           {
+                             public FacesBean.Type getType()
+                             {
+                               return type;
+                             }
+                           };
+    return bean;
+  }  
+ 
+  static void setValueBinding(FacesBean bean, String name, ValueBinding binding)
+  {   
+    PropertyKey key = _getPropertyKey(bean, name, true);
+    bean.setValueBinding(key, binding);
+  }
+ 
+  static ValueBinding getValueBinding(FacesBean bean, String name)
+  {
+    PropertyKey key = _getPropertyKey(bean, name, true);
+    return bean.getValueBinding(key);
+  }
+  
+  static boolean equals(Object o1, Object o2)
+  {
+    return ( o1 == o2 || (o1 != null && o1.equals(o2)));
+  }
+  
+  private static PropertyKey _getPropertyKey(
+    FacesBean bean, 
+    String name,  
+    boolean isStrict)
+  {   
+    _assertNotNull(name, "attribute cannot be null");
+    FacesBean.Type type = bean.getType();
+    PropertyKey key = type.findKey(name);
+    if (isStrict && key == null)
+     throw new IllegalArgumentException("Invalid attribute name " + name);
+    else 
+    return key;
+  }
+
+  private static void _assertNotNull(Object object, String message)
+  {
+    if (object == null)
+    {
+       if (message == null)
+         throw new NullPointerException();
+       else 
+         throw new NullPointerException(message);
+    }
+  }
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/main/java/org/apache/myfaces/adf/validator/ValidatorUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/test/java/org/apache/myfaces/adf/bean/FacesBeanImplTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/test/java/org/apache/myfaces/adf/bean/FacesBeanImplTest.java?rev=425268&r1=425267&r2=425268&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/test/java/org/apache/myfaces/adf/bean/FacesBeanImplTest.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/test/java/org/apache/myfaces/adf/bean/FacesBeanImplTest.java Mon Jul 24 20:54:50 2006
@@ -13,474 +13,474 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adf.bean;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import java.util.Iterator;
-
-import javax.faces.el.ValueBinding;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class FacesBeanImplTest extends TestCase
-{
-  public static final Test suite()
-  {
-    return new TestSuite(FacesBeanImplTest.class);
-  }
-  
-  public static void main(String[] args) throws Throwable
-  {
-    junit.textui.TestRunner.run(suite());
-  }
-
-  public FacesBeanImplTest(
-    String testName)
-  {
-    super(testName);
-  }
-
-  public void setUp()
-  {
-  }
-
-  public void tearDown()
-  {
-  }
-
-  public void testInitialValues()
-  {
-    TestBean bean = new TestBean();
-    assertNull(bean.getFirst());
-    assertNull(bean.getSecond());
-  }
-
-  public void testSubclass()
-  {
-    SubTypeBean bean = new SubTypeBean();
-    assertNull(bean.getFirst());
-    assertNull(bean.getSecond());
-    assertNull(bean.getSub());
-    bean.setSub("sub");
-    assertEquals("sub", bean.getSub());
-  }
-
-  public void testSetValues()
-  {
-    TestBean bean = new TestBean();
-    bean.setFirst("first");
-    bean.setSecond("second");
-    assertEquals(bean.getFirst(), "first");
-    assertEquals(bean.getSecond(), "second");
-
-    bean.setFirst(null);
-    bean.setSecond(null);
-
-    assertNull(bean.getFirst());
-    assertNull(bean.getSecond());
-
-    bean.setSecond("newSecond");
-    assertEquals(bean.getSecond(), "newSecond");
-    assertEquals(bean.getProperty(TestBean.SECOND_KEY), "newSecond");
-    assertEquals(bean.getLocalProperty(TestBean.SECOND_KEY), "newSecond");
-
-    bean.setProperty(TestBean.FIRST_KEY, "newFirst");
-    assertEquals(bean.getFirst(), "newFirst");
-  }
-
-  public void testAliases()
-  {
-    TestBean bean = new TestBean();
-    bean.setFirstAlias("alias");
-    assertEquals("alias", bean.getFirst());
-    assertEquals("alias", bean.getFirstAlias());
-
-    bean = new TestBean();
-    bean.setFirst("alias2");
-    assertEquals("alias2", bean.getFirst());
-    assertEquals("alias2", bean.getFirstAlias());
-  }
-
-  public void testAnonymousKeys()
-  {
-    // Create an anonymous key
-    PropertyKey thirdKey = new PropertyKey("third");
-    TestBean bean = new TestBean();
-    bean.setFirst("first");
-    bean.setSecond("second");
-    bean.setProperty(thirdKey, "third");
-    assertEquals(bean.getFirst(), "first");
-    assertEquals(bean.getSecond(), "second");
-    assertEquals(bean.getProperty(thirdKey), "third");
-
-    PropertyKey extraInstance = new PropertyKey("third");
-    assertEquals(bean.getProperty(thirdKey),
-                 bean.getProperty(extraInstance));
-  }
-
-
-  public void testBindingNotAllowed()
-  {
-    TestBean bean = new TestBean();
-    try
-    {
-      bean.setValueBinding(TestBean.CANT_BE_BOUND_KEY,
-                           new TestValueBinding());
-      fail();
-    }
-    catch (IllegalArgumentException e)
-    {
-    }
-  }
-
-
-
-  public void testBindings()
-  {
-    TestBean bean = new TestBean();
-    TestValueBinding vb1 = new TestValueBinding();
-    vb1.setValue(null, "vbFirst");
-    bean.setValueBinding(TestBean.FIRST_KEY, vb1);
-
-    assertSame(bean.getValueBinding(TestBean.FIRST_KEY), vb1);
-
-    assertEquals("vbFirst", bean.getFirst());
-
-    bean.setFirst("first");
-    assertEquals("first", bean.getFirst());
-    
-    bean.setFirst(null);
-    assertEquals("vbFirst", bean.getFirst());
-  }
-
-  public void testSets()
-  {
-    TestBean bean = new TestBean();
-    assertTrue(bean.keySet().isEmpty());
-    assertTrue(bean.bindingKeySet().isEmpty());
-    
-    bean.setFirst("first");
-    bean.setSecond("second");
-
-    assertEquals(2, bean.keySet().size());
-
-    bean.setSecond("newSecond");
-
-    assertEquals(2, bean.keySet().size());
-    
-    bean.setSecond(null);
-    
-    // This test is somewhat dubious...
-    assertEquals(1, bean.keySet().size());
-
-    // Create an anonymous key
-    PropertyKey thirdKey = new PropertyKey("third");
-
-    bean.setValueBinding(TestBean.FIRST_KEY, new TestValueBinding());
-    assertEquals(1, bean.bindingKeySet().size());
-
-    bean.setValueBinding(TestBean.FIRST_KEY, new TestValueBinding());
-    assertEquals(1, bean.bindingKeySet().size());
-
-    bean.setValueBinding(thirdKey, new TestValueBinding());
-    assertEquals(2, bean.bindingKeySet().size());
-    
-    assertTrue(bean.bindingKeySet().contains(thirdKey));  
-    assertTrue(bean.bindingKeySet().contains(TestBean.FIRST_KEY));
-    assertTrue(!bean.bindingKeySet().contains(TestBean.SECOND_KEY));
-  }
-
-  public void testLists()
-  {
-    TestBean bean = new TestBean();
-    Iterator iterator = bean.items();
-    assertTrue(!iterator.hasNext());
-    Integer[] array = bean.getItems();
-    assertNotNull(array);
-    assertEquals(0, array.length);
-
-    bean.addItem(new Integer(1));
-    assertEquals(1, bean.getItems().length);
-
-    bean.addItem(new Integer(2));
-    assertEquals(2, bean.getItems().length);
-    
-    array = bean.getItems();
-    assertEquals(array[0], new Integer(1));
-    assertEquals(array[1], new Integer(2));
-
-    // Verify that this is a *list*, not a Set, so adding the
-    // same value twice works as expected
-    bean.addItem(new Integer(2));
-    assertEquals(3, bean.getItems().length);
-    bean.removeItem(new Integer(2));
-
-    iterator = bean.items();
-    assertEquals(new Integer(1), iterator.next());
-    assertEquals(new Integer(2), iterator.next());
-    assertTrue(!iterator.hasNext());
-
-    assertTrue(bean.containsEntry(TestBean.ITEMS_KEY, Number.class));
-    assertTrue(bean.containsEntry(TestBean.ITEMS_KEY, Integer.class));
-    assertTrue(!bean.containsEntry(TestBean.ITEMS_KEY, Long.class));
-
-    bean.removeItem(new Integer(1));
-    bean.removeItem(new Integer(2));
-
-    iterator = bean.items();
-    assertTrue(!iterator.hasNext());
-    array = bean.getItems();
-    assertNotNull(array);
-    assertEquals(0, array.length);
-
-    // List items cannot be set, bound, or retrieved
-    try
-    {
-      bean.setProperty(TestBean.ITEMS_KEY, "Shouldn't work");
-      fail();
-    }
-    catch (IllegalArgumentException iae) 
-    {
-      // expected
-    }
-
-
-    try
-    {
-      bean.getProperty(TestBean.ITEMS_KEY);
-      fail();
-    }
-    catch (IllegalArgumentException iae)
-    {
-      // expected
-    }
-
-    try
-    {
-      bean.getLocalProperty(TestBean.ITEMS_KEY);
-      fail();
-    }
-    catch (IllegalArgumentException iae)
-    {
-      // expected
-    }
-
-    try
-    {
-      bean.setValueBinding(TestBean.ITEMS_KEY, new TestValueBinding());
-      fail();
-    }
-    catch (IllegalArgumentException iae)
-    {
-      // expected
-    }
-
-    // Meanwhile, you can't use the list APIs for non-list keys
-    try
-    {
-      bean.addEntry(TestBean.FIRST_KEY, null);
-      fail();
-    }
-    catch (IllegalArgumentException iae)
-    {
-      // expected
-    }
-
-    try
-    {
-      bean.addEntry(TestBean.FIRST_KEY, null);
-      fail();
-    }
-    catch (IllegalArgumentException iae)
-    {
-      // expected
-    }
-
-    try
-    {
-      bean.removeEntry(TestBean.FIRST_KEY, null);
-      fail();
-    }
-    catch (IllegalArgumentException iae) 
-    {
-      // expected
-    }
-
-    try
-    {
-      bean.getEntries(TestBean.FIRST_KEY, Object.class);
-      fail();
-    }
-    catch (IllegalArgumentException iae)
-    {
-      // expected
-    }
-
-    try
-    {
-      bean.entries(TestBean.FIRST_KEY);
-      fail();
-    }
-    catch (IllegalArgumentException iae)
-    {
-      // expected
-    }
-  }
-
-  public void testTypeLocked()
-  {
-    try
-    {
-      TestBean.TYPE.registerKey("ShouldntWork");
-      fail();
-    }
-    catch (IllegalStateException ise)
-    {
-    }
-  }
-
-  public void testAddAll()
-  {
-    TestBean bean = new TestBean();
-    bean.setFirst("first");
-    TestValueBinding binding = new TestValueBinding();
-    binding.setValue(null, "FirstBinding");
-    bean.setValueBinding(TestBean.FIRST_KEY, binding);
-    bean.setSecond("second");
-    bean.setProperty(new PropertyKey("sub"), "subValue");
-    bean.addItem(new Integer(1));
-    bean.addItem(new Integer(2));
-
-    SubTypeBean sub = new SubTypeBean();
-    sub.setSecond("third");
-    sub.addAll(bean);
-
-    assertEquals("first", sub.getFirst());
-    assertEquals("second", sub.getSecond());
-    assertEquals("subValue", sub.getSub());
-    assertNotNull(sub.getValueBinding(TestBean.FIRST_KEY));
-    assertEquals("FirstBinding",
-                 sub.getValueBinding(TestBean.FIRST_KEY).getValue(null));
-    Integer[] items = sub.getItems();
-    assertNotNull(items);
-    assertEquals(2, items.length);
-    assertEquals(new Integer(1), items[0]);
-    assertEquals(new Integer(2), items[1]);
-
-    TestBean andBackAgain = new TestBean();
-    andBackAgain.addAll(sub);
-    assertEquals("subValue",
-                 andBackAgain.getLocalProperty(new PropertyKey("sub")));
-  }
-
-  public void testStateSaveAndRestore()
-  {
-    // Build a bean
-    SubTypeBean bean = new SubTypeBean();
-    TestValueBinding vb1 = new TestValueBinding();
-    vb1.setValue(null, "vbFirst");
-    bean.setValueBinding(SubTypeBean.FIRST_KEY, vb1);
-    bean.setSecond("second");
-    bean.setTransient("Won't be there");
-    bean.setSub("sub");
-    bean.addItem(new Integer(1));
-    bean.addItem(new Integer(2));
-
-    SillyStateHolder silly = new SillyStateHolder();
-    bean.setProperty(SubTypeBean.SILLY_KEY, silly);
-
-    assertEquals("0", silly.toString());
-
-    // Save its state
-    Object savedState = bean.saveState(null);
-    assertNotNull(savedState);
-
-    try
-    {
-      savedState = _copyObjectThroughSerialization(savedState);
-    }
-    catch (Exception e)
-    {
-      e.printStackTrace();
-      fail();
-    }
-
-    // Verify that our "silly" object has had its state saved
-    assertEquals("1", silly.toString());
-
-    // Build a new bean, and restore its state
-    SubTypeBean newBean = new SubTypeBean();
-    newBean.restoreState(null, savedState);
-
-    // Verify it looks like the old bean
-    assertEquals("vbFirst", newBean.getFirst());
-    assertNull(newBean.getLocalProperty(SubTypeBean.FIRST_KEY));
-    assertEquals("second", newBean.getSecond());
-    assertNull(newBean.getValueBinding(SubTypeBean.SECOND_KEY));
-    assertEquals("sub", newBean.getSub());
-    
-    // Verify that our "silly" object has had its state restored
-    assertEquals("2", newBean.getProperty(SubTypeBean.SILLY_KEY).toString());
-
-    Integer[] array = newBean.getItems();
-    assertEquals(2, array.length);
-    assertEquals(new Integer(1), array[0]);
-    assertEquals(new Integer(2), array[1]);
-
-    
-    // Make sure the transient value is now null
-    assertNull(newBean.getTransient());
-
-    // Make sure the value binding looks the same, but is
-    // not actually the same instance
-    ValueBinding vb = newBean.getValueBinding(SubTypeBean.FIRST_KEY);
-    assertTrue(vb instanceof TestValueBinding);
-    assertTrue(vb != vb1);
-    assertEquals(vb.getValue(null), "vbFirst");
-    
-    // Now change the value binding, and verify the original
-    // bean is unchanged
-    vb.setValue(null, "changedVB");
-    assertEquals("changedVB", newBean.getFirst());
-    assertEquals("vbFirst", bean.getFirst());
-    
-    // Now, verify that if we mark the initial state and save, that we get
-    // a non-null value
-    newBean.markInitialState();
-    assertNull(newBean.saveState(null));
-    
-    // Now, we'll set a value, so we should get a non-null state
-    String oldFirst = newBean.getFirst();
-    newBean.setFirst("foo");
-    assertNotNull(newBean.saveState(null));
-  
-    // Our current delta support *does not* keep track of the original value.
-    // If it does, add this test
-//    newBean.setFirst(oldFirst);
-//    assertNull(newBean.saveState(null));
-  }
-
-  static private Object _copyObjectThroughSerialization(Object o)
-    throws IOException, ClassNotFoundException
-  {
-    ByteArrayOutputStream bos = new ByteArrayOutputStream();
-    ObjectOutputStream oos = new ObjectOutputStream(bos);
-    oos.writeObject(o);
-    oos.close();
-
-    byte[] byteArray = bos.toByteArray();
-    ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
-    ObjectInputStream ois = new ObjectInputStream(bis);
-
-    return ois.readObject();
-  }
-
-  private PropertyKey _thirdKey;
-}
+package org.apache.myfaces.adf.bean;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import java.util.Iterator;
+
+import javax.faces.el.ValueBinding;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class FacesBeanImplTest extends TestCase
+{
+  public static final Test suite()
+  {
+    return new TestSuite(FacesBeanImplTest.class);
+  }
+  
+  public static void main(String[] args) throws Throwable
+  {
+    junit.textui.TestRunner.run(suite());
+  }
+
+  public FacesBeanImplTest(
+    String testName)
+  {
+    super(testName);
+  }
+
+  public void setUp()
+  {
+  }
+
+  public void tearDown()
+  {
+  }
+
+  public void testInitialValues()
+  {
+    TestBean bean = new TestBean();
+    assertNull(bean.getFirst());
+    assertNull(bean.getSecond());
+  }
+
+  public void testSubclass()
+  {
+    SubTypeBean bean = new SubTypeBean();
+    assertNull(bean.getFirst());
+    assertNull(bean.getSecond());
+    assertNull(bean.getSub());
+    bean.setSub("sub");
+    assertEquals("sub", bean.getSub());
+  }
+
+  public void testSetValues()
+  {
+    TestBean bean = new TestBean();
+    bean.setFirst("first");
+    bean.setSecond("second");
+    assertEquals(bean.getFirst(), "first");
+    assertEquals(bean.getSecond(), "second");
+
+    bean.setFirst(null);
+    bean.setSecond(null);
+
+    assertNull(bean.getFirst());
+    assertNull(bean.getSecond());
+
+    bean.setSecond("newSecond");
+    assertEquals(bean.getSecond(), "newSecond");
+    assertEquals(bean.getProperty(TestBean.SECOND_KEY), "newSecond");
+    assertEquals(bean.getLocalProperty(TestBean.SECOND_KEY), "newSecond");
+
+    bean.setProperty(TestBean.FIRST_KEY, "newFirst");
+    assertEquals(bean.getFirst(), "newFirst");
+  }
+
+  public void testAliases()
+  {
+    TestBean bean = new TestBean();
+    bean.setFirstAlias("alias");
+    assertEquals("alias", bean.getFirst());
+    assertEquals("alias", bean.getFirstAlias());
+
+    bean = new TestBean();
+    bean.setFirst("alias2");
+    assertEquals("alias2", bean.getFirst());
+    assertEquals("alias2", bean.getFirstAlias());
+  }
+
+  public void testAnonymousKeys()
+  {
+    // Create an anonymous key
+    PropertyKey thirdKey = new PropertyKey("third");
+    TestBean bean = new TestBean();
+    bean.setFirst("first");
+    bean.setSecond("second");
+    bean.setProperty(thirdKey, "third");
+    assertEquals(bean.getFirst(), "first");
+    assertEquals(bean.getSecond(), "second");
+    assertEquals(bean.getProperty(thirdKey), "third");
+
+    PropertyKey extraInstance = new PropertyKey("third");
+    assertEquals(bean.getProperty(thirdKey),
+                 bean.getProperty(extraInstance));
+  }
+
+
+  public void testBindingNotAllowed()
+  {
+    TestBean bean = new TestBean();
+    try
+    {
+      bean.setValueBinding(TestBean.CANT_BE_BOUND_KEY,
+                           new TestValueBinding());
+      fail();
+    }
+    catch (IllegalArgumentException e)
+    {
+    }
+  }
+
+
+
+  public void testBindings()
+  {
+    TestBean bean = new TestBean();
+    TestValueBinding vb1 = new TestValueBinding();
+    vb1.setValue(null, "vbFirst");
+    bean.setValueBinding(TestBean.FIRST_KEY, vb1);
+
+    assertSame(bean.getValueBinding(TestBean.FIRST_KEY), vb1);
+
+    assertEquals("vbFirst", bean.getFirst());
+
+    bean.setFirst("first");
+    assertEquals("first", bean.getFirst());
+    
+    bean.setFirst(null);
+    assertEquals("vbFirst", bean.getFirst());
+  }
+
+  public void testSets()
+  {
+    TestBean bean = new TestBean();
+    assertTrue(bean.keySet().isEmpty());
+    assertTrue(bean.bindingKeySet().isEmpty());
+    
+    bean.setFirst("first");
+    bean.setSecond("second");
+
+    assertEquals(2, bean.keySet().size());
+
+    bean.setSecond("newSecond");
+
+    assertEquals(2, bean.keySet().size());
+    
+    bean.setSecond(null);
+    
+    // This test is somewhat dubious...
+    assertEquals(1, bean.keySet().size());
+
+    // Create an anonymous key
+    PropertyKey thirdKey = new PropertyKey("third");
+
+    bean.setValueBinding(TestBean.FIRST_KEY, new TestValueBinding());
+    assertEquals(1, bean.bindingKeySet().size());
+
+    bean.setValueBinding(TestBean.FIRST_KEY, new TestValueBinding());
+    assertEquals(1, bean.bindingKeySet().size());
+
+    bean.setValueBinding(thirdKey, new TestValueBinding());
+    assertEquals(2, bean.bindingKeySet().size());
+    
+    assertTrue(bean.bindingKeySet().contains(thirdKey));  
+    assertTrue(bean.bindingKeySet().contains(TestBean.FIRST_KEY));
+    assertTrue(!bean.bindingKeySet().contains(TestBean.SECOND_KEY));
+  }
+
+  public void testLists()
+  {
+    TestBean bean = new TestBean();
+    Iterator iterator = bean.items();
+    assertTrue(!iterator.hasNext());
+    Integer[] array = bean.getItems();
+    assertNotNull(array);
+    assertEquals(0, array.length);
+
+    bean.addItem(new Integer(1));
+    assertEquals(1, bean.getItems().length);
+
+    bean.addItem(new Integer(2));
+    assertEquals(2, bean.getItems().length);
+    
+    array = bean.getItems();
+    assertEquals(array[0], new Integer(1));
+    assertEquals(array[1], new Integer(2));
+
+    // Verify that this is a *list*, not a Set, so adding the
+    // same value twice works as expected
+    bean.addItem(new Integer(2));
+    assertEquals(3, bean.getItems().length);
+    bean.removeItem(new Integer(2));
+
+    iterator = bean.items();
+    assertEquals(new Integer(1), iterator.next());
+    assertEquals(new Integer(2), iterator.next());
+    assertTrue(!iterator.hasNext());
+
+    assertTrue(bean.containsEntry(TestBean.ITEMS_KEY, Number.class));
+    assertTrue(bean.containsEntry(TestBean.ITEMS_KEY, Integer.class));
+    assertTrue(!bean.containsEntry(TestBean.ITEMS_KEY, Long.class));
+
+    bean.removeItem(new Integer(1));
+    bean.removeItem(new Integer(2));
+
+    iterator = bean.items();
+    assertTrue(!iterator.hasNext());
+    array = bean.getItems();
+    assertNotNull(array);
+    assertEquals(0, array.length);
+
+    // List items cannot be set, bound, or retrieved
+    try
+    {
+      bean.setProperty(TestBean.ITEMS_KEY, "Shouldn't work");
+      fail();
+    }
+    catch (IllegalArgumentException iae) 
+    {
+      // expected
+    }
+
+
+    try
+    {
+      bean.getProperty(TestBean.ITEMS_KEY);
+      fail();
+    }
+    catch (IllegalArgumentException iae)
+    {
+      // expected
+    }
+
+    try
+    {
+      bean.getLocalProperty(TestBean.ITEMS_KEY);
+      fail();
+    }
+    catch (IllegalArgumentException iae)
+    {
+      // expected
+    }
+
+    try
+    {
+      bean.setValueBinding(TestBean.ITEMS_KEY, new TestValueBinding());
+      fail();
+    }
+    catch (IllegalArgumentException iae)
+    {
+      // expected
+    }
+
+    // Meanwhile, you can't use the list APIs for non-list keys
+    try
+    {
+      bean.addEntry(TestBean.FIRST_KEY, null);
+      fail();
+    }
+    catch (IllegalArgumentException iae)
+    {
+      // expected
+    }
+
+    try
+    {
+      bean.addEntry(TestBean.FIRST_KEY, null);
+      fail();
+    }
+    catch (IllegalArgumentException iae)
+    {
+      // expected
+    }
+
+    try
+    {
+      bean.removeEntry(TestBean.FIRST_KEY, null);
+      fail();
+    }
+    catch (IllegalArgumentException iae) 
+    {
+      // expected
+    }
+
+    try
+    {
+      bean.getEntries(TestBean.FIRST_KEY, Object.class);
+      fail();
+    }
+    catch (IllegalArgumentException iae)
+    {
+      // expected
+    }
+
+    try
+    {
+      bean.entries(TestBean.FIRST_KEY);
+      fail();
+    }
+    catch (IllegalArgumentException iae)
+    {
+      // expected
+    }
+  }
+
+  public void testTypeLocked()
+  {
+    try
+    {
+      TestBean.TYPE.registerKey("ShouldntWork");
+      fail();
+    }
+    catch (IllegalStateException ise)
+    {
+    }
+  }
+
+  public void testAddAll()
+  {
+    TestBean bean = new TestBean();
+    bean.setFirst("first");
+    TestValueBinding binding = new TestValueBinding();
+    binding.setValue(null, "FirstBinding");
+    bean.setValueBinding(TestBean.FIRST_KEY, binding);
+    bean.setSecond("second");
+    bean.setProperty(new PropertyKey("sub"), "subValue");
+    bean.addItem(new Integer(1));
+    bean.addItem(new Integer(2));
+
+    SubTypeBean sub = new SubTypeBean();
+    sub.setSecond("third");
+    sub.addAll(bean);
+
+    assertEquals("first", sub.getFirst());
+    assertEquals("second", sub.getSecond());
+    assertEquals("subValue", sub.getSub());
+    assertNotNull(sub.getValueBinding(TestBean.FIRST_KEY));
+    assertEquals("FirstBinding",
+                 sub.getValueBinding(TestBean.FIRST_KEY).getValue(null));
+    Integer[] items = sub.getItems();
+    assertNotNull(items);
+    assertEquals(2, items.length);
+    assertEquals(new Integer(1), items[0]);
+    assertEquals(new Integer(2), items[1]);
+
+    TestBean andBackAgain = new TestBean();
+    andBackAgain.addAll(sub);
+    assertEquals("subValue",
+                 andBackAgain.getLocalProperty(new PropertyKey("sub")));
+  }
+
+  public void testStateSaveAndRestore()
+  {
+    // Build a bean
+    SubTypeBean bean = new SubTypeBean();
+    TestValueBinding vb1 = new TestValueBinding();
+    vb1.setValue(null, "vbFirst");
+    bean.setValueBinding(SubTypeBean.FIRST_KEY, vb1);
+    bean.setSecond("second");
+    bean.setTransient("Won't be there");
+    bean.setSub("sub");
+    bean.addItem(new Integer(1));
+    bean.addItem(new Integer(2));
+
+    SillyStateHolder silly = new SillyStateHolder();
+    bean.setProperty(SubTypeBean.SILLY_KEY, silly);
+
+    assertEquals("0", silly.toString());
+
+    // Save its state
+    Object savedState = bean.saveState(null);
+    assertNotNull(savedState);
+
+    try
+    {
+      savedState = _copyObjectThroughSerialization(savedState);
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+      fail();
+    }
+
+    // Verify that our "silly" object has had its state saved
+    assertEquals("1", silly.toString());
+
+    // Build a new bean, and restore its state
+    SubTypeBean newBean = new SubTypeBean();
+    newBean.restoreState(null, savedState);
+
+    // Verify it looks like the old bean
+    assertEquals("vbFirst", newBean.getFirst());
+    assertNull(newBean.getLocalProperty(SubTypeBean.FIRST_KEY));
+    assertEquals("second", newBean.getSecond());
+    assertNull(newBean.getValueBinding(SubTypeBean.SECOND_KEY));
+    assertEquals("sub", newBean.getSub());
+    
+    // Verify that our "silly" object has had its state restored
+    assertEquals("2", newBean.getProperty(SubTypeBean.SILLY_KEY).toString());
+
+    Integer[] array = newBean.getItems();
+    assertEquals(2, array.length);
+    assertEquals(new Integer(1), array[0]);
+    assertEquals(new Integer(2), array[1]);
+
+    
+    // Make sure the transient value is now null
+    assertNull(newBean.getTransient());
+
+    // Make sure the value binding looks the same, but is
+    // not actually the same instance
+    ValueBinding vb = newBean.getValueBinding(SubTypeBean.FIRST_KEY);
+    assertTrue(vb instanceof TestValueBinding);
+    assertTrue(vb != vb1);
+    assertEquals(vb.getValue(null), "vbFirst");
+    
+    // Now change the value binding, and verify the original
+    // bean is unchanged
+    vb.setValue(null, "changedVB");
+    assertEquals("changedVB", newBean.getFirst());
+    assertEquals("vbFirst", bean.getFirst());
+    
+    // Now, verify that if we mark the initial state and save, that we get
+    // a non-null value
+    newBean.markInitialState();
+    assertNull(newBean.saveState(null));
+    
+    // Now, we'll set a value, so we should get a non-null state
+    String oldFirst = newBean.getFirst();
+    newBean.setFirst("foo");
+    assertNotNull(newBean.saveState(null));
+  
+    // Our current delta support *does not* keep track of the original value.
+    // If it does, add this test
+//    newBean.setFirst(oldFirst);
+//    assertNull(newBean.saveState(null));
+  }
+
+  static private Object _copyObjectThroughSerialization(Object o)
+    throws IOException, ClassNotFoundException
+  {
+    ByteArrayOutputStream bos = new ByteArrayOutputStream();
+    ObjectOutputStream oos = new ObjectOutputStream(bos);
+    oos.writeObject(o);
+    oos.close();
+
+    byte[] byteArray = bos.toByteArray();
+    ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
+    ObjectInputStream ois = new ObjectInputStream(bis);
+
+    return ois.readObject();
+  }
+
+  private PropertyKey _thirdKey;
+}

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-api/src/test/java/org/apache/myfaces/adf/bean/FacesBeanImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message