本文整理匯總了Java中org.restlet.data.Reference.getPath方法的典型用法代碼示例。如果您正苦於以下問題:Java Reference.getPath方法的具體用法?Java Reference.getPath怎麽用?Java Reference.getPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.restlet.data.Reference
的用法示例。
在下文中一共展示了Reference.getPath方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createInboundRoot
import org.restlet.data.Reference; //導入方法依賴的package包/類
@Override
public Restlet createInboundRoot() {
Router baseRouter = new Router(context);
baseRouter.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
for (RestletRoutable rr : restlets) {
baseRouter.attach(rr.basePath(), rr.getRestlet(context));
}
Filter slashFilter = new Filter() {
@Override
protected int beforeHandle(Request request, Response response) {
Reference ref = request.getResourceRef();
String originalPath = ref.getPath();
if (originalPath.contains("//"))
{
String newPath = originalPath.replaceAll("/+", "/");
ref.setPath(newPath);
}
return Filter.CONTINUE;
}
};
slashFilter.setNext(baseRouter);
return slashFilter;
}
示例2: createInboundRoot
import org.restlet.data.Reference; //導入方法依賴的package包/類
@Override
public Restlet createInboundRoot() {
Router baseRouter = new Router(context);
baseRouter.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
for (RestletRoutable rr : restlets) {
baseRouter.attach(rr.basePath(), rr.getRestlet(context));
}
Filter slashFilter = new Filter() {
@Override
protected int beforeHandle(Request request, Response response) {
Reference ref = request.getResourceRef();
String originalPath = ref.getPath();
if (originalPath.contains("//"))
{
String newPath = originalPath.replaceAll("/+", "/");
ref.setPath(newPath);
}
return Filter.CONTINUE;
}
};
slashFilter.setNext(baseRouter);
return slashFilter;
}
示例3: getMediaDir
import org.restlet.data.Reference; //導入方法依賴的package包/類
protected File getMediaDir(Map<String,Object> attributes) {
Object o = attributes.get(CollectionBaseRestlet.MEDIA_HREF_ATTR);
if (o==null) {
return defaultMediaDir;
}
Reference dirMediaRef = new Reference(o.toString());
if (dirMediaRef.getScheme().equals("file")) {
File mediaDir = new File(dirMediaRef.getPath());
if (mediaDir.exists()) {
if (!mediaDir.isDirectory()) {
getLogger().severe("Media directory "+mediaDir+" is not a directory.");
mediaDir = null;
}
} else {
getLogger().severe("Media directory "+mediaDir+" does not exist.");
mediaDir = null;
}
return mediaDir;
} else {
return null;
}
}
示例4: getReference
import org.restlet.data.Reference; //導入方法依賴的package包/類
public URL getReference(final Reference baseRef, String query, List<?> parts) {
if (!refCache.containsKey(baseRef)) {
refCache.put(baseRef, prepareReference(baseRef));
}
Reference r = new Reference(refCache.get(baseRef));
String currPath = r.getPath();
StringBuilder sb = new StringBuilder(currPath == null ? "" : currPath);
for (Object pe : parts) {
if (pe instanceof String && ((String) pe).startsWith("/")) {
sb.append(pe);
} else {
sb.append("/").append(pe);
}
}
r.setPath(sb.toString());
if (query != null) {
r.setQuery(query);
}
return r.toUrl();
}
示例5: createInboundRoot
import org.restlet.data.Reference; //導入方法依賴的package包/類
@Override
public Restlet createInboundRoot() {
Router baseRouter = new Router(context);
baseRouter.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
for (RestletRoutable rr : restlets) {
baseRouter.attach(rr.basePath(), rr.getRestlet(context));
}
Filter slashFilter = new Filter() {
@Override
protected int beforeHandle(Request request, Response response) {
Reference ref = request.getResourceRef();
String originalPath = ref.getPath();
if (originalPath.contains("//")) {
String newPath = originalPath.replaceAll("/+", "/");
ref.setPath(newPath);
}
return Filter.CONTINUE;
}
};
slashFilter.setNext(baseRouter);
return slashFilter;
}
示例6: createInboundRoot
import org.restlet.data.Reference; //導入方法依賴的package包/類
@Override
public Restlet createInboundRoot() {
Router baseRouter = new Router(context);
baseRouter.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
for (RestletRoutable rr : restlets) {
baseRouter.attach(rr.basePath(), rr.getRestlet(context));
}
Filter slashFilter = new Filter() {
@Override
protected int beforeHandle(Request request, Response response) {
Reference ref = request.getResourceRef();
String originalPath = ref.getPath();
if (originalPath.contains("//"))
{
String newPath = originalPath.replaceAll("/+", "/");
ref.setPath(newPath);
}
return Filter.CONTINUE;
}
};
slashFilter.setNext(baseRouter);
return slashFilter;
}
示例7: getIdentityPath
import org.restlet.data.Reference; //導入方法依賴的package包/類
private String getIdentityPath( Reference ref )
{
String path = ref.getPath();
if( !path.endsWith( "/" ) )
{
path = path.substring( 0, path.lastIndexOf( '/' ) + 1 );
}
return path;
}
示例8: createInboundRoot
import org.restlet.data.Reference; //導入方法依賴的package包/類
/**
* Sets up the Restlet for the APIs under test using a Router. Also, a
* filter is installed to deal with double slashes in URLs.
* This code is adapted from
* net.floodlightcontroller.restserver.RestApiServer
*
* @return Router object for the APIs under test.
*/
@Override
public Restlet createInboundRoot() {
Router baseRouter = new Router(context);
baseRouter.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
for (RestletRoutable rr : restlets) {
baseRouter.attach(rr.basePath(), rr.getRestlet(context));
}
/**
* Filter out multiple slashes in URLs to make them a single slash.
*/
Filter slashFilter = new Filter() {
@Override
protected int beforeHandle(Request request, Response response) {
Reference ref = request.getResourceRef();
String originalPath = ref.getPath();
if (originalPath.contains("//")) {
String newPath = originalPath.replaceAll("/+", "/");
ref.setPath(newPath);
}
return Filter.CONTINUE;
}
};
slashFilter.setNext(baseRouter);
return slashFilter;
}