Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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.trinidadinternal.share.data;
import java.util.Map;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
/**
* Class wrapping up access to parameters. This allows
* the values and contents of these parameters to be modified from their
* values in the HttpServletRequest
*
* @version $Name: $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/share/data/ServletRequestParameters.java#0 $) $Date: 10-nov-2005.19:00:16 $
*/
public class ServletRequestParameters extends RequestParameters
{
/**
* Flag parameter indicating that the request contains a
* compound name that has to be parsed.
*/
public static final String HAS_COMPOUND_NAME = "_compNm";
/**
* Returns a Map containing the modified parameters and
* keys for Map of input request parameters.
*
* If not modification is required the returned Dicitonary instance
* will be the requestParams
instance.
*/
public static Map createRequestMap(
Map requestParams
)
{
if (requestParams == null)
throw new IllegalArgumentException();
return _processParameters(requestParams,
requestParams.size());
}
/**
* Returns a request parameters object wrapping the parameters of
* a ServletRequest.
*/
public ServletRequestParameters(
Map requestParams
)
{
_params = createRequestMap(requestParams);
// clone returned String arrays
_cloneArrays = true;
}
/**
* Decodes key value pairs from a single value, placing the decoded
* values into the specified Map of String[]s. This code
* does not currently handle multiple values for the same key.
*
* adapted from org.apache.myfaces.trinidadinternal.uix22.servlet.url.DefaultPageEncoder
*/
public static void decodeCompoundKeyValues(
String compoundValue,
int startIndex,
Map keyValues
)
{
if (compoundValue == null)
return;
int index = startIndex - 1;
int endIndex = compoundValue.length();
// When submitting using an input type="image",
// a .x or .y is appended to the name of the input
// We want to remove this .x and .y before further processing
int xIndex = compoundValue.lastIndexOf(_DOT_X);
int yIndex = compoundValue.lastIndexOf(_DOT_Y);
int xyIndex = Math.max(xIndex, yIndex);
if ( xyIndex > -1)
{
// make sure this is not the .x of a user, which would have
// a boundary character after it.
if (compoundValue.substring(xyIndex + 1, endIndex).indexOf(_PROPERTY_BOUNDARY) < 0 )
endIndex = xyIndex;
}
while (index >= -1)
{
boolean fixEscapes = false;
// Find the start of the next property (or the end)
int nextIndex = compoundValue.indexOf(_PROPERTY_BOUNDARY,
index + 1);
// Search for any especially escaped characters
while ((nextIndex > 0) &&
(nextIndex < endIndex - 1))
{
char nextChar = compoundValue.charAt(nextIndex + 1);
if ((nextChar != _PROPERTY_BOUNDARY) && (nextChar != '='))
break;
fixEscapes = true;
nextIndex = compoundValue.indexOf(_PROPERTY_BOUNDARY,
nextIndex + 2);
}
if (nextIndex < 0)
nextIndex = endIndex;
// Find the '=' dividing the key and value
int equalsIndex = compoundValue.indexOf('=', index + 1);
while ((equalsIndex > 0) &&
(equalsIndex < nextIndex) &&
(compoundValue.charAt(equalsIndex - 1) == _PROPERTY_BOUNDARY))
{
equalsIndex = compoundValue.indexOf('=', equalsIndex + 1);
}
if ((equalsIndex >= nextIndex) || (equalsIndex < 0))
equalsIndex = nextIndex;
String key = compoundValue.substring(index + 1, equalsIndex);
String value;
if (equalsIndex == nextIndex)
value = "";
else
value = compoundValue.substring(equalsIndex + 1, nextIndex);
if (fixEscapes)
{
key = _decodeEscapes(key);
value = _decodeEscapes(value);
}
key = _decodeChars(key);
value = _decodeChars(value);
// add the key/value String[] pair to the Map
keyValues.put(key, new String[]{value});
if (nextIndex >= endIndex)
break;
index = nextIndex;
}
}
/**
* Encodes an Iterator key value pairs as a single value appended to
* the baseName, if any;
*/
public static String encodeCompoundKeyValues(
String namePrefix,
Iterator