當前位置: 首頁>>代碼示例>>Java>>正文


Java Reference.toString方法代碼示例

本文整理匯總了Java中org.restlet.data.Reference.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java Reference.toString方法的具體用法?Java Reference.toString怎麽用?Java Reference.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.restlet.data.Reference的用法示例。


在下文中一共展示了Reference.toString方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateNotRecursiveServerRedirect

import org.restlet.data.Reference; //導入方法依賴的package包/類
/**
 * Throw an exception if there is a recursive server-side redirect.
 * 
 * @param targetRef
 *        The target reference
 * @param request
 *        The request
 * @param response
 *        The response
 */
private void validateNotRecursiveServerRedirect( Reference targetRef, Request request, Response response )
{
	@SuppressWarnings("unchecked")
	Set<String> serverRedirectHistory = (Set<String>) request.getAttributes().get( SERVER_REDIRECT_HISTORY_ATTRIBUTE );
	if( serverRedirectHistory == null )
	{
		serverRedirectHistory = new HashSet<String>();
		@SuppressWarnings("unchecked")
		Set<String> existing = (Set<String>) request.getAttributes().putIfAbsent( SERVER_REDIRECT_HISTORY_ATTRIBUTE, serverRedirectHistory );
		if( existing != null )
			serverRedirectHistory = existing;
	}

	String targetRefString = targetRef.toString();
	if( serverRedirectHistory.contains( targetRefString ) )
	{
		String message = "Recursive server redirection to " + targetRef;
		getLogger().warning( message );
		throw new ResourceException( Status.SERVER_ERROR_INTERNAL, message );
	}

	serverRedirectHistory.add( targetRefString );
}
 
開發者ID:tliron,項目名稱:prudence,代碼行數:34,代碼來源:ResolvingRedirector.java

示例2: getRequestValue

import org.restlet.data.Reference; //導入方法依賴的package包/類
protected String getRequestValue(Request request, String facetName)
{
   if ("path".equals(facetName)) {
      return request.getResourceRef().getPath();
   } else if ("uri".equals(facetName)) {
      return request.getResourceRef().toString();
   } else if ("remaining".equals(facetName)) {
      String remaining = request.getResourceRef().getRemainingPart();
      int q = remaining.indexOf('?');
      return q<0 ? remaining : remaining.substring(0,q);
   } else if ("query".equals(facetName)) {
      return request.getResourceRef().getQuery();
   } else if ("base".equals(facetName)) {
      Reference baseRef = request.getResourceRef().getBaseRef();
      if (baseRef!=null) {
         return baseRef.toString();
      }
   }
   return null;
}
 
開發者ID:alexmilowski,項目名稱:xproclet,代碼行數:21,代碼來源:XProcHelper.java

示例3: getRelativePath

import org.restlet.data.Reference; //導入方法依賴的package包/類
protected String getRelativePath(Request request) {
    Reference baseRef = request.getRootRef();
    String baseUrl = baseRef.toString();
    String url = null;
    if (baseRef == null) {
        url = baseUrl;
    } else {
        url = request.getResourceRef().toString();
        if (url.startsWith(baseUrl)) {
            url = url.substring(baseUrl.length());
        } else {
            url = request.getResourceRef().getPath();
        }
    }
    return url;
}
 
開發者ID:devacfr,項目名稱:spring-restlet,代碼行數:17,代碼來源:SpringSecurityGuard.java

示例4: constructRetrievalReference

import org.restlet.data.Reference; //導入方法依賴的package包/類
private String constructRetrievalReference(String id) {
	
	Reference us = getReference();
	List<String> segments = us.getSegments();
	int found = segments.indexOf("wps");
	if (found < 0) {
		throw new IllegalStateException("Expected '/wps' in the current request's URL");
	}
	
	StringBuilder buf = new StringBuilder();
	for (int i = 0; i <= found; ++ i) {
		buf.append('/').append(segments.get(i));
	}
	buf.append("/gpkg/").append(id);
	
	return Reference.toString(us.getScheme(), us.getHostDomain(), (us.getHostPort() < 0) ? 80 : us.getHostPort(), buf.toString(), null, null);
}
 
開發者ID:opengeospatial,項目名稱:geopackager,代碼行數:18,代碼來源:WPSResource.java

示例5: getBaseUrlSlash

