forked from LupusNobilis/java-org.hwo
52 lines
996 B
Java
52 lines
996 B
Java
package org.hwo.net.serverobjects;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.Stack;
|
|
|
|
import org.hwo.net.http.HttpServerRequest;
|
|
|
|
public class ServerObjectRequest {
|
|
|
|
private HttpServerRequest httpRequest;
|
|
|
|
private Stack<String> pathToClimb;
|
|
private Stack<String> pathClimbed;
|
|
|
|
public ServerObjectRequest(HttpServerRequest httpRequest)
|
|
{
|
|
this.httpRequest = httpRequest;
|
|
pathToClimb = new Stack<String>();
|
|
pathClimbed = new Stack<String>();
|
|
|
|
initialize();
|
|
}
|
|
|
|
private void initialize()
|
|
{
|
|
pathToClimb = new Stack<String>();
|
|
pathToClimb.addAll(Arrays.asList(httpRequest.getRequestURI().getPathElements()));
|
|
}
|
|
|
|
public HttpServerRequest getHttpRequest()
|
|
{
|
|
return httpRequest;
|
|
}
|
|
|
|
public String popNextElement()
|
|
{
|
|
if (pathToClimb.empty())
|
|
return null;
|
|
String n = pathToClimb.pop();
|
|
return n;
|
|
}
|
|
|
|
public void pushLastElement(String element)
|
|
{
|
|
pathClimbed.push(element);
|
|
}
|
|
|
|
}
|