本文整理汇总了Java中org.restlet.representation.Representation.getMediaType方法的典型用法代码示例。如果您正苦于以下问题:Java Representation.getMediaType方法的具体用法?Java Representation.getMediaType怎么用?Java Representation.getMediaType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.restlet.representation.Representation
的用法示例。
在下文中一共展示了Representation.getMediaType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JacksonRepresentation
import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param representation
* The representation to parse.
* @param objectClass
* The object class to instantiate.
*/
public JacksonRepresentation(Representation representation,
Class<T> objectClass) {
super(representation.getMediaType());
this.object = null;
this.objectClass = objectClass;
this.representation = representation;
this.objectMapper = null;
this.objectReader = null;
this.objectWriter = null;
this.csvSchema = null;
// [ifndef android] instruction
this.expandingEntityRefs = XML_EXPANDING_ENTITY_REFS;
// [ifndef android] instruction
this.validatingDtd = XML_VALIDATING_DTD;
}
示例2: SaxRepresentation
import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param xmlRepresentation
* A source XML representation to parse.
*/
public SaxRepresentation(Representation xmlRepresentation) {
super((xmlRepresentation == null) ? null : xmlRepresentation
.getMediaType());
this.secureProcessing = XML_SECURE_PROCESSING;
this.xmlRepresentation = xmlRepresentation;
}
示例3: GsonRepresentation
import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param representation
* The representation to parse.
* @param objectClass
* The object class to instantiate.
*/
public GsonRepresentation(Representation representation,
Class<T> objectClass) {
super(representation.getMediaType());
this.object = null;
this.objectClass = objectClass;
this.jsonRepresentation = representation;
this.builder = null;
}
示例4: checkMetadataConsistency
import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
* Checks that the URI and the representation are compatible. The whole set
* of metadata of the representation must be included in the set of those of
* the URI
*
* @param fileName
* The name of the resource
* @param representation
* The provided representation.
* @return True if the metadata of the representation are compatible with
* the metadata extracted from the filename
*/
private boolean checkMetadataConsistency(String fileName, Representation representation) {
if (representation != null) {
Variant var = new Variant();
Entity.updateMetadata(fileName, var, false, getMetadataService());
// "var" contains the theoretical correct metadata
if (!var.getLanguages().isEmpty()
&& !representation.getLanguages().isEmpty()
&& !var.getLanguages().containsAll(representation.getLanguages())) {
return false;
}
if ((var.getMediaType() != null)
&& (representation.getMediaType() != null)
&& !(var.getMediaType().includes(representation.getMediaType()))) {
return false;
}
if (!var.getEncodings().isEmpty()
&& !representation.getEncodings().isEmpty()
&& !var.getEncodings().containsAll(representation.getEncodings())) {
return false;
}
}
return true;
}
示例5: GsonRepresentation
import org.restlet.representation.Representation; //导入方法依赖的package包/类
public GsonRepresentation(Representation representation, Class<T> objectClass) {
super(representation.getMediaType());
iObject = null;
iObjectClass = objectClass;
iRepresentation = representation;
}
示例6: addEntityHeaders
import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
* Adds the entity headers based on the {@link Representation} to the {@link Series}.
*
* @param entity
* The source entity {@link Representation}.
* @param headers
* The target headers {@link Series}.
*/
public static void addEntityHeaders(Representation entity,
Series<Header> headers) {
if (entity == null || !entity.isAvailable()) {
addHeader(HeaderConstants.HEADER_CONTENT_LENGTH, "0", headers);
} else if (entity.getAvailableSize() != Representation.UNKNOWN_SIZE) {
addHeader(HeaderConstants.HEADER_CONTENT_LENGTH,
Long.toString(entity.getAvailableSize()), headers);
}
if (entity != null) {
addHeader(HeaderConstants.HEADER_CONTENT_ENCODING,
EncodingWriter.write(entity.getEncodings()), headers);
addHeader(HeaderConstants.HEADER_CONTENT_LANGUAGE,
LanguageWriter.write(entity.getLanguages()), headers);
if (entity.getLocationRef() != null) {
addHeader(HeaderConstants.HEADER_CONTENT_LOCATION, entity
.getLocationRef().getTargetRef().toString(), headers);
}
if (entity.getDigest() != null
&& Digest.ALGORITHM_MD5.equals(entity.getDigest()
.getAlgorithm())) {
addHeader(
HeaderConstants.HEADER_CONTENT_MD5,
new String(org.restlet.engine.util.Base64.encode(entity
.getDigest().getValue(), false)),
headers);
}
if (entity.getRange() != null) {
Range range = entity.getRange();
if (isBytesRange(range)) {
addHeader(HeaderConstants.HEADER_CONTENT_RANGE,
RangeWriter.write(range, entity.getSize()),
headers);
} else {
addHeader(HeaderConstants.HEADER_CONTENT_RANGE,
RangeWriter.write(range, range.getInstanceSize()),
headers);
}
}
if (entity.getMediaType() != null) {
addHeader(HeaderConstants.HEADER_CONTENT_TYPE,
ContentType.writeHeader(entity), headers);
}
if (entity.getExpirationDate() != null) {
addHeader(HeaderConstants.HEADER_EXPIRES,
DateWriter.write(entity.getExpirationDate()), headers);
}
if (entity.getModificationDate() != null) {
addHeader(HeaderConstants.HEADER_LAST_MODIFIED,
DateWriter.write(entity.getModificationDate()), headers);
}
if (entity.getTag() != null) {
addHeader(HeaderConstants.HEADER_ETAG,
TagWriter.write(entity.getTag()), headers);
}
if (entity.getDisposition() != null
&& !Disposition.TYPE_NONE.equals(entity.getDisposition()
.getType())) {
addHeader(HeaderConstants.HEADER_CONTENT_DISPOSITION,
DispositionWriter.write(entity.getDisposition()),
headers);
}
}
}
示例7: JaxbRepresentation
import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
* Creates a new JAXB representation, converting the input XML into a Java
* content tree. The XML is validated.
*
* @param xmlRepresentation
* The XML wrapped in a representation.
* @param contextPath
* The list of Java package names for JAXB.
* @param validationHandler
* A handler for dealing with validation failures.
* @param classLoader
* The classloader to use for JAXB annotated classes.
* @throws JAXBException
* If the incoming XML does not validate against the schema.
* @throws IOException
* If unmarshalling XML fails.
*/
public JaxbRepresentation(Representation xmlRepresentation,
String contextPath, ValidationEventHandler validationHandler,
ClassLoader classLoader) {
super((xmlRepresentation == null) ? null : xmlRepresentation
.getMediaType());
this.classLoader = classLoader;
this.contextPath = contextPath;
this.object = null;
this.secureProcessing = true;
this.validationEventHandler = validationHandler;
this.xmlRepresentation = xmlRepresentation;
}
示例8: DomRepresentation
import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param xmlRepresentation
* A source XML representation to parse.
*/
public DomRepresentation(Representation xmlRepresentation) {
super((xmlRepresentation == null) ? null : xmlRepresentation.getMediaType());
this.setAvailable((xmlRepresentation == null) ? false : xmlRepresentation.isAvailable());
this.xmlRepresentation = xmlRepresentation;
}
示例9: ContentType
import org.restlet.representation.Representation; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param representation
* The representation.
*/
public ContentType(Representation representation) {
this(representation.getMediaType(), representation.getCharacterSet());
}