import org.restlet.data.Reference; //導入方法依賴的package包/類
public static String getBaseUrlSlash(Request request) {

        Series<?> headers = (Series<?>) request.getAttributes().get("org.restlet.http.headers");

        String scheme = null;
        String authority = null;
        if (headers != null) {
            scheme = headers.getFirstValue("X-Forwarded-Proto", true);
            authority = headers.getFirstValue("Host");
        }

        Reference ref = request.getRootRef();
        if (authority != null) {
            ref.setAuthority(authority);
        }
        if (scheme != null) {
            ref.setScheme(scheme);
        }

        String url = ref.toString();
        return url.endsWith("/") ? url : url + "/";
    }
 
開發者ID:slipstream,項目名稱:SlipStreamServer,代碼行數:23,代碼來源:ResourceUriUtil.java

示例6: FileProperties

import org.restlet.data.Reference; //導入方法依賴的package包/類
public FileProperties(Reference r) {

        uri = r.toString();
        name = r.getLastSegment();

        Matcher m = REPORT_FILENAME.matcher(name);

        if (m.matches() && m.groupCount() == 3) {
            node = m.group(1);
            date = m.group(2);
            type = m.group(3);
        } else {
            node = null;
            date = null;
            type = "unknown";
        }
    }
 
開發者ID:slipstream,項目名稱:SlipStreamServer,代碼行數:18,代碼來源:FileProperties.java

示例7: getHeaderValue

import org.restlet.data.Reference; //導入方法依賴的package包/類
protected String getHeaderValue(String headerName,Request request,Series<Header> headers) {
   if (headerName.equals("Host")) {
      Reference hostRef = request.getHostRef();
      return hostRef==null ? null : hostRef.toString();
   } else {
      return headers==null ? null : headers.getFirstValue(headerName);
   }
}
 
開發者ID:alexmilowski,項目名稱:xproclet,代碼行數:9,代碼來源:XProcHelper.java

示例8: getUrl

import org.restlet.data.Reference; //導入方法依賴的package包/類
@Override
public String getUrl(String tileMatrix, int tileRow, int tileCol) {
	Reference synthesized = new Reference(request);
	
	/*
	 * Determine an appropriate bounding box for this request.
	 */
	double width = availableData.getMaxX() - availableData.getMinX();
	double height = availableData.getMaxY() - availableData.getMinY();
	int matrixWidth = getMatrixWidth(tileMatrix);
	int matrixHeight = getMatrixHeight(tileMatrix);
	double llx = availableData.getMinX() + tileCol * width / matrixWidth;
	double lly = availableData.getMinY() + tileRow * height / matrixHeight;
	double urx = llx + width / matrixWidth;
	double ury = lly + height / matrixHeight;
	StringBuilder buf = new StringBuilder();
	buf.append(llx).append(',');
	buf.append(lly).append(',');
	buf.append(urx).append(',');
	buf.append(ury);
	query.set("BBOX", buf.toString());
	
	query.set("WIDTH", String.valueOf(getTileWidthPixels(tileMatrix)));
	query.set("HEIGHT", String.valueOf(getTileHeightPixels(tileMatrix)));
	
	try {
		synthesized.setQuery(query.encode());
	} catch (IOException e) {
		LOG.error("Synthesizing WMS request", e);
		return null;
	}
	return synthesized.toString();
}
 
開發者ID:opengeospatial,項目名稱:geopackager,代碼行數:34,代碼來源:TiledWMS.java

示例9: newModelFromForm

import org.restlet.data.Reference; //導入方法依賴的package包/類
@Post("multi")
   public Representation newModelFromForm(Representation formRep) {
//TODO: rework to use FileUpload Streaming API...
DiskFileItemFactory factory = new DiskFileItemFactory() ;
RestletFileUpload upload = new RestletFileUpload(factory) ;
List<FileItem> items ;
try {
    items = upload.parseRepresentation(formRep) ;
} catch (FileUploadException e) {
    throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "Exception parsing multipart form: " + e.getMessage(), e) ;
}
ComputationalModel model = parseModel(items) ;

model = addModel(model) ;

FileItem iframeItem = items.get(items.size() - 1) ;
if (iframeItem.getString().equals("true")) {
    return new StringRepresentation(buildIframeResponse(model), MediaType.TEXT_HTML) ;
} else {
    Reference modelRef = getNamespace().modelRef(entryName, getResolver().getModelName(model.getId()), true) ;
    redirectSeeOther(modelRef) ;
    return new StringRepresentation("Model created, URL: " + modelRef.toString() + ".") ;
}
   }
 
開發者ID:NCIP,項目名稱:digital-model-repository,代碼行數:25,代碼來源:NewModelResource.java

示例10: initializeBaseUrl

