Package org.opentripplanner.api.parameter

Source Code of org.opentripplanner.api.parameter.FeedScopedId

package org.opentripplanner.api.parameter;

import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

import org.onebusaway.gtfs.model.AgencyAndId;

public class FeedScopedId {
   
    String feedId;
    String entityId;

    private static void err (String message) {
        throw new WebApplicationException(Response
                .status(Status.BAD_REQUEST)
                .entity(message)
                .build());
    }
   
    public FeedScopedId (String s) {
        try {
            /* We do not use split in case the entity ID contains a slash. */
            int idx = s.indexOf('/');
            if (idx == -1) {
                feedId = "none";
                entityId = s;
            } else {
                feedId = s.substring(0, idx);
                entityId = s.substring(idx + 1);           
            }
        } catch (Exception ex) {
            err ("Unable to parse feed-scoped ID: " + ex.getMessage());
        }       
    }
   
    public AgencyAndId toAgencyAndId () {
        return new AgencyAndId(feedId, entityId);
    }

}
TOP

Related Classes of org.opentripplanner.api.parameter.FeedScopedId

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.