You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2012/03/30 20:04:08 UTC
svn commit: r1307561 - in
/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared:
renderkit/ renderkit/html/ resource/ util/ util/io/ util/renderkit/
Author: lu4242
Date: Fri Mar 30 18:04:07 2012
New Revision: 1307561
URL: http://svn.apache.org/viewvc?rev=1307561&view=rev
Log:
update shared from latest code in myfaces core
Modified:
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/ContentTypeUtils.java
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMessageRendererBase.java
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ValueExpressionFilterInputStream.java
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/AttachedDeltaWrapper.java (props changed)
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/ComponentUtils.java (props changed)
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/ConcurrentLRUCache.java (props changed)
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/DebugUtils.java (props changed)
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/PriorityQueue.java (props changed)
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/RendererUtils.java (props changed)
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/TagUtils.java (props changed)
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/io/DynamicPushbackInputStream.java
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/renderkit/ (props changed)
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/renderkit/ClientBehaviorEvents.java (props changed)
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/renderkit/HTML.java (props changed)
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/renderkit/JsfProperties.java (props changed)
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/ContentTypeUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/ContentTypeUtils.java?rev=1307561&r1=1307560&r2=1307561&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/ContentTypeUtils.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/ContentTypeUtils.java Fri Mar 30 18:04:07 2012
@@ -1,136 +1,136 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.shared.renderkit;
-
-import javax.faces.context.FacesContext;
-
-import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
-import org.apache.myfaces.shared.util.StringUtils;
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-public class ContentTypeUtils
-{
- public static final String HTML_CONTENT_TYPE = "text/html";
- public static final String TEXT_ANY_CONTENT_TYPE = "text/*";
- public static final String ANY_CONTENT_TYPE = "*/*";
-
- public static final String[] HTML_ALLOWED_CONTENT_TYPES = {HTML_CONTENT_TYPE,
- ANY_CONTENT_TYPE, TEXT_ANY_CONTENT_TYPE};
-
- public static final String XHTML_CONTENT_TYPE = "application/xhtml+xml";
- public static final String APPLICATION_XML_CONTENT_TYPE = "application/xml";
- public static final String TEXT_XML_CONTENT_TYPE = "text/xml";
-
- public static final String[] XHTML_ALLOWED_CONTENT_TYPES = {XHTML_CONTENT_TYPE,
- APPLICATION_XML_CONTENT_TYPE, TEXT_XML_CONTENT_TYPE};
-
- public static final String[] AJAX_XHTML_ALLOWED_CONTENT_TYPES = {XHTML_CONTENT_TYPE};
-
-
- /**
- * Indicate if the passes content type match one of the options passed.
- */
- public static boolean containsContentType(String contentType, String[] allowedContentTypes)
- {
- if (allowedContentTypes == null)
- {
- return false;
- }
- for (int i = 0; i < allowedContentTypes.length; i++)
- {
- if (allowedContentTypes[i].indexOf(contentType) != -1)
- {
- return true;
- }
- }
- return false;
- }
-
- public static String chooseWriterContentType(String contentTypeListString,
- String[] htmlContentTypes, String[] xhtmlContentTypes)
- {
- String[] contentTypeList = splitContentTypeListString(contentTypeListString);
- String[] supportedContentTypeArray = HtmlRendererUtils.getSupportedContentTypes();
- String selectedContentType = null;
- for (int i = 0; i < supportedContentTypeArray.length; i++)
- {
- String supportedContentType = supportedContentTypeArray[i].trim();
-
- for (int j = 0; j < contentTypeList.length; j++)
- {
- String contentType = (String) contentTypeList[j];
-
- if (contentType.indexOf(supportedContentType) != -1)
- {
- if (containsContentType(contentType, htmlContentTypes))
- {
- selectedContentType = HTML_CONTENT_TYPE;
- }
- else if (containsContentType(contentType, xhtmlContentTypes))
- {
- selectedContentType = XHTML_CONTENT_TYPE;
- }
- break;
- }
- }
- if (selectedContentType != null)
- {
- break;
- }
- }
- return selectedContentType;
- }
-
- public static String[] splitContentTypeListString(String contentTypeListString)
- {
- String[] splittedArray = StringUtils.splitShortString(contentTypeListString, ',');
- for (int i = 0; i < splittedArray.length; i++)
- {
- int semicolonIndex = splittedArray[i].indexOf(";");
- if (semicolonIndex != -1)
- {
- splittedArray[i] = splittedArray[i].substring(0,semicolonIndex);
- }
- }
- return splittedArray;
- }
-
- public static String getContentTypeFromAcceptHeader(FacesContext context)
- {
- String contentTypeListString = (String) context.getExternalContext()
- .getRequestHeaderMap().get("Accept");
- // There is a windows mobile IE client (6.12) sending
- // "application/vnd.wap.mms-message;*/*"
- // Note that the Accept header should be written as
- // "application/vnd.wap.mms-message,*/*" ,
- // so this is bug of the client. Anyway, this is a workaround ...
- if (contentTypeListString != null
- && contentTypeListString
- .startsWith("application/vnd.wap.mms-message;*/*"))
- {
- contentTypeListString = "*/*";
- }
- return contentTypeListString;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.shared.renderkit;
+
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.shared.util.StringUtils;
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public class ContentTypeUtils
+{
+ public static final String HTML_CONTENT_TYPE = "text/html";
+ public static final String TEXT_ANY_CONTENT_TYPE = "text/*";
+ public static final String ANY_CONTENT_TYPE = "*/*";
+
+ public static final String[] HTML_ALLOWED_CONTENT_TYPES = {HTML_CONTENT_TYPE,
+ ANY_CONTENT_TYPE, TEXT_ANY_CONTENT_TYPE};
+
+ public static final String XHTML_CONTENT_TYPE = "application/xhtml+xml";
+ public static final String APPLICATION_XML_CONTENT_TYPE = "application/xml";
+ public static final String TEXT_XML_CONTENT_TYPE = "text/xml";
+
+ public static final String[] XHTML_ALLOWED_CONTENT_TYPES = {XHTML_CONTENT_TYPE,
+ APPLICATION_XML_CONTENT_TYPE, TEXT_XML_CONTENT_TYPE};
+
+ public static final String[] AJAX_XHTML_ALLOWED_CONTENT_TYPES = {XHTML_CONTENT_TYPE};
+
+
+ /**
+ * Indicate if the passes content type match one of the options passed.
+ */
+ public static boolean containsContentType(String contentType, String[] allowedContentTypes)
+ {
+ if (allowedContentTypes == null)
+ {
+ return false;
+ }
+ for (int i = 0; i < allowedContentTypes.length; i++)
+ {
+ if (allowedContentTypes[i].indexOf(contentType) != -1)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static String chooseWriterContentType(String contentTypeListString,
+ String[] htmlContentTypes, String[] xhtmlContentTypes)
+ {
+ String[] contentTypeList = splitContentTypeListString(contentTypeListString);
+ String[] supportedContentTypeArray = HtmlRendererUtils.getSupportedContentTypes();
+ String selectedContentType = null;
+ for (int i = 0; i < supportedContentTypeArray.length; i++)
+ {
+ String supportedContentType = supportedContentTypeArray[i].trim();
+
+ for (int j = 0; j < contentTypeList.length; j++)
+ {
+ String contentType = (String) contentTypeList[j];
+
+ if (contentType.indexOf(supportedContentType) != -1)
+ {
+ if (containsContentType(contentType, htmlContentTypes))
+ {
+ selectedContentType = HTML_CONTENT_TYPE;
+ }
+ else if (containsContentType(contentType, xhtmlContentTypes))
+ {
+ selectedContentType = XHTML_CONTENT_TYPE;
+ }
+ break;
+ }
+ }
+ if (selectedContentType != null)
+ {
+ break;
+ }
+ }
+ return selectedContentType;
+ }
+
+ public static String[] splitContentTypeListString(String contentTypeListString)
+ {
+ String[] splittedArray = StringUtils.splitShortString(contentTypeListString, ',');
+ for (int i = 0; i < splittedArray.length; i++)
+ {
+ int semicolonIndex = splittedArray[i].indexOf(";");
+ if (semicolonIndex != -1)
+ {
+ splittedArray[i] = splittedArray[i].substring(0,semicolonIndex);
+ }
+ }
+ return splittedArray;
+ }
+
+ public static String getContentTypeFromAcceptHeader(FacesContext context)
+ {
+ String contentTypeListString = (String) context.getExternalContext()
+ .getRequestHeaderMap().get("Accept");
+ // There is a windows mobile IE client (6.12) sending
+ // "application/vnd.wap.mms-message;*/*"
+ // Note that the Accept header should be written as
+ // "application/vnd.wap.mms-message,*/*" ,
+ // so this is bug of the client. Anyway, this is a workaround ...
+ if (contentTypeListString != null
+ && contentTypeListString
+ .startsWith("application/vnd.wap.mms-message;*/*"))
+ {
+ contentTypeListString = "*/*";
+ }
+ return contentTypeListString;
+ }
+
+}
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMessageRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMessageRendererBase.java?rev=1307561&r1=1307560&r2=1307561&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMessageRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMessageRendererBase.java Fri Mar 30 18:04:07 2012
@@ -226,6 +226,8 @@ public abstract class HtmlMessageRendere
(facesContext.getExternalContext()))
{
behaviors = ((ClientBehaviorHolder) message).getClientBehaviors();
+ // If there is a behavior registered, force wrapSpan
+ wrapSpan = wrapSpan || !behaviors.isEmpty();
}
if ( wrapSpan )
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java?rev=1307561&r1=1307560&r2=1307561&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java Fri Mar 30 18:04:07 2012
@@ -2150,9 +2150,11 @@ public final class HtmlRendererUtils
boolean submitting1 = getClientBehaviorScript(facesContext,
uiComponent, targetClientId, eventName1, clientBehaviors,
behaviorCode, params);
+ ScriptContext behaviorCode2 = new ScriptContext();
boolean submitting2 = getClientBehaviorScript(facesContext,
uiComponent, targetClientId, eventName2, clientBehaviors,
- behaviorCode, params2);
+ behaviorCode2, params2);
+
// ClientBehaviors for both events have to be checked for the Submitting hint
boolean submitting = submitting1 || submitting2;
if (behaviorCode != null
@@ -2160,6 +2162,11 @@ public final class HtmlRendererUtils
{
finalParams.add(behaviorCode.toString());
}
+ if (behaviorCode2 != null
+ && !behaviorCode2.toString().trim().equals(STR_EMPTY))
+ {
+ finalParams.add(behaviorCode2.toString());
+ }
if (serverEventCode != null
&& !serverEventCode.trim().equals(STR_EMPTY))
{
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java?rev=1307561&r1=1307560&r2=1307561&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java Fri Mar 30 18:04:07 2012
@@ -327,6 +327,29 @@ public class HtmlTableRendererBase exten
}
}
+ private Integer[] getBodyRows(FacesContext facesContext, UIComponent component)
+ {
+ Integer[] bodyrows = null;
+ String bodyrowsAttr = (String) component.getAttributes().get(JSFAttr.BODYROWS_ATTR);
+ if(bodyrowsAttr != null && !"".equals(bodyrowsAttr))
+ {
+ String[] bodyrowsString = StringUtils.trim(StringUtils.splitShortString(bodyrowsAttr, ','));
+ // parsing with no exception handling, because of JSF-spec:
+ // "If present, this must be a comma separated list of integers."
+ bodyrows = new Integer[bodyrowsString.length];
+ for(int i = 0; i < bodyrowsString.length; i++)
+ {
+ bodyrows[i] = new Integer(bodyrowsString[i]);
+ }
+
+ }
+ else
+ {
+ bodyrows = ZERO_INT_ARRAY;
+ }
+ return bodyrows;
+ }
+
/**
* Renders everything inside the TBODY tag by iterating over the row objects
* between offsets first and first+rows and applying the UIColumn components
@@ -337,12 +360,19 @@ public class HtmlTableRendererBase exten
*/
public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException
{
-
UIData uiData = (UIData) component;
ResponseWriter writer = facesContext.getResponseWriter();
int rowCount = uiData.getRowCount();
+ int newspaperColumns = getNewspaperColumns(component);
+
+ if (rowCount == -1 && newspaperColumns == 1)
+ {
+ encodeInnerHtmlUnknownRowCount(facesContext, component);
+ return;
+ }
+
if (rowCount == 0)
{
//nothing to render, to get valid xhtml we render an empty dummy row
@@ -377,7 +407,6 @@ public class HtmlTableRendererBase exten
}
}
- int newspaperColumns = getNewspaperColumns(component);
int newspaperRows;
if((last - first) % newspaperColumns == 0)
{
@@ -390,24 +419,7 @@ public class HtmlTableRendererBase exten
boolean newspaperHorizontalOrientation = isNewspaperHorizontalOrientation(component);
// get the row indizes for which a new TBODY element should be created
- Integer[] bodyrows = null;
- String bodyrowsAttr = (String) component.getAttributes().get(JSFAttr.BODYROWS_ATTR);
- if(bodyrowsAttr != null && !"".equals(bodyrowsAttr))
- {
- String[] bodyrowsString = StringUtils.trim(StringUtils.splitShortString(bodyrowsAttr, ','));
- // parsing with no exception handling, because of JSF-spec:
- // "If present, this must be a comma separated list of integers."
- bodyrows = new Integer[bodyrowsString.length];
- for(int i = 0; i < bodyrowsString.length; i++)
- {
- bodyrows[i] = new Integer(bodyrowsString[i]);
- }
-
- }
- else
- {
- bodyrows = ZERO_INT_ARRAY;
- }
+ Integer[] bodyrows = getBodyRows(facesContext, component);
int bodyrowsCount = 0;
// walk through the newspaper rows
@@ -520,6 +532,113 @@ public class HtmlTableRendererBase exten
writer.endElement(HTML.TBODY_ELEM);
}
}
+
+ private void encodeInnerHtmlUnknownRowCount(FacesContext facesContext, UIComponent component)throws IOException
+ {
+ UIData uiData = (UIData) component;
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ Styles styles = getStyles(uiData);
+
+ Integer[] bodyrows = getBodyRows(facesContext, component);
+ int bodyrowsCount = 0;
+
+ int first = uiData.getFirst();
+ int rows = uiData.getRows();
+ int currentRow = first;
+ boolean isRowRendered = false;
+
+ while(true)
+ {
+ uiData.setRowIndex(currentRow);
+ if (!uiData.isRowAvailable())
+ {
+ break;
+ }
+
+ isRowRendered = true;
+
+ // first column in table, start new row
+ beforeRow(facesContext, uiData);
+
+ // is the current row listed in the bodyrows attribute
+ if(ArrayUtils.contains(bodyrows, currentRow))
+ {
+ // close any preopened TBODY element first
+ if(bodyrowsCount != 0)
+ {
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+ writer.endElement(HTML.TBODY_ELEM);
+ }
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+ writer.startElement(HTML.TBODY_ELEM, uiData);
+ // Do not attach bodyrowsCount to the first TBODY element, because of backward compatibility
+ writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext) + ":tbody_element" +
+ (bodyrowsCount == 0 ? "" : bodyrowsCount), null);
+ bodyrowsCount++;
+ }
+
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+ renderRowStart(facesContext, writer, uiData, styles, currentRow);
+
+ List<UIComponent> children = null;
+ for (int j = 0, size = getChildCount(component); j < size; j++)
+ {
+ if (children == null)
+ {
+ children = getChildren(component);
+ }
+ UIComponent child = (UIComponent) children.get(j);
+ if (child.isRendered())
+ {
+ boolean columnRendering = child instanceof UIColumn;
+
+ if (columnRendering)
+ {
+ beforeColumn(facesContext, uiData, j);
+ }
+
+ encodeColumnChild(facesContext, writer, uiData, child,
+ styles, j);
+
+ if (columnRendering)
+ {
+ afterColumn(facesContext, uiData, j);
+ }
+ }
+ }
+
+ renderRowEnd(facesContext, writer, uiData);
+ afterRow(facesContext, uiData);
+
+ currentRow++;
+
+ if (rows > 0 && currentRow-first > rows )
+ {
+ break;
+ }
+ }
+
+ if (!isRowRendered)
+ {
+ //nothing to render, to get valid xhtml we render an empty dummy row
+ writer.startElement(HTML.TBODY_ELEM, uiData);
+ writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext) + ":tbody_element", null);
+ writer.startElement(HTML.TR_ELEM, uiData);
+ writer.startElement(HTML.TD_ELEM, uiData);
+ writer.endElement(HTML.TD_ELEM);
+ writer.endElement(HTML.TR_ELEM);
+ writer.endElement(HTML.TBODY_ELEM);
+ return;
+ }
+
+ if(bodyrowsCount != 0)
+ {
+ // close the last TBODY element
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+ writer.endElement(HTML.TBODY_ELEM);
+ }
+ }
protected void encodeColumnChild(FacesContext facesContext, ResponseWriter writer,
UIData uiData, UIComponent component, Styles styles, int columnStyleIndex) throws IOException
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java?rev=1307561&r1=1307560&r2=1307561&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java Fri Mar 30 18:04:07 2012
@@ -1,100 +1,100 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.shared.resource;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Comparator;
-
-import javax.faces.FacesWrapper;
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-public abstract class ResourceLoaderWrapper extends ResourceLoader implements FacesWrapper<ResourceLoader>
-{
-
- public ResourceLoaderWrapper()
- {
- super(null);
- }
-
- public String getResourceVersion(String path)
- {
- return getWrapped().getResourceVersion(path);
- }
-
- public String getLibraryVersion(String path)
- {
- return getWrapped().getLibraryVersion(path);
- }
-
- public URL getResourceURL(ResourceMeta resourceMeta)
- {
- return getWrapped().getResourceURL(resourceMeta);
- }
-
- public InputStream getResourceInputStream(ResourceMeta resourceMeta)
- {
- return getWrapped().getResourceInputStream(resourceMeta);
- }
-
- public ResourceMeta createResourceMeta(String prefix, String libraryName,
- String libraryVersion, String resourceName, String resourceVersion)
- {
- return getWrapped().createResourceMeta(prefix, libraryName, libraryVersion,
- resourceName, resourceVersion);
- }
-
- public boolean libraryExists(String libraryName)
- {
- return getWrapped().libraryExists(libraryName);
- }
-
- public String getPrefix()
- {
- return getWrapped().getPrefix();
- }
-
- public void setPrefix(String prefix)
- {
- getWrapped().setPrefix(prefix);
- }
-
- @Override
- public boolean resourceExists(ResourceMeta resourceMeta)
- {
- return getWrapped().resourceExists(resourceMeta);
- }
-
- @Override
- protected Comparator<String> getVersionComparator()
- {
- return getWrapped().getVersionComparator();
- }
-
- @Override
- protected void setVersionComparator(Comparator<String> versionComparator)
- {
- getWrapped().setVersionComparator(versionComparator);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.shared.resource;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Comparator;
+
+import javax.faces.FacesWrapper;
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public abstract class ResourceLoaderWrapper extends ResourceLoader implements FacesWrapper<ResourceLoader>
+{
+
+ public ResourceLoaderWrapper()
+ {
+ super(null);
+ }
+
+ public String getResourceVersion(String path)
+ {
+ return getWrapped().getResourceVersion(path);
+ }
+
+ public String getLibraryVersion(String path)
+ {
+ return getWrapped().getLibraryVersion(path);
+ }
+
+ public URL getResourceURL(ResourceMeta resourceMeta)
+ {
+ return getWrapped().getResourceURL(resourceMeta);
+ }
+
+ public InputStream getResourceInputStream(ResourceMeta resourceMeta)
+ {
+ return getWrapped().getResourceInputStream(resourceMeta);
+ }
+
+ public ResourceMeta createResourceMeta(String prefix, String libraryName,
+ String libraryVersion, String resourceName, String resourceVersion)
+ {
+ return getWrapped().createResourceMeta(prefix, libraryName, libraryVersion,
+ resourceName, resourceVersion);
+ }
+
+ public boolean libraryExists(String libraryName)
+ {
+ return getWrapped().libraryExists(libraryName);
+ }
+
+ public String getPrefix()
+ {
+ return getWrapped().getPrefix();
+ }
+
+ public void setPrefix(String prefix)
+ {
+ getWrapped().setPrefix(prefix);
+ }
+
+ @Override
+ public boolean resourceExists(ResourceMeta resourceMeta)
+ {
+ return getWrapped().resourceExists(resourceMeta);
+ }
+
+ @Override
+ protected Comparator<String> getVersionComparator()
+ {
+ return getWrapped().getVersionComparator();
+ }
+
+ @Override
+ protected void setVersionComparator(Comparator<String> versionComparator)
+ {
+ getWrapped().setVersionComparator(versionComparator);
+ }
+
+}
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java?rev=1307561&r1=1307560&r2=1307561&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java Fri Mar 30 18:04:07 2012
@@ -1,199 +1,199 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.shared.resource;
-
-public class ResourceValidationUtils
-{
- public static boolean isValidResourceName(String resourceName)
- {
- return validateResourceName(resourceName, true);
- }
-
- public static boolean isValidLibraryName(String libraryName)
- {
- return validate(libraryName, false);
- }
-
- public static boolean isValidLibraryName(String libraryName, boolean allowSlash)
- {
- return validate(libraryName, allowSlash);
- }
-
- public static boolean isValidLocalePrefix(String localePrefix)
- {
- for (int i = 0; i < localePrefix.length(); i++)
- {
- char c = localePrefix.charAt(i);
- if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') || (c >='0' && c <='9') )
- {
- continue;
- }
- else
- {
- return false;
- }
- }
- return true;
- }
-
- private static boolean validate(String expression, boolean allowSlash)
- {
- if (expression.length() == 2 &&
- expression.charAt(0) == '.' &&
- expression.charAt(1) == '.')
- {
- return false;
- }
- for (int i = 0; i < expression.length(); i++)
- {
- char c = expression.charAt(i);
-
- // Enforce NameChar convention as specified
- // http://www.w3.org/TR/REC-xml/#NT-NameChar
- // Valid characters for NameChar
- // ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
- // [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] |
- // [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF]
- // | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
- // "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
- // Excluding ":"
- if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') ||
- (c >=0xC0 && c <=0xD6) || (c >=0xD8 && c <=0xF6) ||
- (c >=0xF8 && c <=0x2FF) || (c >=0x370 && c <=0x37D) ||
- (c >=0x37F && c <=0x1FFF) || (c >=0x200C && c <=0x200D) ||
- (c >=0x2070 && c <=0x218F) || (c >=0x2C00 && c <=0x2FEF) ||
- (c >=0x3001 && c <=0xD7FF) || (c >=0xF900 && c <=0xFDCF) ||
- (c >=0xFDF0 && c <=0xFFFD) || (c >=0x10000 && c <=0xEFFFF) ||
- c == '-' || (c >='0' && c <='9') || c == 0xB7 || (c >=0x300 && c <=0x36F) ||
- (c >=0x203F && c <=0x2040) || (allowSlash && c == '/')
- )
- {
- continue;
- }
- else if (c == '.')
- {
- if (i+2 < expression.length())
- {
- char c1 = expression.charAt(i+1);
- char c2 = expression.charAt(i+2);
- if (c == c1 && (c2 == '/' || c2 == '\\' ) )
- {
- return false;
- }
- }
- continue;
- }
- else
- {
- return false;
- }
- }
- if (expression.length() >= 3)
- {
- int length = expression.length();
- if ( (expression.charAt(length-3) == '/' || expression.charAt(length-3) == '\\' ) &&
- expression.charAt(length-2) == '.' &&
- expression.charAt(length-1) == '.' )
- {
- return false;
- }
- }
- return true;
- }
-
- private static boolean validateResourceName(String expression, boolean allowSlash)
- {
- if (expression.length() == 2 &&
- expression.charAt(0) == '.' &&
- expression.charAt(1) == '.')
- {
- return false;
- }
- for (int i = 0; i < expression.length(); i++)
- {
- char c = expression.charAt(i);
-
- // Enforce NameChar convention as specified
- // http://www.w3.org/TR/REC-xml/#NT-NameChar
- // Valid characters for NameChar
- // ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
- // [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] |
- // [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF]
- // | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
- // "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
- // Excluding ":"
-
- // Forbidden chars by win
- // < (less than)
- // > (greater than)
- // : (colon)
- // " (double quote)
- // / (forward slash)
- // \ (backslash)
- // | (vertical bar or pipe)
- // ? (question mark)
- // * (asterisk)
- // Do not use chars in UNIX because they have special meaning
- // *&%$|^/\~
- if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') ||
- (c >=0xC0 && c <=0xD6) || (c >=0xD8 && c <=0xF6) ||
- (c >=0xF8 && c <=0x2FF) || (c >=0x370 && c <=0x37D) ||
- (c >=0x37F && c <=0x1FFF) || (c >=0x200C && c <=0x200D) ||
- (c >=0x2070 && c <=0x218F) || (c >=0x2C00 && c <=0x2FEF) ||
- (c >=0x3001 && c <=0xD7FF) || (c >=0xF900 && c <=0xFDCF) ||
- (c >=0xFDF0 && c <=0xFFFD) || (c >=0x10000 && c <=0xEFFFF) ||
- (c == '-') || (c >='0' && c <='9') || c == 0xB7 || (c >=0x300 && c <=0x36F) ||
- (c >=0x203F && c <=0x2040) || (allowSlash && c == '/') ||
- (c == '!') || (c == '#') || (c == '\'') || (c == '(') || (c == ')') ||
- (c == '+') || (c == ',') || (c == ';' ) || (c == '=') ||
- (c == '@') || (c == '[') || (c == ']' ) || (c == '{') || (c == '}'))
- {
- continue;
- }
- else if (c == '.')
- {
- if (i+2 < expression.length())
- {
- char c1 = expression.charAt(i+1);
- char c2 = expression.charAt(i+2);
- if (c == c1 && (c2 == '/' || c2 == '\\' ) )
- {
- return false;
- }
- }
- continue;
- }
- else
- {
- return false;
- }
- }
- if (expression.length() >= 3)
- {
- int length = expression.length();
- if ( (expression.charAt(length-3) == '/' || expression.charAt(length-3) == '\\' ) &&
- expression.charAt(length-2) == '.' &&
- expression.charAt(length-1) == '.' )
- {
- return false;
- }
- }
- return true;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.shared.resource;
+
+public class ResourceValidationUtils
+{
+ public static boolean isValidResourceName(String resourceName)
+ {
+ return validateResourceName(resourceName, true);
+ }
+
+ public static boolean isValidLibraryName(String libraryName)
+ {
+ return validate(libraryName, false);
+ }
+
+ public static boolean isValidLibraryName(String libraryName, boolean allowSlash)
+ {
+ return validate(libraryName, allowSlash);
+ }
+
+ public static boolean isValidLocalePrefix(String localePrefix)
+ {
+ for (int i = 0; i < localePrefix.length(); i++)
+ {
+ char c = localePrefix.charAt(i);
+ if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') || (c >='0' && c <='9') )
+ {
+ continue;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean validate(String expression, boolean allowSlash)
+ {
+ if (expression.length() == 2 &&
+ expression.charAt(0) == '.' &&
+ expression.charAt(1) == '.')
+ {
+ return false;
+ }
+ for (int i = 0; i < expression.length(); i++)
+ {
+ char c = expression.charAt(i);
+
+ // Enforce NameChar convention as specified
+ // http://www.w3.org/TR/REC-xml/#NT-NameChar
+ // Valid characters for NameChar
+ // ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
+ // [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] |
+ // [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF]
+ // | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
+ // "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
+ // Excluding ":"
+ if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') ||
+ (c >=0xC0 && c <=0xD6) || (c >=0xD8 && c <=0xF6) ||
+ (c >=0xF8 && c <=0x2FF) || (c >=0x370 && c <=0x37D) ||
+ (c >=0x37F && c <=0x1FFF) || (c >=0x200C && c <=0x200D) ||
+ (c >=0x2070 && c <=0x218F) || (c >=0x2C00 && c <=0x2FEF) ||
+ (c >=0x3001 && c <=0xD7FF) || (c >=0xF900 && c <=0xFDCF) ||
+ (c >=0xFDF0 && c <=0xFFFD) || (c >=0x10000 && c <=0xEFFFF) ||
+ c == '-' || (c >='0' && c <='9') || c == 0xB7 || (c >=0x300 && c <=0x36F) ||
+ (c >=0x203F && c <=0x2040) || (allowSlash && c == '/')
+ )
+ {
+ continue;
+ }
+ else if (c == '.')
+ {
+ if (i+2 < expression.length())
+ {
+ char c1 = expression.charAt(i+1);
+ char c2 = expression.charAt(i+2);
+ if (c == c1 && (c2 == '/' || c2 == '\\' ) )
+ {
+ return false;
+ }
+ }
+ continue;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ if (expression.length() >= 3)
+ {
+ int length = expression.length();
+ if ( (expression.charAt(length-3) == '/' || expression.charAt(length-3) == '\\' ) &&
+ expression.charAt(length-2) == '.' &&
+ expression.charAt(length-1) == '.' )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean validateResourceName(String expression, boolean allowSlash)
+ {
+ if (expression.length() == 2 &&
+ expression.charAt(0) == '.' &&
+ expression.charAt(1) == '.')
+ {
+ return false;
+ }
+ for (int i = 0; i < expression.length(); i++)
+ {
+ char c = expression.charAt(i);
+
+ // Enforce NameChar convention as specified
+ // http://www.w3.org/TR/REC-xml/#NT-NameChar
+ // Valid characters for NameChar
+ // ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
+ // [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] |
+ // [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF]
+ // | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
+ // "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
+ // Excluding ":"
+
+ // Forbidden chars by win
+ // < (less than)
+ // > (greater than)
+ // : (colon)
+ // " (double quote)
+ // / (forward slash)
+ // \ (backslash)
+ // | (vertical bar or pipe)
+ // ? (question mark)
+ // * (asterisk)
+ // Do not use chars in UNIX because they have special meaning
+ // *&%$|^/\~
+ if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') ||
+ (c >=0xC0 && c <=0xD6) || (c >=0xD8 && c <=0xF6) ||
+ (c >=0xF8 && c <=0x2FF) || (c >=0x370 && c <=0x37D) ||
+ (c >=0x37F && c <=0x1FFF) || (c >=0x200C && c <=0x200D) ||
+ (c >=0x2070 && c <=0x218F) || (c >=0x2C00 && c <=0x2FEF) ||
+ (c >=0x3001 && c <=0xD7FF) || (c >=0xF900 && c <=0xFDCF) ||
+ (c >=0xFDF0 && c <=0xFFFD) || (c >=0x10000 && c <=0xEFFFF) ||
+ (c == '-') || (c >='0' && c <='9') || c == 0xB7 || (c >=0x300 && c <=0x36F) ||
+ (c >=0x203F && c <=0x2040) || (allowSlash && c == '/') ||
+ (c == '!') || (c == '#') || (c == '\'') || (c == '(') || (c == ')') ||
+ (c == '+') || (c == ',') || (c == ';' ) || (c == '=') ||
+ (c == '@') || (c == '[') || (c == ']' ) || (c == '{') || (c == '}'))
+ {
+ continue;
+ }
+ else if (c == '.')
+ {
+ if (i+2 < expression.length())
+ {
+ char c1 = expression.charAt(i+1);
+ char c2 = expression.charAt(i+2);
+ if (c == c1 && (c2 == '/' || c2 == '\\' ) )
+ {
+ return false;
+ }
+ }
+ continue;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ if (expression.length() >= 3)
+ {
+ int length = expression.length();
+ if ( (expression.charAt(length-3) == '/' || expression.charAt(length-3) == '\\' ) &&
+ expression.charAt(length-2) == '.' &&
+ expression.charAt(length-1) == '.' )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+}
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ValueExpressionFilterInputStream.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ValueExpressionFilterInputStream.java?rev=1307561&r1=1307560&r2=1307561&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ValueExpressionFilterInputStream.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ValueExpressionFilterInputStream.java Fri Mar 30 18:04:07 2012
@@ -1,168 +1,168 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.shared.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.ValueExpression;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ExceptionQueuedEvent;
-import javax.faces.event.ExceptionQueuedEventContext;
-
-import org.apache.myfaces.shared.util.io.DynamicPushbackInputStream;
-
-public class ValueExpressionFilterInputStream extends InputStream
-{
- private PushbackInputStream delegate;
- private String libraryName;
- private String resourceName;
-
- public ValueExpressionFilterInputStream(InputStream in, String libraryName, String resourceName)
- {
- super();
- delegate = new DynamicPushbackInputStream(in,300);
- }
-
- @Override
- public int read() throws IOException
- {
- int c1 = delegate.read();
-
- if (c1 == -1)
- {
- return -1;
- }
-
- if ( ((char)c1) == '#')
- {
- int c2 = delegate.read();
- if (c2 == -1)
- {
- return -1;
- }
- if (((char)c2) == '{')
- {
- //It is a value expression. We need
- //to look for a occurrence of } to
- //extract the expression and evaluate it,
- //the result should be unread.
- List<Integer> expressionList = new ArrayList<Integer>();
- int c3 = delegate.read();
- while ( c3 != -1 && ((char)c3) != '}' )
- {
- expressionList.add(c3);
- c3 = delegate.read();
- }
-
- if (c3 == -1)
- {
- //get back the data, because we can't
- //extract any value expression
- for (int i = 0; i < expressionList.size(); i++)
- {
- delegate.unread(expressionList.get(i));
- }
- delegate.unread(c2);
- return c1;
- }
- else
- {
- //EL expression found. Evaluate it and pushback
- //the result into the stream
- FacesContext context = FacesContext.getCurrentInstance();
- ELContext elContext = context.getELContext();
- try
- {
- ValueExpression ve = context.getApplication().
- getExpressionFactory().createValueExpression(
- elContext,
- "#{"+convertToExpression(expressionList)+"}",
- String.class);
- String value = (String) ve.getValue(elContext);
-
- for (int i = value.length()-1; i >= 0 ; i--)
- {
- delegate.unread((int) value.charAt(i));
- }
- }
- catch(ELException e)
- {
- ExceptionQueuedEventContext equecontext = new ExceptionQueuedEventContext (
- context, e, null);
- context.getApplication().publishEvent (context, ExceptionQueuedEvent.class, equecontext);
-
- Logger log = Logger.getLogger(ResourceImpl.class.getName());
- if (log.isLoggable(Level.SEVERE))
- {
- log.severe("Cannot evaluate EL expression " + convertToExpression(expressionList)
- + " in resource " + (libraryName == null?"":libraryName) + ":" +
- (resourceName == null?"":resourceName));
- }
-
- delegate.unread(c3);
- for (int i = expressionList.size()-1; i >= 0; i--)
- {
- delegate.unread(expressionList.get(i));
- }
- delegate.unread(c2);
- return c1;
- }
-
- //read again
- return delegate.read();
- }
- }
- else
- {
- delegate.unread(c2);
- return c1;
- }
- }
- else
- {
- //just continue
- return c1;
- }
- }
-
- private String convertToExpression(List<Integer> expressionList)
- {
- char[] exprArray = new char[expressionList.size()];
-
- for (int i = 0; i < expressionList.size(); i++)
- {
- exprArray[i] = (char) expressionList.get(i).intValue();
- }
- return String.valueOf(exprArray);
- }
-
- @Override
- public void close() throws IOException
- {
- delegate.close();
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.shared.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ExceptionQueuedEvent;
+import javax.faces.event.ExceptionQueuedEventContext;
+
+import org.apache.myfaces.shared.util.io.DynamicPushbackInputStream;
+
+public class ValueExpressionFilterInputStream extends InputStream
+{
+ private PushbackInputStream delegate;
+ private String libraryName;
+ private String resourceName;
+
+ public ValueExpressionFilterInputStream(InputStream in, String libraryName, String resourceName)
+ {
+ super();
+ delegate = new DynamicPushbackInputStream(in,300);
+ }
+
+ @Override
+ public int read() throws IOException
+ {
+ int c1 = delegate.read();
+
+ if (c1 == -1)
+ {
+ return -1;
+ }
+
+ if ( ((char)c1) == '#')
+ {
+ int c2 = delegate.read();
+ if (c2 == -1)
+ {
+ return -1;
+ }
+ if (((char)c2) == '{')
+ {
+ //It is a value expression. We need
+ //to look for a occurrence of } to
+ //extract the expression and evaluate it,
+ //the result should be unread.
+ List<Integer> expressionList = new ArrayList<Integer>();
+ int c3 = delegate.read();
+ while ( c3 != -1 && ((char)c3) != '}' )
+ {
+ expressionList.add(c3);
+ c3 = delegate.read();
+ }
+
+ if (c3 == -1)
+ {
+ //get back the data, because we can't
+ //extract any value expression
+ for (int i = 0; i < expressionList.size(); i++)
+ {
+ delegate.unread(expressionList.get(i));
+ }
+ delegate.unread(c2);
+ return c1;
+ }
+ else
+ {
+ //EL expression found. Evaluate it and pushback
+ //the result into the stream
+ FacesContext context = FacesContext.getCurrentInstance();
+ ELContext elContext = context.getELContext();
+ try
+ {
+ ValueExpression ve = context.getApplication().
+ getExpressionFactory().createValueExpression(
+ elContext,
+ "#{"+convertToExpression(expressionList)+"}",
+ String.class);
+ String value = (String) ve.getValue(elContext);
+
+ for (int i = value.length()-1; i >= 0 ; i--)
+ {
+ delegate.unread((int) value.charAt(i));
+ }
+ }
+ catch(ELException e)
+ {
+ ExceptionQueuedEventContext equecontext = new ExceptionQueuedEventContext (
+ context, e, null);
+ context.getApplication().publishEvent (context, ExceptionQueuedEvent.class, equecontext);
+
+ Logger log = Logger.getLogger(ResourceImpl.class.getName());
+ if (log.isLoggable(Level.SEVERE))
+ {
+ log.severe("Cannot evaluate EL expression " + convertToExpression(expressionList)
+ + " in resource " + (libraryName == null?"":libraryName) + ":" +
+ (resourceName == null?"":resourceName));
+ }
+
+ delegate.unread(c3);
+ for (int i = expressionList.size()-1; i >= 0; i--)
+ {
+ delegate.unread(expressionList.get(i));
+ }
+ delegate.unread(c2);
+ return c1;
+ }
+
+ //read again
+ return delegate.read();
+ }
+ }
+ else
+ {
+ delegate.unread(c2);
+ return c1;
+ }
+ }
+ else
+ {
+ //just continue
+ return c1;
+ }
+ }
+
+ private String convertToExpression(List<Integer> expressionList)
+ {
+ char[] exprArray = new char[expressionList.size()];
+
+ for (int i = 0; i < expressionList.size(); i++)
+ {
+ exprArray[i] = (char) expressionList.get(i).intValue();
+ }
+ return String.valueOf(exprArray);
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ delegate.close();
+ }
+}
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/AttachedDeltaWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/ComponentUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/ConcurrentLRUCache.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/DebugUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/PriorityQueue.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/RendererUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/TagUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/io/DynamicPushbackInputStream.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/io/DynamicPushbackInputStream.java?rev=1307561&r1=1307560&r2=1307561&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/io/DynamicPushbackInputStream.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/io/DynamicPushbackInputStream.java Fri Mar 30 18:04:07 2012
@@ -1,154 +1,154 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.shared.util.io;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-
-/**
- * NOTE: Copy of org.apache.abdera.i18n.text.io.DynamicPushbackInputStream
- *
- * PushbackInputStream implementation that performs dynamic resizing of the unread buffer
- */
-public class DynamicPushbackInputStream extends PushbackInputStream
-{
-
- private final int origsize;
-
- public DynamicPushbackInputStream(InputStream in)
- {
- super(in);
- this.origsize = 1;
- }
-
- public DynamicPushbackInputStream(InputStream in, int initialSize)
- {
- super(in, initialSize);
- this.origsize = initialSize;
- }
-
- /**
- * Clear the buffer
- */
- public int clear()
- {
- int m = buf.length;
- buf = new byte[origsize];
- pos = origsize;
- return m;
- }
-
- /**
- * Shrink the buffer. This will reclaim currently unused space in the buffer, reducing memory but potentially
- * increasing the cost of resizing the buffer
- */
- public int shrink()
- {
- byte[] old = buf;
- if (pos == 0)
- {
- return 0; // nothing to do
- }
- int n = old.length - pos;
- int m;
- int p;
- int s;
- int l;
- if (n < origsize)
- {
- buf = new byte[origsize];
- p = pos;
- s = origsize - n;
- l = old.length - p;
- m = old.length - origsize;
- pos = s;
- }
- else
- {
- buf = new byte[n];
- p = pos;
- s = 0;
- l = n;
- m = old.length - l;
- pos = 0;
- }
- System.arraycopy(old, p, buf, s, l);
- return m;
- }
-
- private void resize(int len)
- {
- byte[] old = buf;
- buf = new byte[old.length + len];
- System.arraycopy(old, 0, buf, len, old.length);
- }
-
- public void unread(byte[] b, int off, int len) throws IOException
- {
- if (len > pos && pos + len > buf.length)
- {
- resize(len - pos);
- pos += len - pos;
- }
- super.unread(b, off, len);
- }
-
- public void unread(int b) throws IOException
- {
- if (pos == 0)
- {
- resize(1);
- pos++;
- }
- super.unread(b);
- }
-
- public int read() throws IOException
- {
- int m = super.read();
- if (pos >= buf.length && buf.length > origsize)
- {
- shrink();
- }
- return m;
- }
-
- public int read(byte[] b, int off, int len) throws IOException
- {
- this.available(); // workaround for a problem in PushbackInputStream, without this, the amount of bytes read
- // from some streams will be incorrect
- int r = super.read(b, off, len);
- if (pos >= buf.length && buf.length > origsize)
- {
- shrink();
- }
- return r;
- }
-
- public long skip(long n) throws IOException
- {
- long r = super.skip(n);
- if (pos >= buf.length && buf.length > origsize)
- {
- shrink();
- }
- return r;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.shared.util.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+
+/**
+ * NOTE: Copy of org.apache.abdera.i18n.text.io.DynamicPushbackInputStream
+ *
+ * PushbackInputStream implementation that performs dynamic resizing of the unread buffer
+ */
+public class DynamicPushbackInputStream extends PushbackInputStream
+{
+
+ private final int origsize;
+
+ public DynamicPushbackInputStream(InputStream in)
+ {
+ super(in);
+ this.origsize = 1;
+ }
+
+ public DynamicPushbackInputStream(InputStream in, int initialSize)
+ {
+ super(in, initialSize);
+ this.origsize = initialSize;
+ }
+
+ /**
+ * Clear the buffer
+ */
+ public int clear()
+ {
+ int m = buf.length;
+ buf = new byte[origsize];
+ pos = origsize;
+ return m;
+ }
+
+ /**
+ * Shrink the buffer. This will reclaim currently unused space in the buffer, reducing memory but potentially
+ * increasing the cost of resizing the buffer
+ */
+ public int shrink()
+ {
+ byte[] old = buf;
+ if (pos == 0)
+ {
+ return 0; // nothing to do
+ }
+ int n = old.length - pos;
+ int m;
+ int p;
+ int s;
+ int l;
+ if (n < origsize)
+ {
+ buf = new byte[origsize];
+ p = pos;
+ s = origsize - n;
+ l = old.length - p;
+ m = old.length - origsize;
+ pos = s;
+ }
+ else
+ {
+ buf = new byte[n];
+ p = pos;
+ s = 0;
+ l = n;
+ m = old.length - l;
+ pos = 0;
+ }
+ System.arraycopy(old, p, buf, s, l);
+ return m;
+ }
+
+ private void resize(int len)
+ {
+ byte[] old = buf;
+ buf = new byte[old.length + len];
+ System.arraycopy(old, 0, buf, len, old.length);
+ }
+
+ public void unread(byte[] b, int off, int len) throws IOException
+ {
+ if (len > pos && pos + len > buf.length)
+ {
+ resize(len - pos);
+ pos += len - pos;
+ }
+ super.unread(b, off, len);
+ }
+
+ public void unread(int b) throws IOException
+ {
+ if (pos == 0)
+ {
+ resize(1);
+ pos++;
+ }
+ super.unread(b);
+ }
+
+ public int read() throws IOException
+ {
+ int m = super.read();
+ if (pos >= buf.length && buf.length > origsize)
+ {
+ shrink();
+ }
+ return m;
+ }
+
+ public int read(byte[] b, int off, int len) throws IOException
+ {
+ this.available(); // workaround for a problem in PushbackInputStream, without this, the amount of bytes read
+ // from some streams will be incorrect
+ int r = super.read(b, off, len);
+ if (pos >= buf.length && buf.length > origsize)
+ {
+ shrink();
+ }
+ return r;
+ }
+
+ public long skip(long n) throws IOException
+ {
+ long r = super.skip(n);
+ if (pos >= buf.length && buf.length > origsize)
+ {
+ shrink();
+ }
+ return r;
+ }
+}
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/renderkit/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/renderkit/ClientBehaviorEvents.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/renderkit/HTML.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/renderkit/JsfProperties.java
------------------------------------------------------------------------------
svn:eol-style = native