import org.restlet.data.Reference; //導入方法依賴的package包/類
/**
 * Create a string representation of the base URL. This value will have all
 * trailing slashes removed.
 *
 * @param baseRef
 * @return
 */
private String initializeBaseUrl(Reference baseRef) {

	String url = baseRef.toString();

	// TODO: This assumption should be fixed in the rest of the code.
	// Strip any trailing slashes.
	while (url.endsWith("/")) {
		url = url.substring(0, url.length() - 1);
	}

	return url;
}
 
開發者ID:slipstream,項目名稱:SlipStreamServer,代碼行數:20,代碼來源:Configuration.java

示例11: getLocalBaseRefSlash

import org.restlet.data.Reference; //導入方法依賴的package包/類
public static Reference getLocalBaseRefSlash(Request request) {
    Reference rootRef = request.getRootRef();
    String url = rootRef.toString();
    if (!url.endsWith("/")) {
        url += "/";
    }
    return new Reference(url);
}
 
開發者ID:slipstream,項目名稱:SlipStreamServer,代碼行數:9,代碼來源:ResourceUriUtil.java

示例12: buildAddress

import org.restlet.data.Reference; //導入方法依賴的package包/類
private String buildAddress(final ExtensionInfo extensionInfo, final String path) {
    final Reference ref = new Reference(extensionInfo.getBaseUrl());
    ref.setPath(path);
    return ref.toString();
}
 
開發者ID:blackducksoftware,項目名稱:hub-email-extension,代碼行數:6,代碼來源:ExtensionInfoServerResource.java

示例13: getResource

import org.restlet.data.Reference; //導入方法依賴的package包/類
private static Reference getResource(AbstractResource resource, Reference hostReference)
		throws MalformedURLException {

	return new Reference(hostReference, hostReference.toString() + resource.getResourceUri());
}
 
開發者ID:devacfr,項目名稱:spring-restlet,代碼行數:6,代碼來源:AbstractResourceTest.java

示例14: submitJob

import org.restlet.data.Reference; //導入方法依賴的package包/類
@Post("multi")
   public Representation submitJob(Representation formRep) {
RestletFileUpload upload = new RestletFileUpload() ;
ComputationJob job = new ComputationJob() ;
boolean inIframe = false ;
try {
    FileItemIterator items = upload.getItemIterator(formRep) ;
    List<ParameterValue> values = new ArrayList<ParameterValue>() ;
    job.setParameterValues(values) ;
    State state = State.TITLE ;
    while (items.hasNext()) {
	FileItemStream item = items.next() ;
       	InputStream itemStream = item.openStream() ;
       	switch (state) {
       	    case TITLE:
       		job.setTitle(Streams.asString(itemStream)) ;
       		state = State.DESC ;
       		break ;
       	    case DESC:
       		job.setDescription(Streams.asString(itemStream)) ;
       		state = State.COMMENTS ;
       		break ;
       	    case COMMENTS:
       		job.setComment(Streams.asString(itemStream)) ;
       		state = State.PARAMS ;
       		break ;
       	    case PARAMS:
       		if (item.getFieldName().equals("iframe")) {
       		    inIframe = Boolean.parseBoolean(Streams.asString(itemStream)) ;
       		} else {
       		    Parameter param = new Parameter() ;
       		    param.setName(parseParamName(item.getFieldName())) ;
       		    ParameterValue value = new ParameterValue() ;
       		    if (item.isFormField()) {
       			value.setValue(Streams.asString(itemStream)) ;
       		    } else {
       			value.setValue(storeFile(item.getName(), itemStream).getSource()) ;
       		    }
       		    value.setJob(job) ;
       		    value.setParameter(param) ;
       		    param.setValue(value) ;
       		    values.add(value) ;
       		}
       		break ;
       	}
    }
} catch (Exception e) {
    throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "Exception processing submit job form: " + e.getMessage(), e) ;
}

job = addNewJob(job) ;
ComputationJob startedJob = startJob(job) ;

if (inIframe) {
    return new StringRepresentation(buildIframeResponse(job), MediaType.TEXT_HTML) ;
} else {
    Reference jobRef = getNamespace().jobRef(entryName, modelName,getResolver().getJobName(startedJob.getId()), true) ;
    redirectSeeOther(jobRef) ;
    return new StringRepresentation("Job submitted, URL: " + jobRef.toString() + ".") ;
}
   }
 
開發者ID:NCIP,項目名稱:digital-model-repository,代碼行數:62,代碼來源:SubmitJobResource.java


注:本文中的org.restlet.data.Reference.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。