<commit_before>/*
 * Copyright (C) 2013 BigTesting.org
 *
 * 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.bigtesting.fixd.request.impl;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Set;

import org.bigtesting.fixd.core.RequestUnmarshallerImpl;
import org.bigtesting.fixd.request.HttpRequest;
import org.bigtesting.fixd.session.Session;
import org.bigtesting.fixd.util.RequestUtils;
import org.bigtesting.routd.PathParameterElement;
import org.bigtesting.routd.Route;
import org.bigtesting.routd.RouteHelper;
import org.simpleframework.http.Request;

/**
 * 
 * @author <NAME>
 */
public class SimpleHttpRequest implements HttpRequest {

    private final Request request;
    
    private final Session session;
    
    private final Route route;
    
    private final RequestUnmarshallerImpl unmarshaller;
    
    public SimpleHttpRequest(Request request, Session session, Route route, 
            RequestUnmarshallerImpl unmarshaller) {
        
        this.request = request;
        this.session = session;
        this.route = route;
        this.unmarshaller = unmarshaller;
    }
    
    public String getPath() {
        
        return request.getPath().getPath();
    }

    public Set<String> getRequestParameterNames() {
        
        return request.getQuery().keySet();
    }

    public String getRequestParameter(String name) {
        
        return request.getParameter(name);
    }
    
    public String getPathParameter(String name) {
        
        List<PathParameterElement> pathParams = getRoute().pathParameterElements();
        String[] pathTokens = RouteHelper.getPathElements(getPath());
        
        for (PathParameterElement pathParam : pathParams) {
            
            if (pathParam.name().equals(name)) return pathTokens[pathParam.index()];
        }
        
        return null;<commit_msg>using routd convenience method instead of custom implementation<commit_after>/*
 * Copyright (C) 2013 BigTesting.org
 *
 * 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.bigtesting.fixd.request.impl;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Set;

import org.bigtesting.fixd.core.RequestUnmarshallerImpl;
import org.bigtesting.fixd.request.HttpRequest;
import org.bigtesting.fixd.session.Session;
import org.bigtesting.fixd.util.RequestUtils;
import org.bigtesting.routd.Route;
import org.simpleframework.http.Request;

/**
 * 
 * @author <NAME>
 */
public class SimpleHttpRequest implements HttpRequest {

    private final Request request;
    
    private final Session session;
    
    private final Route route;
    
    private final RequestUnmarshallerImpl unmarshaller;
    
    public SimpleHttpRequest(Request request, Session session, Route route, 
            RequestUnmarshallerImpl unmarshaller) {
        
        this.request = request;
        this.session = session;
        this.route = route;
        this.unmarshaller = unmarshaller;
    }
    
    public String getPath() {
        
        return request.getPath().getPath();
    }

    public Set<String> getRequestParameterNames() {
        
        return request.getQuery().keySet();
    }

    public String getRequestParameter(String name) {
        
        return request.getParameter(name);
    }
    
    public String getPathParameter(String name) {
        
        return getRoute().getPathParameter(name, getPath());
{'fraction_non_alphanumeric': 0.08390830180280437, 'fraction_numerical': 0.0035610950367237926, 'mean_word_length': 3.1191567369385886, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1464567', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1181, 'n_words': 359}