Example usage for org.apache.commons.httpclient URI URI

List of usage examples for org.apache.commons.httpclient URI URI

Introduction

In this page you can find the example usage for org.apache.commons.httpclient URI URI.

Prototype

public URI(String scheme, String host, String path, String fragment) throws URIException 

Source Link

Document

Construct a general URI from the given components.

Usage

From source file:org.eclipsetrader.kdb.internal.core.Util.java

/**
 * Builds the http method for historycal prices download.
 *
 * @return the method.//from w ww. ja  v  a 2 s  . com
 */
public static HttpMethod getHistoryFeedMethod(IFeedIdentifier identifier, Date from, Date to)
        throws URIException {
    String symbol = getSymbol(identifier);

    String prefix = "/site/jikeiretsu.aspx?c=";
    String suffix = "&hyouji=&download=csv";
    URI uri = new URI("http", "k-db.com", prefix + symbol.toLowerCase() + suffix, "");

    GetMethod method = new GetMethod();
    method.setURI(uri);
    method.setFollowRedirects(true);

    return method;
}

From source file:org.eclipsetrader.kdb.internal.core.Util.java

public static HttpMethod get1DayHistoryFeedMethod(IFeedIdentifier identifier) throws URIException {
    String symbol = getSymbol(identifier);

    String prefix = "/site/jikeiretsu.aspx?c=";
    String suffix = "&hyouji=minutely&download=csv";
    URI uri = new URI("http", "k-db.com", prefix + symbol.toLowerCase() + suffix, "");

    GetMethod method = new GetMethod();
    method.setURI(uri);/* w  w w.j a  va  2  s  .  co m*/
    method.setFollowRedirects(true);

    return method;
}

From source file:org.eclipsetrader.kdb.internal.core.Util.java

public static HttpMethod get5DayHistoryFeedMethod(IFeedIdentifier identifier) throws URIException {
    String symbol = getSymbol(identifier);

    String prefix = "/site/jikeiretsu.aspx?c=";
    String suffix = "&hyouji=5min&download=csv";
    URI uri = new URI("http", "k-db.com", prefix + symbol.toLowerCase() + suffix, "");

    GetMethod method = new GetMethod();
    method.setURI(uri);/* w ww  .j  a va 2s. com*/
    method.setFollowRedirects(true);

    return method;
}

From source file:org.eclipsetrader.kdb.internal.core.Util.java

public static HttpMethod get1YearHistoryFeedMethod(IFeedIdentifier identifier, int year) throws URIException {
    String symbol = getSymbol(identifier);

    String prefix = "/site/jikeiretsu.aspx?c=";
    String suffix = "&hyouji=&download=csv";
    URI uri = new URI("http", "k-db.com",
            prefix + symbol.toLowerCase() + "&year=" + Integer.toString(year) + suffix, "");

    GetMethod method = new GetMethod();
    method.setURI(uri);/*from   w w  w.  j  a v a 2  s. c o m*/
    method.setFollowRedirects(true);

    return method;
}

From source file:org.eclipsetrader.yahoo.internal.core.Util.java

/**
 * Builds the http method for historycal prices download.
 *
 * @return the method./* w  w w.  j a  va  2s  .  co  m*/
 */
public static HttpMethod getHistoryFeedMethod(IFeedIdentifier identifier, Date from, Date to)
        throws URIException {
    String symbol = getSymbol(identifier);

    Calendar fromDate = Calendar.getInstance();
    fromDate.setTime(from);

    Calendar toDate = Calendar.getInstance();
    toDate.setTime(to);

    String prefix = "/instrument/1.0/";
    String suffix = "/chartdata;type=quote";
    URI uri = new URI("http", "chartapi.finance.yahoo.com", prefix + symbol.toLowerCase() + suffix, "");

    GetMethod method = new GetMethod();
    method.setURI(uri);
    method.setQueryString(new NameValuePair[] { new NameValuePair("s", symbol),
            new NameValuePair("d", String.valueOf(toDate.get(Calendar.MONTH))),
            new NameValuePair("e", String.valueOf(toDate.get(Calendar.DAY_OF_MONTH))),
            new NameValuePair("f", String.valueOf(toDate.get(Calendar.YEAR))), new NameValuePair("g", "d"),
            new NameValuePair("a", String.valueOf(fromDate.get(Calendar.MONTH))),
            new NameValuePair("b", String.valueOf(fromDate.get(Calendar.DAY_OF_MONTH))),
            new NameValuePair("c", String.valueOf(fromDate.get(Calendar.YEAR))),
            new NameValuePair("ignore", ".csv"), });
    method.setFollowRedirects(true);
    try {
        System.out.println(method.getURI().toString());
    } catch (URIException e) {
        e.printStackTrace();
    }

    return method;
}

