示例#1
0
	private void parseParams(String sParams) throws ServletParseException 
	{
		StringTokenizer st = new StringTokenizer(sParams, ";");
		while (st.hasMoreTokens()) 
		{
			String param = st.nextToken();
			String name;
			String value;
			int index = param.indexOf('=');
			
			if (index < 0) 
			{
				name  = param.trim();
				value = "";
			} 
			else 
			{
				name  = param.substring(0, index).trim();
				value = param.substring(index + 1).trim();
			}
			if (!SipGrammar.__param.containsAll(name)) 
			{
				throw new ServletParseException("Invalid parameter name [" 
						+ name + "] in [" + _uri + "]");
			}
			if (!SipGrammar.__param.containsAll(value)) 
			{
				throw new ServletParseException("Invalid parameter value [" 
						+ value + "] in [" + _uri + "]");
			}			
			_params.put(SipGrammar.unescape(name.toLowerCase()), SipGrammar.unescape(value));
		}
	}
示例#2
0
	public String toString()
	{
		if (_uri != null)
			return _uri;
		StringBuffer sb = new StringBuffer();
		sb.append(_scheme).append(":");
		sb.append(_file);
		
		Iterator<String> it = getParameterNames();
		while (it.hasNext()) 
		{
			String name = (String) it.next();
			String value = getParameter(name);
			sb.append(';');
			sb.append(SipGrammar.escape(name, SipGrammar.__param));
			if (value != null && value.length() > 0) 
			{
				sb.append('=');
				sb.append(SipGrammar.escape(value, SipGrammar.__param));
			}
		}
		return sb.toString();
	}
示例#3
0
	private void parse() throws ServletParseException 
	{
		int indexScheme = _uri.indexOf(':');
		if (indexScheme < 0) 
			throw new ServletParseException("Missing scheme in uri [" + _uri + "]");
		
		_scheme = _uri.substring(0, indexScheme);
		if (!SipGrammar.isURIScheme(_scheme))
			throw new ServletParseException("Invalid scheme [" + _scheme + "] in uri [" + _uri + "]");
		
		int indexParam = _uri.indexOf(';', indexScheme);
		if (indexParam < 0) 
		{
			_file = _uri.substring(indexScheme + 1);
		} 
		else 
		{
			_file = _uri.substring(indexScheme + 1, indexParam);
			String sParams = _uri.substring(indexParam + 1);
			parseParams(sParams);
		}
	}