You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by ma...@apache.org on 2006/07/25 04:42:46 UTC
svn commit: r425276 [5/12] - in
/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src:
main/java/org/apache/myfaces/adfinternal/agent/
main/java/org/apache/myfaces/adfinternal/agent/parse/
main/java/org/apache/myfaces/adfi...
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/bean/UIXFacesBeanImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/bean/UIXFacesBeanImpl.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/bean/UIXFacesBeanImpl.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/bean/UIXFacesBeanImpl.java Mon Jul 24 21:42:41 2006
@@ -1,41 +1,41 @@
-/*
- * Copyright 2005,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.adfinternal.bean;
-
-import org.apache.myfaces.adf.bean.FacesBeanImpl;
-import org.apache.myfaces.adf.component.UIXComponent;
-import org.apache.myfaces.adf.component.UIXFacesBean;
-
-public class UIXFacesBeanImpl extends FacesBeanImpl implements UIXFacesBean
-{
- public UIXFacesBeanImpl()
- {
- }
-
- public Type getType()
- {
- return _type;
- }
-
- public void init(
- UIXComponent component,
- Type type)
- {
- _type = type;
- }
-
- private Type _type;
+/*
+ * Copyright 2005,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.adfinternal.bean;
+
+import org.apache.myfaces.adf.bean.FacesBeanImpl;
+import org.apache.myfaces.adf.component.UIXComponent;
+import org.apache.myfaces.adf.component.UIXFacesBean;
+
+public class UIXFacesBeanImpl extends FacesBeanImpl implements UIXFacesBean
+{
+ public UIXFacesBeanImpl()
+ {
+ }
+
+ public Type getType()
+ {
+ return _type;
+ }
+
+ public void init(
+ UIXComponent component,
+ Type type)
+ {
+ _type = type;
+ }
+
+ private Type _type;
}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/bean/UIXFacesBeanImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/DialogServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/DialogServiceImpl.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/DialogServiceImpl.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/DialogServiceImpl.java Mon Jul 24 21:42:41 2006
@@ -1,17 +1,17 @@
-/*
- * 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.
+/*
+ * 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.adfinternal.context;
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/DialogServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/PageFlowScopeProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/PageFlowScopeProviderImpl.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/PageFlowScopeProviderImpl.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/PageFlowScopeProviderImpl.java Mon Jul 24 21:42:41 2006
@@ -1,17 +1,17 @@
-/*
- * Copyright 2006,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.
+/*
+ * Copyright 2006,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.adfinternal.context;
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/PageFlowScopeProviderImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/PageResolverDefaultImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/PageResolverDefaultImpl.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/PageResolverDefaultImpl.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/PageResolverDefaultImpl.java Mon Jul 24 21:42:41 2006
@@ -13,43 +13,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfinternal.context;
-
-import org.apache.myfaces.adf.context.PageResolver;
-
-/**
- * A default implementation of the page resolver that returns the view ID
- * as the physical page name.
- */
-public class PageResolverDefaultImpl extends PageResolver
-{
- static public PageResolver sharedInstance()
- {
- return _SHARED_INSTANCE;
- }
-
- private PageResolverDefaultImpl()
- {
- }
-
- /**
- * {@inheritDoc}
- * @param viewId {@inheritDoc}
- * @return {@inheritDoc}
- */
- public String getPhysicalURI(String viewId)
- {
- return viewId;
- }
-
- /**
- * Encodes an action URI.
- */
- public String encodeActionURI(String actionURI)
- {
- return actionURI;
- }
-
-
- static private PageResolver _SHARED_INSTANCE = new PageResolverDefaultImpl();
-}
+package org.apache.myfaces.adfinternal.context;
+
+import org.apache.myfaces.adf.context.PageResolver;
+
+/**
+ * A default implementation of the page resolver that returns the view ID
+ * as the physical page name.
+ */
+public class PageResolverDefaultImpl extends PageResolver
+{
+ static public PageResolver sharedInstance()
+ {
+ return _SHARED_INSTANCE;
+ }
+
+ private PageResolverDefaultImpl()
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ * @param viewId {@inheritDoc}
+ * @return {@inheritDoc}
+ */
+ public String getPhysicalURI(String viewId)
+ {
+ return viewId;
+ }
+
+ /**
+ * Encodes an action URI.
+ */
+ public String encodeActionURI(String actionURI)
+ {
+ return actionURI;
+ }
+
+
+ static private PageResolver _SHARED_INSTANCE = new PageResolverDefaultImpl();
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/context/PageResolverDefaultImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/BaseConverter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/BaseConverter.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/BaseConverter.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/BaseConverter.java Mon Jul 24 21:42:41 2006
@@ -13,74 +13,74 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfinternal.convert;
-
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-
-class BaseConverter extends GenericConverter
-{
- public BaseConverter()
- {
- }
-
- public Object convert(Object source, Class targetType)
- {
- if (source instanceof Calendar)
- {
- Calendar cal = (Calendar) source;
- return cal.getTime();
- }
- if (source instanceof Date)
- {
- Date date = (Date) source;
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- return cal;
- }
- // Source must be a Number
- Number num = (Number) source;
-
- // identity-equality is used since these are all final classes:
- if ((targetType == Integer.class) || (targetType == Integer.TYPE))
- return new Integer(num.intValue());
- if ((targetType == Byte.class) || (targetType == Byte.TYPE))
- return new Byte(num.byteValue());
- if ((targetType == Double.class) || (targetType == Double.TYPE))
- return new Double(num.doubleValue());
- if ((targetType == Float.class) || (targetType == Float.TYPE))
- return new Float(num.floatValue());
- if ((targetType == Long.class) || (targetType == Long.TYPE))
- return new Long(num.longValue());
- if ((targetType == Short.class) || (targetType == Short.TYPE))
- return new Short(num.shortValue());
-
- throw new IllegalArgumentException("Unsupported conversion from:"+
- source.getClass() + " to:"+targetType);
- }
-
- public List getTargetTypes(Class sourceType)
- {
- if (Date.class.isAssignableFrom(sourceType))
- {
- return Collections.singletonList(Calendar.class);
- }
- if (Calendar.class.isAssignableFrom(sourceType))
- {
- return Collections.singletonList(Date.class);
- }
- if (Number.class.isAssignableFrom(sourceType))
- {
- return Arrays.asList(new Class[] {
- Byte.class, Double.class, Float.class,
- Integer.class, Long.class, Short.class,
- Byte.TYPE, Double.TYPE, Float.TYPE, // bug 4891181
- Integer.TYPE, Long.TYPE, Short.TYPE}
- );
- }
- return Collections.EMPTY_LIST;
- }
-}
+package org.apache.myfaces.adfinternal.convert;
+
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+class BaseConverter extends GenericConverter
+{
+ public BaseConverter()
+ {
+ }
+
+ public Object convert(Object source, Class targetType)
+ {
+ if (source instanceof Calendar)
+ {
+ Calendar cal = (Calendar) source;
+ return cal.getTime();
+ }
+ if (source instanceof Date)
+ {
+ Date date = (Date) source;
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ return cal;
+ }
+ // Source must be a Number
+ Number num = (Number) source;
+
+ // identity-equality is used since these are all final classes:
+ if ((targetType == Integer.class) || (targetType == Integer.TYPE))
+ return new Integer(num.intValue());
+ if ((targetType == Byte.class) || (targetType == Byte.TYPE))
+ return new Byte(num.byteValue());
+ if ((targetType == Double.class) || (targetType == Double.TYPE))
+ return new Double(num.doubleValue());
+ if ((targetType == Float.class) || (targetType == Float.TYPE))
+ return new Float(num.floatValue());
+ if ((targetType == Long.class) || (targetType == Long.TYPE))
+ return new Long(num.longValue());
+ if ((targetType == Short.class) || (targetType == Short.TYPE))
+ return new Short(num.shortValue());
+
+ throw new IllegalArgumentException("Unsupported conversion from:"+
+ source.getClass() + " to:"+targetType);
+ }
+
+ public List getTargetTypes(Class sourceType)
+ {
+ if (Date.class.isAssignableFrom(sourceType))
+ {
+ return Collections.singletonList(Calendar.class);
+ }
+ if (Calendar.class.isAssignableFrom(sourceType))
+ {
+ return Collections.singletonList(Date.class);
+ }
+ if (Number.class.isAssignableFrom(sourceType))
+ {
+ return Arrays.asList(new Class[] {
+ Byte.class, Double.class, Float.class,
+ Integer.class, Long.class, Short.class,
+ Byte.TYPE, Double.TYPE, Float.TYPE, // bug 4891181
+ Integer.TYPE, Long.TYPE, Short.TYPE}
+ );
+ }
+ return Collections.EMPTY_LIST;
+ }
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/BaseConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ConvertException.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ConvertException.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ConvertException.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ConvertException.java Mon Jul 24 21:42:41 2006
@@ -13,23 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfinternal.convert;
-
-class ConvertException extends RuntimeException
-{
- public ConvertException(Object source, Class targetType, Throwable error)
- {
- super(_getMessage(source, targetType), error);
- }
-
- public ConvertException(Object source, Class targetType)
- {
- super(_getMessage(source, targetType));
- }
-
- private static String _getMessage(Object source, Class targetType)
- {
- return "Could not convert instance:"+source +
- " of type:"+source.getClass()+" into type:"+targetType;
- }
-}
+package org.apache.myfaces.adfinternal.convert;
+
+class ConvertException extends RuntimeException
+{
+ public ConvertException(Object source, Class targetType, Throwable error)
+ {
+ super(_getMessage(source, targetType), error);
+ }
+
+ public ConvertException(Object source, Class targetType)
+ {
+ super(_getMessage(source, targetType));
+ }
+
+ private static String _getMessage(Object source, Class targetType)
+ {
+ return "Could not convert instance:"+source +
+ " of type:"+source.getClass()+" into type:"+targetType;
+ }
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ConvertException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/GenericConverter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/GenericConverter.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/GenericConverter.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/GenericConverter.java Mon Jul 24 21:42:41 2006
@@ -13,32 +13,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfinternal.convert;
-
-import java.util.List;
-
-/**
- * This class is capable of converting
- * one Object into another.
- * A converter may be capable of converting a single Object into
- * many different types.
- * @author The Oracle ADF Faces Team
- */
-public abstract class GenericConverter
-{
- /**
- * converts the given Object into an instance of the
- * targetType.
- * @return an instance of the targetType.
- */
- public abstract Object convert(Object source, Class targetType);
-
- /**
- * Gets all the supported targetTypes for the given sourceType.
- * This converter must be able to convert the sourceType into each of the
- * supported targetTypes.
- * @return Each item is of type {@link Class}. An empty list must be
- * returned if the given sourceType cannot be converted into anything.
- */
- public abstract List getTargetTypes(Class sourceType);
-}
+package org.apache.myfaces.adfinternal.convert;
+
+import java.util.List;
+
+/**
+ * This class is capable of converting
+ * one Object into another.
+ * A converter may be capable of converting a single Object into
+ * many different types.
+ * @author The Oracle ADF Faces Team
+ */
+public abstract class GenericConverter
+{
+ /**
+ * converts the given Object into an instance of the
+ * targetType.
+ * @return an instance of the targetType.
+ */
+ public abstract Object convert(Object source, Class targetType);
+
+ /**
+ * Gets all the supported targetTypes for the given sourceType.
+ * This converter must be able to convert the sourceType into each of the
+ * supported targetTypes.
+ * @return Each item is of type {@link Class}. An empty list must be
+ * returned if the given sourceType cannot be converted into anything.
+ */
+ public abstract List getTargetTypes(Class sourceType);
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/GenericConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/GenericConverterFactory.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/GenericConverterFactory.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/GenericConverterFactory.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/GenericConverterFactory.java Mon Jul 24 21:42:41 2006
@@ -13,317 +13,317 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfinternal.convert;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A factory of GenericConverters.
- * GenericConverters may be registered with this factory.
- * The factory supports converting between the types supported
- * by each individual converter. The factory also supports converting
- * between types supported by combining individual converters.
- *
- * @author The Oracle ADF Faces Team
- */
-public class GenericConverterFactory
-{
- private GenericConverterFactory()
- {
- _converters = new ArrayList(3);
- registerConverter(new SqlConverter());
- registerConverter(new BaseConverter());
- }
-
- /**
- * Gets a converter that is capable of converting from the given
- * sourceType to the given targetType.
- * This method first searches to see if any of the registered converters
- * are capable of making this conversion alone. If one is found, it is
- * returned. Otherwise, this method will search to see if some combination
- * of registered converters can be used to perform this conversion.
- * If so, a composite converter will be returned.
- * <P>
- * The returned converter (or lack thereof) is cached so that subsequent
- * requests for the same source and target types will be fast.
- * @return null if there is no such converter.
- */
- public GenericConverter getConverter(Class sourceType, Class targetType)
- {
- Key key = new Key(sourceType, targetType);
- // check the cache first:
- Object cached = _cache.get(key);
- if (cached != null)
- {
- return (cached == _NULL) ? null : (GenericConverter) cached;
- }
-
- // we are going to start searching to see if some chain of converters
- // can be used to perform this conversion.
- // initial node in chain:
- Node start = new Node(null, null, sourceType);
- LinkedList sourcesToBeSearched = new LinkedList();
- sourcesToBeSearched.add(start);
- // cache to store all the classes we've tested already. This is to
- // avoid our chains from looping indefinitely:
- Set cache = new HashSet(16);
- GenericConverter converter = _findConverter(sourcesToBeSearched, targetType, cache);
- if (converter == null)
- {
- // cache the fact that no such converter exists:
- _cache.put(key, _NULL);
- }
- else
- {
- _cache.put(key, converter);
- }
-
- return converter;
- }
-
- /**
- * tries to find a converter, or create a chain of converters that can
- * convert from one of the given sourceTypes to the specified targetType.
- * @param sourcesToBeSearched each element is a Node. Each Node is a pairing of
- * sourceType and the chain of converters needed to produce this sourceType.
- * @param targetType the type that is needed
- * @param cache used to record which classes we've searched already.
- * @return null if no converter was found.
- */
- private GenericConverter _findConverter(
- LinkedList sourcesToBeSearched,
- Class targetType,
- Set cache)
- {
- while(!sourcesToBeSearched.isEmpty())
- {
- Node source = (Node) sourcesToBeSearched.removeFirst();
- // loop through all the converters and see what types they can turn
- // the current sourceType into
- // (the current sourceType is source.targetType):
- for(int j=0,jsz=_converters.size(); j<jsz; j++)
- {
- GenericConverter conv = (GenericConverter) _converters.get(j);
- // loop though all the targetTypes on this converter to see
- // if we can find the one we're looking for:
- if (_searchTargetTypes(sourcesToBeSearched, source, conv, targetType,
- cache))
- {
- // see if there is no chain:
- if (source.previous == null)
- return conv;
-
- // there is a chain:
- return new CompositeConverter(source, conv, targetType);
- }
- }
- }
- return null;
- }
-
- /**
- * Searches the targetTypes of the given converter to see if we
- * can find the type we are searching for.
- * @param sourcesToBeSearched each element is a Node. Each Node is a pairing of
- * sourceType and the chain of converters needed to produce this sourceType.
- * @param currentSource a chain of converters has been used to produce the
- * type identified by this Node. The targetType of this Node will be used
- * to search the currentConverter.
- * @param searchType the targetType we are searching for.
- * @param cache used to record which classes we've searched already.
- * @return true if the currentConverter can convert from
- * currentSource.targetType into searchType.
- */
- private boolean _searchTargetTypes(
- List sourcesToBeSearched,
- Node currentSource,
- GenericConverter currentConverter,
- Class searchType,
- Set cache)
- {
- Class sourceType = currentSource.targetType;
- List targetTypes = currentConverter.getTargetTypes(sourceType);
- for(int i=0,sz=targetTypes.size(); i<sz; i++)
- {
- Class targetType = (Class) targetTypes.get(i);
- // check to see if we've seen this targetType before:
- if (cache.add(targetType))
- {
- // check to see if the targetType is a subclass of the searchType:
- if (searchType.isAssignableFrom(targetType))
- return true;
-
- // create a new node in the chain by adding this targetType and converter
- Node newSource = new Node(currentSource, currentConverter, targetType);
-
- // add the new node so that we can continue searching by seeing if
- // we can convert the targetType into the searchType using some other
- // converter:
- sourcesToBeSearched.add(newSource);
- }
- }
- return false;
- }
-
- /**
- * Registers a converter. Registering a new converter causes the internal
- * cache to be cleared.
- */
- public void registerConverter(GenericConverter converter)
- {
- _converters.add(converter);
- _cache.clear();
- }
-
- /**
- * converts the given source instance into an object of the targetType.
- * @param source the object to convert
- * @param targetType the required type.
- * @return null, if the source is null.
- */
- public Object convert(Object source, Class targetType)
- {
- if (source == null)
- return null;
-
- if (targetType.isAssignableFrom(source.getClass()))
- return source;
-
- GenericConverter converter = getConverter(source.getClass(), targetType);
- if (converter != null)
- {
- return converter.convert(source, targetType);
- }
- throw new ConvertException(source, targetType);
- }
-
- /**
- * Checks to see if it is possible to convert the given instance
- * into the specified targetType
- * @return true if conversion is possible.
- */
- public boolean isConvertible(Object source, Class targetType)
- {
- if (source == null)
- return false; // bug 4589048
-
- if (targetType.isAssignableFrom(source.getClass()))
- return true;
-
- GenericConverter converter = getConverter(source.getClass(), targetType);
- return converter != null;
- }
-
- private final Map _cache = new HashMap(16);
- private final List _converters;
- private static final Object _NULL = Node.class; // reuse an object
-
- private static final class Node
- {
- public Node(Node previous, GenericConverter converter, Class targetType)
- {
- this.previous = previous;
- this.converter = converter;
- this.targetType = targetType;
- }
-
- public Object convert(Object source)
- {
- if (previous != null)
- {
- source = previous.convert(source);
- source = converter.convert(source, targetType);
- }
- return source;
- }
-
- public Class getSourceType()
- {
- if (previous == null)
- return targetType;
- return previous.getSourceType();
- }
-
- public final Node previous;
- public final GenericConverter converter;
- public final Class targetType;
- }
-
- private static final class Key
- {
- public Key(Class source, Class target)
- {
- assert !source.equals(target);
-
- _source = source;
- _target = target;
-
- _hc = source.hashCode() + target.hashCode();
- }
-
- public int hashCode()
- {
- return _hc;
- }
-
- public boolean equals(Object other)
- {
- if (this == other)
- return true;
- if (other instanceof Key)
- {
- Key that = (Key) other;
- return (_source.equals(that._source) && _target.equals(that._target));
- }
- return false;
- }
-
- private final int _hc;
- private final Class _source, _target;
- }
-
- private static final class CompositeConverter extends GenericConverter
- {
- public CompositeConverter(Node source, GenericConverter conv, Class targetType)
- {
- assert source != null;
- _chain = new Node(source, conv, targetType) ;
- }
-
- public Object convert(Object source, Class targetType)
- {
- if (targetType.isAssignableFrom(_chain.targetType))
- {
- return _chain.convert(source);
- }
- else
- throw new IllegalArgumentException("Cannot convert to:"+targetType);
- }
-
- public List getTargetTypes(Class sourceType)
- {
- if (_chain.getSourceType().isAssignableFrom(sourceType))
- {
- return Collections.singletonList(_chain.targetType);
- }
- return Collections.EMPTY_LIST;
- }
-
- private final Node _chain;
- }
-
- public static GenericConverterFactory getCurrentInstance()
- {
- return _INSTANCE;
- }
-
- private static final GenericConverterFactory _INSTANCE =
- new GenericConverterFactory();
-}
+package org.apache.myfaces.adfinternal.convert;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A factory of GenericConverters.
+ * GenericConverters may be registered with this factory.
+ * The factory supports converting between the types supported
+ * by each individual converter. The factory also supports converting
+ * between types supported by combining individual converters.
+ *
+ * @author The Oracle ADF Faces Team
+ */
+public class GenericConverterFactory
+{
+ private GenericConverterFactory()
+ {
+ _converters = new ArrayList(3);
+ registerConverter(new SqlConverter());
+ registerConverter(new BaseConverter());
+ }
+
+ /**
+ * Gets a converter that is capable of converting from the given
+ * sourceType to the given targetType.
+ * This method first searches to see if any of the registered converters
+ * are capable of making this conversion alone. If one is found, it is
+ * returned. Otherwise, this method will search to see if some combination
+ * of registered converters can be used to perform this conversion.
+ * If so, a composite converter will be returned.
+ * <P>
+ * The returned converter (or lack thereof) is cached so that subsequent
+ * requests for the same source and target types will be fast.
+ * @return null if there is no such converter.
+ */
+ public GenericConverter getConverter(Class sourceType, Class targetType)
+ {
+ Key key = new Key(sourceType, targetType);
+ // check the cache first:
+ Object cached = _cache.get(key);
+ if (cached != null)
+ {
+ return (cached == _NULL) ? null : (GenericConverter) cached;
+ }
+
+ // we are going to start searching to see if some chain of converters
+ // can be used to perform this conversion.
+ // initial node in chain:
+ Node start = new Node(null, null, sourceType);
+ LinkedList sourcesToBeSearched = new LinkedList();
+ sourcesToBeSearched.add(start);
+ // cache to store all the classes we've tested already. This is to
+ // avoid our chains from looping indefinitely:
+ Set cache = new HashSet(16);
+ GenericConverter converter = _findConverter(sourcesToBeSearched, targetType, cache);
+ if (converter == null)
+ {
+ // cache the fact that no such converter exists:
+ _cache.put(key, _NULL);
+ }
+ else
+ {
+ _cache.put(key, converter);
+ }
+
+ return converter;
+ }
+
+ /**
+ * tries to find a converter, or create a chain of converters that can
+ * convert from one of the given sourceTypes to the specified targetType.
+ * @param sourcesToBeSearched each element is a Node. Each Node is a pairing of
+ * sourceType and the chain of converters needed to produce this sourceType.
+ * @param targetType the type that is needed
+ * @param cache used to record which classes we've searched already.
+ * @return null if no converter was found.
+ */
+ private GenericConverter _findConverter(
+ LinkedList sourcesToBeSearched,
+ Class targetType,
+ Set cache)
+ {
+ while(!sourcesToBeSearched.isEmpty())
+ {
+ Node source = (Node) sourcesToBeSearched.removeFirst();
+ // loop through all the converters and see what types they can turn
+ // the current sourceType into
+ // (the current sourceType is source.targetType):
+ for(int j=0,jsz=_converters.size(); j<jsz; j++)
+ {
+ GenericConverter conv = (GenericConverter) _converters.get(j);
+ // loop though all the targetTypes on this converter to see
+ // if we can find the one we're looking for:
+ if (_searchTargetTypes(sourcesToBeSearched, source, conv, targetType,
+ cache))
+ {
+ // see if there is no chain:
+ if (source.previous == null)
+ return conv;
+
+ // there is a chain:
+ return new CompositeConverter(source, conv, targetType);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Searches the targetTypes of the given converter to see if we
+ * can find the type we are searching for.
+ * @param sourcesToBeSearched each element is a Node. Each Node is a pairing of
+ * sourceType and the chain of converters needed to produce this sourceType.
+ * @param currentSource a chain of converters has been used to produce the
+ * type identified by this Node. The targetType of this Node will be used
+ * to search the currentConverter.
+ * @param searchType the targetType we are searching for.
+ * @param cache used to record which classes we've searched already.
+ * @return true if the currentConverter can convert from
+ * currentSource.targetType into searchType.
+ */
+ private boolean _searchTargetTypes(
+ List sourcesToBeSearched,
+ Node currentSource,
+ GenericConverter currentConverter,
+ Class searchType,
+ Set cache)
+ {
+ Class sourceType = currentSource.targetType;
+ List targetTypes = currentConverter.getTargetTypes(sourceType);
+ for(int i=0,sz=targetTypes.size(); i<sz; i++)
+ {
+ Class targetType = (Class) targetTypes.get(i);
+ // check to see if we've seen this targetType before:
+ if (cache.add(targetType))
+ {
+ // check to see if the targetType is a subclass of the searchType:
+ if (searchType.isAssignableFrom(targetType))
+ return true;
+
+ // create a new node in the chain by adding this targetType and converter
+ Node newSource = new Node(currentSource, currentConverter, targetType);
+
+ // add the new node so that we can continue searching by seeing if
+ // we can convert the targetType into the searchType using some other
+ // converter:
+ sourcesToBeSearched.add(newSource);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Registers a converter. Registering a new converter causes the internal
+ * cache to be cleared.
+ */
+ public void registerConverter(GenericConverter converter)
+ {
+ _converters.add(converter);
+ _cache.clear();
+ }
+
+ /**
+ * converts the given source instance into an object of the targetType.
+ * @param source the object to convert
+ * @param targetType the required type.
+ * @return null, if the source is null.
+ */
+ public Object convert(Object source, Class targetType)
+ {
+ if (source == null)
+ return null;
+
+ if (targetType.isAssignableFrom(source.getClass()))
+ return source;
+
+ GenericConverter converter = getConverter(source.getClass(), targetType);
+ if (converter != null)
+ {
+ return converter.convert(source, targetType);
+ }
+ throw new ConvertException(source, targetType);
+ }
+
+ /**
+ * Checks to see if it is possible to convert the given instance
+ * into the specified targetType
+ * @return true if conversion is possible.
+ */
+ public boolean isConvertible(Object source, Class targetType)
+ {
+ if (source == null)
+ return false; // bug 4589048
+
+ if (targetType.isAssignableFrom(source.getClass()))
+ return true;
+
+ GenericConverter converter = getConverter(source.getClass(), targetType);
+ return converter != null;
+ }
+
+ private final Map _cache = new HashMap(16);
+ private final List _converters;
+ private static final Object _NULL = Node.class; // reuse an object
+
+ private static final class Node
+ {
+ public Node(Node previous, GenericConverter converter, Class targetType)
+ {
+ this.previous = previous;
+ this.converter = converter;
+ this.targetType = targetType;
+ }
+
+ public Object convert(Object source)
+ {
+ if (previous != null)
+ {
+ source = previous.convert(source);
+ source = converter.convert(source, targetType);
+ }
+ return source;
+ }
+
+ public Class getSourceType()
+ {
+ if (previous == null)
+ return targetType;
+ return previous.getSourceType();
+ }
+
+ public final Node previous;
+ public final GenericConverter converter;
+ public final Class targetType;
+ }
+
+ private static final class Key
+ {
+ public Key(Class source, Class target)
+ {
+ assert !source.equals(target);
+
+ _source = source;
+ _target = target;
+
+ _hc = source.hashCode() + target.hashCode();
+ }
+
+ public int hashCode()
+ {
+ return _hc;
+ }
+
+ public boolean equals(Object other)
+ {
+ if (this == other)
+ return true;
+ if (other instanceof Key)
+ {
+ Key that = (Key) other;
+ return (_source.equals(that._source) && _target.equals(that._target));
+ }
+ return false;
+ }
+
+ private final int _hc;
+ private final Class _source, _target;
+ }
+
+ private static final class CompositeConverter extends GenericConverter
+ {
+ public CompositeConverter(Node source, GenericConverter conv, Class targetType)
+ {
+ assert source != null;
+ _chain = new Node(source, conv, targetType) ;
+ }
+
+ public Object convert(Object source, Class targetType)
+ {
+ if (targetType.isAssignableFrom(_chain.targetType))
+ {
+ return _chain.convert(source);
+ }
+ else
+ throw new IllegalArgumentException("Cannot convert to:"+targetType);
+ }
+
+ public List getTargetTypes(Class sourceType)
+ {
+ if (_chain.getSourceType().isAssignableFrom(sourceType))
+ {
+ return Collections.singletonList(_chain.targetType);
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ private final Node _chain;
+ }
+
+ public static GenericConverterFactory getCurrentInstance()
+ {
+ return _INSTANCE;
+ }
+
+ private static final GenericConverterFactory _INSTANCE =
+ new GenericConverterFactory();
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/GenericConverterFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/NumberConverter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/NumberConverter.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/NumberConverter.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/NumberConverter.java Mon Jul 24 21:42:41 2006
@@ -13,50 +13,50 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfinternal.convert;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.ConverterException;
-
-public final class NumberConverter extends org.apache.myfaces.adf.convert.NumberConverter
-{
- public NumberConverter()
- {
- }
-
- public Object getAsObject(
- FacesContext context,
- UIComponent component,
- String value)
- throws ConverterException
- {
- Object number = super.getAsObject(context, component, value);
- if (number == null) // bug 4137626
- return null;
-
- // this is causing bug 4920160
- number =
- DateTimeConverter.__typeConvert(context, this, component, value, number);
- return number;
- }
-
- public String getAsString(
- FacesContext context,
- UIComponent component,
- Object value)
- throws ConverterException
- {
- if (value == null)
- return null;
-
- GenericConverterFactory fac = GenericConverterFactory.getCurrentInstance();
- // we support other types of numbers, like oracle.jbo.domain.Number:
- if ((!(value instanceof Number)) && fac.isConvertible(value, Number.class))
- {
- value = fac.convert(value, Number.class);
- }
- // bug 4214147:
- return super.getAsString(context, component, value);
- }
+package org.apache.myfaces.adfinternal.convert;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.ConverterException;
+
+public final class NumberConverter extends org.apache.myfaces.adf.convert.NumberConverter
+{
+ public NumberConverter()
+ {
+ }
+
+ public Object getAsObject(
+ FacesContext context,
+ UIComponent component,
+ String value)
+ throws ConverterException
+ {
+ Object number = super.getAsObject(context, component, value);
+ if (number == null) // bug 4137626
+ return null;
+
+ // this is causing bug 4920160
+ number =
+ DateTimeConverter.__typeConvert(context, this, component, value, number);
+ return number;
+ }
+
+ public String getAsString(
+ FacesContext context,
+ UIComponent component,
+ Object value)
+ throws ConverterException
+ {
+ if (value == null)
+ return null;
+
+ GenericConverterFactory fac = GenericConverterFactory.getCurrentInstance();
+ // we support other types of numbers, like oracle.jbo.domain.Number:
+ if ((!(value instanceof Number)) && fac.isConvertible(value, Number.class))
+ {
+ value = fac.convert(value, Number.class);
+ }
+ // bug 4214147:
+ return super.getAsString(context, component, value);
+ }
}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/NumberConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/SqlConverter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/SqlConverter.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/SqlConverter.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/SqlConverter.java Mon Jul 24 21:42:41 2006
@@ -13,54 +13,54 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfinternal.convert;
-
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * converter for the java.sql package
- */
-class SqlConverter extends GenericConverter
-{
- public SqlConverter()
- {
- }
-
- public Object convert(Object source, Class targetType)
- {
- java.util.Date jDate = (java.util.Date) source;
- if (targetType.isAssignableFrom(Date.class))
- {
- return new Date(jDate.getTime());
- }
- if (targetType.isAssignableFrom(Time.class))
- {
- return new Time(jDate.getTime());
- }
- if (targetType.isAssignableFrom(Timestamp.class))
- {
- return new Timestamp(jDate.getTime());
- }
- throw new ConvertException(source, targetType);
- }
-
- public List getTargetTypes(Class sourceType)
- {
- if (java.util.Date.class.isAssignableFrom(sourceType))
- {
- Class[] types = new Class[] {
- Date.class,
- Time.class,
- Timestamp.class
- };
- return Arrays.asList(types);
- }
- return Collections.EMPTY_LIST;
- }
-}
+package org.apache.myfaces.adfinternal.convert;
+
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * converter for the java.sql package
+ */
+class SqlConverter extends GenericConverter
+{
+ public SqlConverter()
+ {
+ }
+
+ public Object convert(Object source, Class targetType)
+ {
+ java.util.Date jDate = (java.util.Date) source;
+ if (targetType.isAssignableFrom(Date.class))
+ {
+ return new Date(jDate.getTime());
+ }
+ if (targetType.isAssignableFrom(Time.class))
+ {
+ return new Time(jDate.getTime());
+ }
+ if (targetType.isAssignableFrom(Timestamp.class))
+ {
+ return new Timestamp(jDate.getTime());
+ }
+ throw new ConvertException(source, targetType);
+ }
+
+ public List getTargetTypes(Class sourceType)
+ {
+ if (java.util.Date.class.isAssignableFrom(sourceType))
+ {
+ Class[] types = new Class[] {
+ Date.class,
+ Time.class,
+ Timestamp.class
+ };
+ return Arrays.asList(types);
+ }
+ return Collections.EMPTY_LIST;
+ }
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/convert/SqlConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/el/Tokenizer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/el/Tokenizer.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/el/Tokenizer.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/el/Tokenizer.java Mon Jul 24 21:42:41 2006
@@ -1,313 +1,313 @@
-/*
- * 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.adfinternal.el;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-
-/**
- * converts a EL expression into tokens.
- * @author The Oracle ADF Faces Team
- */
-public class Tokenizer implements Iterator
-{
- /**
- * Creates a new Tokenizer
- * @param expression the expression to tokenize
- */
- public Tokenizer(String expression)
- {
- _exp = expression;
- _curToken = _next();
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext()
- {
- return _curToken != null;
- }
-
- public Object next()
- {
- if (_curToken == null)
- throw new NoSuchElementException();
- Token tok = _curToken;
- _curToken = _next();
- return tok;
- }
-
- private Token _next()
- {
- int size = _exp.length();
- // if there are no more characters to consume then we cannot return any
- // tokens:
- if (_curIndex >= size)
- return null;
-
- final Token tok;
- // in the initial state everything is just text, and we are searching
- // for the beginning of an expression (searching for "#{" ):
- if (_state == _STATE_INIT)
- {
- int loc = _exp.indexOf("#{", _curIndex);
- if (loc < 0)
- {
- // if we do not find the beginning of an expression, then the entire
- // string is treated as one big text token:
- loc = size;
- }
- _state = _STATE_EXP_START;
- if (loc > _curIndex)
- {
- // there was some text before the beginning of the expression.
- // create a text token from that text:
- tok = new Token(TEXT_TYPE, _curIndex, loc);
- _curIndex = loc;
- }
- else
- {
- // there was no text before the beginning of the expression.
- // create a token for the expression-begin characters #{ :
- tok = _next();
- }
- }// _STATE_INIT
- else if (_state == _STATE_EXP_START)
- {
- // create a token for the expression-begin characters #{ :
- int end = _curIndex + 2; // skip over #{
- tok = new Token(EXP_START_TYPE, _curIndex, end);
- _curIndex = end;
- _state = _STATE_EXP;
- }
- else if (_state == _STATE_EXP)
- {
- // once we are inside an expression we can have:
- // 1. whitespace
- // 2. numbers
- // 3. alphas
- // 4. quotes
- // 5. operators
- // 6. end of expression character "}"
- int start = _curIndex;
- char ch = _exp.charAt(_curIndex++);
- if (Character.isWhitespace(ch))
- tok = _readWhiteSpace(start);
- else if (Character.isDigit(ch))
- tok = _readNumber(start);
- else if (Character.isJavaIdentifierStart(ch))
- tok = _readVar(start);
- else if ('}' == ch)
- {
- tok = new Token(EXP_END_TYPE, start, _curIndex);
- _state = _STATE_INIT;
- }
- else if (('"' == ch) || ('\'' == ch))
- tok = _readQuoted(start, ch);
- else // everything else is treated as an operator:
- tok = new Token(OPER_TYPE, start, _curIndex);
- } // _STATE_EXP
- else
- throw new AssertionError("invalid state:"+_state);
-
-
- return tok;
- }
-
- /**
- * creates a quote token.
- * @param start the start index of the quotation
- * @param quote the quote character that delimits this quotation.
- */
- private Token _readQuoted(int start, char quote)
- {
- // we start at start+1 since we want to skip over the starting
- // quotation delimiter:
- for(int end = start+1;;)
- {
- // search for the ending quotation character:
- end = _exp.indexOf(quote, end);
- if (end >= 0)
- {
- end++;
- // if the ending quotation character was preceded by a back-slash
- // then ignore it; it is escaped.
- if (_exp.charAt(end-2) == '\\')
- {
- continue;
- }
- _curIndex = end;
- return new Token(QUOTED_TYPE, start, end);
- }
- else
- throw _fatal("Cannot find matching quote", start);
- }
- }
-
- private RuntimeException _fatal(String message, int charPos)
- {
- return new IllegalArgumentException(message+". character position:"+charPos);
- }
-
- /**
- * Creates a token for variables
- * @param start the starting index of a variable usage
- */
- private Token _readVar(int start)
- {
- // we skip over the first character since we know that is an alpha already:
- for(int end=start+1;;)
- {
- // search for the end of this variable usage:
- end = _getLastLocOfAlpha(end);
- // if the variable was followed by a period, then append the next variable
- // as well, since this is part of a long dot separated variable usage like:
- // "a.b.c"
- if (_exp.charAt(end) == '.')
- end++;
- else
- {
- _curIndex = end;
- break;
- }
- }
- return new Token(VAR_TYPE, start, _curIndex);
- }
-
- private int _getLastLocOfAlpha(int start)
- {
- while(Character.isJavaIdentifierPart(_exp.charAt(start)))
- start++;
- return start;
- }
-
- /**
- * reads a number token.
- * @param start the starting index of a number
- */
- private Token _readNumber(int start)
- {
- // we can skip the first character since we know it is a number already:
- int end = _getLastLocOfDigit(start+1);
- // if this is a decimal number then append it to this token:
- if (_exp.charAt(end) == '.')
- end = _getLastLocOfDigit(end +1);
- _curIndex = end;
- return new Token(NUMBER_TYPE, start, end);
- }
-
-
- private int _getLastLocOfDigit(int start)
- {
- while(Character.isDigit(_exp.charAt(start)))
- start++;
- return start;
- }
-
- /**
- * creates a whitespace token
- * @param start the starting index of the first whitespace character
- */
- private Token _readWhiteSpace(int start)
- {
- while(Character.isWhitespace(_exp.charAt(_curIndex)))
- {
- _curIndex++;
- }
- return new Token(WHITE_SPACE_TYPE, start, _curIndex);
- }
-
- private final String _exp;
- private int _curIndex = 0;
- private int _state = _STATE_INIT;
- private Token _curToken = null;
-
- public final class Token
- {
- public final int type;
- private final int _start, _end;
-
- private Token(int type, int start, int end)
- {
- this.type = type;
- _start = start;
- _end = end;
- }
-
- public String getText()
- {
- return _exp.substring(_start, _end);
- }
- }
-
-
- private static final int _STATE_INIT = 100;
- private static final int _STATE_EXP_START = 200;
- private static final int _STATE_EXP = 300;
-
-
- /**
- * Identifies some plain text
- */
- public static final int TEXT_TYPE = 100;
-
- /**
- * Identifies the expression start string.
- * This string is two charaters long and is: "#{"
- */
- public static final int EXP_START_TYPE = 200;
-
- /**
- * Identifies the expression end character.
- * This is character is "}"
- */
- public static final int EXP_END_TYPE = 300;
-
- /**
- * Identifies a series of whitespace characters
- */
- public static final int WHITE_SPACE_TYPE = 400;
-
- /**
- * Identifies a quotation.
- * Eg: "quotation", 'quotation', 'he said, "foo!"' ,
- * "it's it".
- * More examples: "foo \" bar" , 'foo \' bar'
- */
- public static final int QUOTED_TYPE = 500;
-
- /**
- * Identifies a variable usage.
- * Eg: "row", "row.name", "foo.bar.baz"
- */
- public static final int VAR_TYPE = 600;
-
- /**
- * identifies a number
- * eg: "123", "321.321"
- */
- public static final int NUMBER_TYPE = 700;
-
- /**
- * Identifies an operator.
- * eg: ">", "[", "+", "?"
- */
- public static final int OPER_TYPE = 800;
-
+/*
+ * 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.adfinternal.el;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+
+/**
+ * converts a EL expression into tokens.
+ * @author The Oracle ADF Faces Team
+ */
+public class Tokenizer implements Iterator
+{
+ /**
+ * Creates a new Tokenizer
+ * @param expression the expression to tokenize
+ */
+ public Tokenizer(String expression)
+ {
+ _exp = expression;
+ _curToken = _next();
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasNext()
+ {
+ return _curToken != null;
+ }
+
+ public Object next()
+ {
+ if (_curToken == null)
+ throw new NoSuchElementException();
+ Token tok = _curToken;
+ _curToken = _next();
+ return tok;
+ }
+
+ private Token _next()
+ {
+ int size = _exp.length();
+ // if there are no more characters to consume then we cannot return any
+ // tokens:
+ if (_curIndex >= size)
+ return null;
+
+ final Token tok;
+ // in the initial state everything is just text, and we are searching
+ // for the beginning of an expression (searching for "#{" ):
+ if (_state == _STATE_INIT)
+ {
+ int loc = _exp.indexOf("#{", _curIndex);
+ if (loc < 0)
+ {
+ // if we do not find the beginning of an expression, then the entire
+ // string is treated as one big text token:
+ loc = size;
+ }
+ _state = _STATE_EXP_START;
+ if (loc > _curIndex)
+ {
+ // there was some text before the beginning of the expression.
+ // create a text token from that text:
+ tok = new Token(TEXT_TYPE, _curIndex, loc);
+ _curIndex = loc;
+ }
+ else
+ {
+ // there was no text before the beginning of the expression.
+ // create a token for the expression-begin characters #{ :
+ tok = _next();
+ }
+ }// _STATE_INIT
+ else if (_state == _STATE_EXP_START)
+ {
+ // create a token for the expression-begin characters #{ :
+ int end = _curIndex + 2; // skip over #{
+ tok = new Token(EXP_START_TYPE, _curIndex, end);
+ _curIndex = end;
+ _state = _STATE_EXP;
+ }
+ else if (_state == _STATE_EXP)
+ {
+ // once we are inside an expression we can have:
+ // 1. whitespace
+ // 2. numbers
+ // 3. alphas
+ // 4. quotes
+ // 5. operators
+ // 6. end of expression character "}"
+ int start = _curIndex;
+ char ch = _exp.charAt(_curIndex++);
+ if (Character.isWhitespace(ch))
+ tok = _readWhiteSpace(start);
+ else if (Character.isDigit(ch))
+ tok = _readNumber(start);
+ else if (Character.isJavaIdentifierStart(ch))
+ tok = _readVar(start);
+ else if ('}' == ch)
+ {
+ tok = new Token(EXP_END_TYPE, start, _curIndex);
+ _state = _STATE_INIT;
+ }
+ else if (('"' == ch) || ('\'' == ch))
+ tok = _readQuoted(start, ch);
+ else // everything else is treated as an operator:
+ tok = new Token(OPER_TYPE, start, _curIndex);
+ } // _STATE_EXP
+ else
+ throw new AssertionError("invalid state:"+_state);
+
+
+ return tok;
+ }
+
+ /**
+ * creates a quote token.
+ * @param start the start index of the quotation
+ * @param quote the quote character that delimits this quotation.
+ */
+ private Token _readQuoted(int start, char quote)
+ {
+ // we start at start+1 since we want to skip over the starting
+ // quotation delimiter:
+ for(int end = start+1;;)
+ {
+ // search for the ending quotation character:
+ end = _exp.indexOf(quote, end);
+ if (end >= 0)
+ {
+ end++;
+ // if the ending quotation character was preceded by a back-slash
+ // then ignore it; it is escaped.
+ if (_exp.charAt(end-2) == '\\')
+ {
+ continue;
+ }
+ _curIndex = end;
+ return new Token(QUOTED_TYPE, start, end);
+ }
+ else
+ throw _fatal("Cannot find matching quote", start);
+ }
+ }
+
+ private RuntimeException _fatal(String message, int charPos)
+ {
+ return new IllegalArgumentException(message+". character position:"+charPos);
+ }
+
+ /**
+ * Creates a token for variables
+ * @param start the starting index of a variable usage
+ */
+ private Token _readVar(int start)
+ {
+ // we skip over the first character since we know that is an alpha already:
+ for(int end=start+1;;)
+ {
+ // search for the end of this variable usage:
+ end = _getLastLocOfAlpha(end);
+ // if the variable was followed by a period, then append the next variable
+ // as well, since this is part of a long dot separated variable usage like:
+ // "a.b.c"
+ if (_exp.charAt(end) == '.')
+ end++;
+ else
+ {
+ _curIndex = end;
+ break;
+ }
+ }
+ return new Token(VAR_TYPE, start, _curIndex);
+ }
+
+ private int _getLastLocOfAlpha(int start)
+ {
+ while(Character.isJavaIdentifierPart(_exp.charAt(start)))
+ start++;
+ return start;
+ }
+
+ /**
+ * reads a number token.
+ * @param start the starting index of a number
+ */
+ private Token _readNumber(int start)
+ {
+ // we can skip the first character since we know it is a number already:
+ int end = _getLastLocOfDigit(start+1);
+ // if this is a decimal number then append it to this token:
+ if (_exp.charAt(end) == '.')
+ end = _getLastLocOfDigit(end +1);
+ _curIndex = end;
+ return new Token(NUMBER_TYPE, start, end);
+ }
+
+
+ private int _getLastLocOfDigit(int start)
+ {
+ while(Character.isDigit(_exp.charAt(start)))
+ start++;
+ return start;
+ }
+
+ /**
+ * creates a whitespace token
+ * @param start the starting index of the first whitespace character
+ */
+ private Token _readWhiteSpace(int start)
+ {
+ while(Character.isWhitespace(_exp.charAt(_curIndex)))
+ {
+ _curIndex++;
+ }
+ return new Token(WHITE_SPACE_TYPE, start, _curIndex);
+ }
+
+ private final String _exp;
+ private int _curIndex = 0;
+ private int _state = _STATE_INIT;
+ private Token _curToken = null;
+
+ public final class Token
+ {
+ public final int type;
+ private final int _start, _end;
+
+ private Token(int type, int start, int end)
+ {
+ this.type = type;
+ _start = start;
+ _end = end;
+ }
+
+ public String getText()
+ {
+ return _exp.substring(_start, _end);
+ }
+ }
+
+
+ private static final int _STATE_INIT = 100;
+ private static final int _STATE_EXP_START = 200;
+ private static final int _STATE_EXP = 300;
+
+
+ /**
+ * Identifies some plain text
+ */
+ public static final int TEXT_TYPE = 100;
+
+ /**
+ * Identifies the expression start string.
+ * This string is two charaters long and is: "#{"
+ */
+ public static final int EXP_START_TYPE = 200;
+
+ /**
+ * Identifies the expression end character.
+ * This is character is "}"
+ */
+ public static final int EXP_END_TYPE = 300;
+
+ /**
+ * Identifies a series of whitespace characters
+ */
+ public static final int WHITE_SPACE_TYPE = 400;
+
+ /**
+ * Identifies a quotation.
+ * Eg: "quotation", 'quotation', 'he said, "foo!"' ,
+ * "it's it".
+ * More examples: "foo \" bar" , 'foo \' bar'
+ */
+ public static final int QUOTED_TYPE = 500;
+
+ /**
+ * Identifies a variable usage.
+ * Eg: "row", "row.name", "foo.bar.baz"
+ */
+ public static final int VAR_TYPE = 600;
+
+ /**
+ * identifies a number
+ * eg: "123", "321.321"
+ */
+ public static final int NUMBER_TYPE = 700;
+
+ /**
+ * Identifies an operator.
+ * eg: ">", "[", "+", "?"
+ */
+ public static final int OPER_TYPE = 800;
+
}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/el/Tokenizer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/AdfComponentHandler.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/AdfComponentHandler.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/AdfComponentHandler.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/AdfComponentHandler.java Mon Jul 24 21:42:41 2006
@@ -13,75 +13,75 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfinternal.facelets;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.FaceletViewHandler;
-import com.sun.facelets.tag.jsf.ComponentHandler;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-
-import com.sun.facelets.tag.MetaRuleset;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-
-import org.apache.myfaces.adf.component.UIXComponent;
-
-/**
- * TagLibrary implementation for Oracle ADF core library.
- * @author Adam Winer
- * @version
- */
-public class AdfComponentHandler extends ComponentHandler
-{
- public AdfComponentHandler(ComponentConfig config)
- {
- super(config);
- if (_markInitialState == null)
- {
- // Can't imagine why this wouldn't always run during
- // a Faces request...
- FacesContext context = FacesContext.getCurrentInstance();
- if (context != null)
- {
- ExternalContext external = context.getExternalContext();
- String restoreMode = external.getInitParameter(
- FaceletViewHandler.PARAM_BUILD_BEFORE_RESTORE);
- if ("true".equals(restoreMode))
- _markInitialState = Boolean.TRUE;
- else
- _markInitialState = Boolean.FALSE;
- }
- }
- }
-
- protected MetaRuleset createMetaRuleset(Class type)
- {
- MetaRuleset m = super.createMetaRuleset(type);
-
- m.addRule(StringArrayPropertyTagRule.Instance);
- m.addRule(AdfListenersTagRule.Instance);
-
- return m;
- }
-
- protected void onComponentPopulated(FaceletContext context,
- UIComponent component,
- UIComponent parent)
- {
- assert (_markInitialState != null);
-
- if ((component instanceof UIXComponent) &&
- (_markInitialState == Boolean.TRUE))
- {
- if (component.getId() == null)
- component.setId(context.generateUniqueId(UIViewRoot.UNIQUE_ID_PREFIX));
-
- ((UIXComponent) component).markInitialState();
- }
- }
-
- static private Boolean _markInitialState;
-}
+package org.apache.myfaces.adfinternal.facelets;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.FaceletViewHandler;
+import com.sun.facelets.tag.jsf.ComponentHandler;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+
+import com.sun.facelets.tag.MetaRuleset;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.adf.component.UIXComponent;
+
+/**
+ * TagLibrary implementation for Oracle ADF core library.
+ * @author Adam Winer
+ * @version
+ */
+public class AdfComponentHandler extends ComponentHandler
+{
+ public AdfComponentHandler(ComponentConfig config)
+ {
+ super(config);
+ if (_markInitialState == null)
+ {
+ // Can't imagine why this wouldn't always run during
+ // a Faces request...
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (context != null)
+ {
+ ExternalContext external = context.getExternalContext();
+ String restoreMode = external.getInitParameter(
+ FaceletViewHandler.PARAM_BUILD_BEFORE_RESTORE);
+ if ("true".equals(restoreMode))
+ _markInitialState = Boolean.TRUE;
+ else
+ _markInitialState = Boolean.FALSE;
+ }
+ }
+ }
+
+ protected MetaRuleset createMetaRuleset(Class type)
+ {
+ MetaRuleset m = super.createMetaRuleset(type);
+
+ m.addRule(StringArrayPropertyTagRule.Instance);
+ m.addRule(AdfListenersTagRule.Instance);
+
+ return m;
+ }
+
+ protected void onComponentPopulated(FaceletContext context,
+ UIComponent component,
+ UIComponent parent)
+ {
+ assert (_markInitialState != null);
+
+ if ((component instanceof UIXComponent) &&
+ (_markInitialState == Boolean.TRUE))
+ {
+ if (component.getId() == null)
+ component.setId(context.generateUniqueId(UIViewRoot.UNIQUE_ID_PREFIX));
+
+ ((UIXComponent) component).markInitialState();
+ }
+ }
+
+ static private Boolean _markInitialState;
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/AdfComponentHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/AdfListenersTagRule.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/AdfListenersTagRule.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/AdfListenersTagRule.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/AdfListenersTagRule.java Mon Jul 24 21:42:41 2006
@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfinternal.facelets;
-
+package org.apache.myfaces.adfinternal.facelets;
+
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -29,110 +29,110 @@
import com.sun.facelets.tag.MetadataTarget;
import com.sun.facelets.tag.TagAttribute;
import com.sun.facelets.tag.TagAttributeException;
-
-/**
- *
- * @author Adam Winer
- * =-=AEW REWRITE USING BEANINFO
- */
-final class AdfListenersTagRule extends MetaRule
-{
- public static final MetaRule Instance = new AdfListenersTagRule();
-
- private static class ListenerPropertyMetadata extends Metadata
- {
- public ListenerPropertyMetadata(Method method, TagAttribute attribute, Class[] paramList)
- {
- _method = method;
- _attribute = attribute;
- _paramList = paramList;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance)
- {
- MethodExpression expr =
- _attribute.getMethodExpression(ctx, null, _paramList);
-
- try
- {
- _method.invoke(instance,
- new Object[]{new LegacyMethodBinding(expr)});
- }
- catch (InvocationTargetException e)
- {
- throw new TagAttributeException(_attribute, e.getCause());
- }
- catch (Exception e)
- {
- throw new TagAttributeException(_attribute, e);
- }
- }
-
- private final Method _method;
- private final TagAttribute _attribute;
- private Class[] _paramList;
- }
-
-
- public Metadata applyRule(
- String name,
- TagAttribute attribute,
- MetadataTarget meta)
- {
- if ((meta.getPropertyType(name) == MethodBinding.class) &&
- name.endsWith("Listener"))
- {
- // OK, we're trying to call setFooListener()
- Method m = meta.getWriteMethod(name);
- if (m != null)
- {
- // First, look for the getFooListeners() property
- PropertyDescriptor listeners = meta.getProperty(name + "s");
- if (listeners == null)
- return null;
-
- // It should return an array of FooListener objects
- Class arrayType = listeners.getPropertyType();
- if (!arrayType.isArray())
- return null;
-
- // Ignore non-ADF types
- Class listenerClass = arrayType.getComponentType();
- if (!listenerClass.getName().startsWith("org.apache.myfaces.adf."))
- return null;
-
- // Turn that into an Event to get the signature
- Class eventClass = _getEventClass(listenerClass);
- if (eventClass == null)
- return null;
-
- // And go
- return new ListenerPropertyMetadata(m, attribute,
- new Class[]{eventClass});
- }
- }
- return null;
- }
-
- static private Class _getEventClass(Class listenerClass)
- {
- String listenerName = listenerClass.getName();
- if (!listenerName.endsWith("Listener"))
- return null;
-
- String eventName = (listenerName.substring(0,
- listenerName.length() - "Listener".length()) +
- "Event");
-
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- try
- {
- return Class.forName(eventName, true, loader);
- }
- catch (ClassNotFoundException cnfe)
- {
- return null;
- }
- }
-}
+
+/**
+ *
+ * @author Adam Winer
+ * =-=AEW REWRITE USING BEANINFO
+ */
+final class AdfListenersTagRule extends MetaRule
+{
+ public static final MetaRule Instance = new AdfListenersTagRule();
+
+ private static class ListenerPropertyMetadata extends Metadata
+ {
+ public ListenerPropertyMetadata(Method method, TagAttribute attribute, Class[] paramList)
+ {
+ _method = method;
+ _attribute = attribute;
+ _paramList = paramList;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ MethodExpression expr =
+ _attribute.getMethodExpression(ctx, null, _paramList);
+
+ try
+ {
+ _method.invoke(instance,
+ new Object[]{new LegacyMethodBinding(expr)});
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TagAttributeException(_attribute, e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TagAttributeException(_attribute, e);
+ }
+ }
+
+ private final Method _method;
+ private final TagAttribute _attribute;
+ private Class[] _paramList;
+ }
+
+
+ public Metadata applyRule(
+ String name,
+ TagAttribute attribute,
+ MetadataTarget meta)
+ {
+ if ((meta.getPropertyType(name) == MethodBinding.class) &&
+ name.endsWith("Listener"))
+ {
+ // OK, we're trying to call setFooListener()
+ Method m = meta.getWriteMethod(name);
+ if (m != null)
+ {
+ // First, look for the getFooListeners() property
+ PropertyDescriptor listeners = meta.getProperty(name + "s");
+ if (listeners == null)
+ return null;
+
+ // It should return an array of FooListener objects
+ Class arrayType = listeners.getPropertyType();
+ if (!arrayType.isArray())
+ return null;
+
+ // Ignore non-ADF types
+ Class listenerClass = arrayType.getComponentType();
+ if (!listenerClass.getName().startsWith("org.apache.myfaces.adf."))
+ return null;
+
+ // Turn that into an Event to get the signature
+ Class eventClass = _getEventClass(listenerClass);
+ if (eventClass == null)
+ return null;
+
+ // And go
+ return new ListenerPropertyMetadata(m, attribute,
+ new Class[]{eventClass});
+ }
+ }
+ return null;
+ }
+
+ static private Class _getEventClass(Class listenerClass)
+ {
+ String listenerName = listenerClass.getName();
+ if (!listenerName.endsWith("Listener"))
+ return null;
+
+ String eventName = (listenerName.substring(0,
+ listenerName.length() - "Listener".length()) +
+ "Event");
+
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+ try
+ {
+ return Class.forName(eventName, true, loader);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ return null;
+ }
+ }
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/AdfListenersTagRule.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/StringArrayPropertyTagRule.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/StringArrayPropertyTagRule.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/StringArrayPropertyTagRule.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/facelets/StringArrayPropertyTagRule.java Mon Jul 24 21:42:41 2006
@@ -13,98 +13,98 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfinternal.facelets;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import java.util.ArrayList;
-import java.util.StringTokenizer;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.TagAttributeException;
-
-/**
- *
- * @author Adam Winer
- * @version $Id: StringArrayPropertyTagRule.java,v 1.1 2005/08/23 05:54:54 adamwiner Exp $
- */
-final class StringArrayPropertyTagRule extends MetaRule
-{
- public static final MetaRule Instance = new StringArrayPropertyTagRule();
-
- private static class LiteralPropertyMetadata extends Metadata
- {
- public LiteralPropertyMetadata(Method method, TagAttribute attribute)
- {
- _method = method;
- _attribute = attribute;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance)
- {
- if (_params == null)
- {
- String[] strArray = _coerceToStringArray(_attribute.getValue());
- _params = new Object[]{strArray};
- }
-
- try
- {
- _method.invoke(instance, _params);
- }
- catch (InvocationTargetException e)
- {
- throw new TagAttributeException(_attribute, e.getCause());
- }
- catch (Exception e)
- {
- throw new TagAttributeException(_attribute, e);
- }
- }
-
- private final Method _method;
- private final TagAttribute _attribute;
- private Object[] _params;
- }
-
-
- public Metadata applyRule(
- String name,
- TagAttribute attribute,
- MetadataTarget meta)
- {
- // Leave expressions to the underlying code
- if ((meta.getPropertyType(name) == _STRING_ARRAY_TYPE) &&
- attribute.isLiteral())
- {
- Method m = meta.getWriteMethod(name);
-
- // if the property is writable
- if (m != null)
- {
- return new LiteralPropertyMetadata(m, attribute);
- }
- }
- return null;
- }
-
- static private String[] _coerceToStringArray(String str)
- {
- if (str == null)
- return null;
-
- ArrayList list = new ArrayList();
- StringTokenizer tokens = new StringTokenizer(str);
- while (tokens.hasMoreTokens())
- list.add(tokens.nextToken());
- String[] strArray = new String[list.size()];
- return (String[]) list.toArray(strArray);
- }
-
- static private final Class _STRING_ARRAY_TYPE = (new String[0]).getClass();
-}
+package org.apache.myfaces.adfinternal.facelets;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagAttributeException;
+
+/**
+ *
+ * @author Adam Winer
+ * @version $Id: StringArrayPropertyTagRule.java,v 1.1 2005/08/23 05:54:54 adamwiner Exp $
+ */
+final class StringArrayPropertyTagRule extends MetaRule
+{
+ public static final MetaRule Instance = new StringArrayPropertyTagRule();
+
+ private static class LiteralPropertyMetadata extends Metadata
+ {
+ public LiteralPropertyMetadata(Method method, TagAttribute attribute)
+ {
+ _method = method;
+ _attribute = attribute;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ if (_params == null)
+ {
+ String[] strArray = _coerceToStringArray(_attribute.getValue());
+ _params = new Object[]{strArray};
+ }
+
+ try
+ {
+ _method.invoke(instance, _params);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TagAttributeException(_attribute, e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TagAttributeException(_attribute, e);
+ }
+ }
+
+ private final Method _method;
+ private final TagAttribute _attribute;
+ private Object[] _params;
+ }
+
+
+ public Metadata applyRule(
+ String name,
+ TagAttribute attribute,
+ MetadataTarget meta)
+ {
+ // Leave expressions to the underlying code
+ if ((meta.getPropertyType(name) == _STRING_ARRAY_TYPE) &&
+ attribute.isLiteral())
+ {
+ Method m = meta.getWriteMethod(name);
+
+ // if the property is writable
+ if (m != null)
+ {
+ return new LiteralPropertyMetadata(m, attribute);
+ }
+ }
+ return null;
+ }
+
+ static private String[] _coerceToStringArray(String str)
+ {
+ if (str == null)
+ return null;
+
+ ArrayList list = new ArrayList();
+ StringTokenizer tokens = new StringTokenizer(str);
+ while (tokens.hasMoreTokens())
+ list.add(tokens.nextToken());
+ String[] strArray = new String[list.size()];
+ return (String[]) list.toArray(strArray);
+ }
+
+ static private final Class _STRING_ARRAY_TYPE = (new String[0]).getClass();
+}