From source file:org.eclipsetrader.yahoo.internal.core.Util.java

public static HttpMethod get1DayHistoryFeedMethod(IFeedIdentifier identifier) throws URIException {
    String symbol = getSymbol(identifier);

    String prefix = "/instrument/1.0/";
    String suffix = "/chartdata;type=quote;range=1d/csv/";
    URI uri = new URI("http", "chartapi.finance.yahoo.com", prefix + symbol.toLowerCase() + suffix, "");

    GetMethod method = new GetMethod();
    method.setURI(uri);/* w  ww  .j  av  a  2s.  co m*/
    method.setFollowRedirects(true);

    return method;
}

From source file:org.eclipsetrader.yahoo.internal.core.Util.java

public static HttpMethod get5DayHistoryFeedMethod(IFeedIdentifier identifier) throws URIException {
    String symbol = getSymbol(identifier);

    String prefix = "/instrument/1.0/";
    String suffix = "/chartdata;type=quote;range=5d/csv/";
    URI uri = new URI("http", "chartapi.finance.yahoo.com", prefix + symbol.toLowerCase() + suffix, "");

    GetMethod method = new GetMethod();
    method.setURI(uri);//from   w  w  w.  j  a va  2  s  .c o  m
    method.setFollowRedirects(true);

    return method;
}

From source file:org.eclipsetrader.yahoo.internal.core.Util.java

public static HttpMethod get1YearHistoryFeedMethod(IFeedIdentifier identifier, int year) throws URIException {
    String symbol = getSymbol(identifier);

    String prefix = "/instrument/1.0/";
    String suffix = "/chartdata;type=quote;ys=" + year + ";yz=1/csv/";
    URI uri = new URI("http", "chartapi.finance.yahoo.com", prefix + symbol.toLowerCase() + suffix, "");

    GetMethod method = new GetMethod();
    method.setURI(uri);//w  w w  .  j  a v a 2s .co m
    method.setFollowRedirects(true);

    return method;
}

From source file:org.eclipsetrader.yahoojapan.internal.core.Util.java

/**
 * Builds the http method for historycal prices download.
 *
 * @return the method.//from   w  w  w  .  j  a va  2 s .  c  o m
 */
public static HttpMethod getHistoryFeedMethod(IFeedIdentifier identifier, Date from, Date to)
        throws URIException {
    String symbol = getSymbol(identifier);

    Calendar fromDate = Calendar.getInstance();
    fromDate.setTime(from);

    Calendar toDate = Calendar.getInstance();
    toDate.setTime(to);

    String prefix = "/history/";
    String suffix = "";
    URI uri = new URI("http", "info.finance.yahoo.co.jp", prefix + suffix, "");

    GetMethod method = new GetMethod();
    method.setURI(uri);
    method.setQueryString(new NameValuePair[] { new NameValuePair("code", symbol),
            new NameValuePair("sy", String.valueOf(fromDate.get(Calendar.YEAR))),
            new NameValuePair("sm", String.valueOf(fromDate.get(Calendar.MONTH) + 1)),
            new NameValuePair("sd", String.valueOf(fromDate.get(Calendar.DAY_OF_MONTH))),
            new NameValuePair("ey", String.valueOf(toDate.get(Calendar.YEAR))),
            new NameValuePair("em", String.valueOf(toDate.get(Calendar.MONTH) + 1)),
            new NameValuePair("ed", String.valueOf(toDate.get(Calendar.DAY_OF_MONTH))),
            new NameValuePair("tm", "d"),
            //                new NameValuePair("p", "1"),
    });
    method.setFollowRedirects(true);
    try {
        System.out.println(method.getURI().toString());
    } catch (URIException e) {
        e.printStackTrace();
    }

    return method;
}

From source file:org.eclipsetrader.yahoojapan.internal.core.Util.java

public static HttpMethod get1YearHistoryFeedMethod(IFeedIdentifier identifier, int year, int page)
        throws URIException {
    String symbol = getSymbol(identifier);

    String prefix = "/history/";
    String suffix = "";
    URI uri = new URI("http", "info.finance.yahoo.co.jp", prefix + suffix, "");

    GetMethod method = new GetMethod();
    method.setURI(uri);//w w  w  .  j  a v  a 2  s .  co m
    method.setQueryString(new NameValuePair[] { new NameValuePair("code", symbol),
            new NameValuePair("sy", String.valueOf(year)), new NameValuePair("sm", "1"),
            new NameValuePair("sd", "1"), new NameValuePair("ey", String.valueOf(year)),
            new NameValuePair("em", "12"), new NameValuePair("ed", "31"), new NameValuePair("tm", "d"),
            new NameValuePair("p", String.valueOf(page)), });
    method.setFollowRedirects(true);

    return method;
}