if (!getEncodings().isEmpty()) { if (!first) { sb.append(","); sb.append(getEncodings());
/** * Indicates if the current variant is equal to the given variant. * * @param other * The other variant. * @return True if the current variant includes the other. */ @Override public boolean equals(Object other) { if (other == this) { return true; } if (!(other instanceof Variant)) { return false; } Variant that = (Variant) other; return Objects.equals(getCharacterSet(), that.getCharacterSet()) && Objects.equals(getMediaType(), that.getMediaType()) && getLanguages().equals(that.getLanguages()) && getEncodings().equals(that.getEncodings()) && Objects.equals(getLocationRef(), that.getLocationRef()); }
result = (getEncodings().isEmpty()) || getEncodings().contains(Encoding.ALL) || getEncodings().containsAll(other.getEncodings());
for (Encoding encoding : variant.getEncodings()) { extension = metadataService.getExtension(encoding); if (extension != null) {
if (!var.getEncodings().isEmpty() && !representation.getEncodings().isEmpty() && !var.getEncodings().containsAll(representation.getEncodings())) { return false;
&& i < variant.getEncodings().size(); i++) { found = current.includes(variant.getEncodings() .get(i)); variant.getEncodings().add((Encoding) current); if (variant.getEncodings().isEmpty()) { final Encoding defaultEncoding = metadataService .getDefaultEncoding(); && !defaultEncoding.equals(Encoding.ALL) && !defaultEncoding.equals(Encoding.IDENTITY)) { variant.getEncodings().add(defaultEncoding);
/** * Constructor. * * @param variant * The variant to enrich. * @param annotationInfo * The optional annotation descriptor. */ public VariantInfo(Variant variant, MethodAnnotationInfo annotationInfo) { this(variant.getMediaType(), annotationInfo); setCharacterSet(variant.getCharacterSet()); setEncodings(variant.getEncodings()); setLanguages(variant.getLanguages()); }
/** * Creates a {@link ClientInfo} instance with preferences matching exactly * the current variant. * * @return The new {@link ClientInfo} instance. */ public ClientInfo createClientInfo() { ClientInfo result = new ClientInfo(); if (getCharacterSet() != null) { result.getAcceptedCharacterSets().add( new Preference<CharacterSet>(getCharacterSet())); } if (getEncodings() != null) { for (Encoding encoding : getEncodings()) { result.getAcceptedEncodings().add( new Preference<Encoding>(encoding)); } } if (getLanguages() != null) { for (Language language : getLanguages()) { result.getAcceptedLanguages().add( new Preference<Language>(language)); } } if (getMediaType() != null) { result.getAcceptedMediaTypes().add( new Preference<MediaType>(getMediaType())); } return result; }
if (bestRestlVar.getEncodings() != null) { dimensions.add(Dimension.ENCODING);
result.getEncodings().addAll(target.getEncodings());
/** * Converts the given Restlet Variant to a JAX-RS Variant * * @param restletVariant * @return the JAX-RS Variant * @throws IllegalArgumentException * If the given Variant does not contain exactly one language * and one */ public static javax.ws.rs.core.Variant toJaxRsVariant( org.restlet.representation.Variant restletVariant) throws IllegalArgumentException { final MediaType mediaType = Converter .toJaxRsMediaType(restletVariant.getMediaType(), restletVariant.getCharacterSet()); final Locale language = toLocale(Util .getOnlyMetadataName(restletVariant.getLanguages())); final String encoding = Util.getOnlyMetadataName(restletVariant .getEncodings()); return new javax.ws.rs.core.Variant(mediaType, language, encoding); }
@Override public Representation toRepresentation(Object object, Variant targetVariant, UniformResource resource) throws IOException { Representation result = null; if (object instanceof Document) { result = new DomRepresentation(targetVariant == null ? null : targetVariant.getMediaType(), (Document) object); } if ((result != null) && (targetVariant != null)) { // Copy the variant metadata result.setCharacterSet(targetVariant.getCharacterSet()); result.setMediaType(targetVariant.getMediaType()); result.setEncodings(targetVariant.getEncodings()); result.setLanguages(targetVariant.getLanguages()); } return result; } }
float encodingScore = scoreEncodings(variant.getEncodings());
/** * Constructor from a variant. * * @param variant * The variant to copy. * @param modificationDate * The modification date. * @param tag * The tag. */ public RepresentationInfo(Variant variant, Date modificationDate, Tag tag) { setCharacterSet(variant.getCharacterSet()); setEncodings(variant.getEncodings()); setLocationRef(variant.getLocationRef()); setLanguages(variant.getLanguages()); setMediaType(variant.getMediaType()); setModificationDate(modificationDate); setTag(tag); }
/** * Constructor from a variant. * * @param variant * The variant to copy. * @param modificationDate * The modification date. * @param tag * The tag. */ public Representation(Variant variant, Date modificationDate, Tag tag) { setCharacterSet(variant.getCharacterSet()); setEncodings(variant.getEncodings()); setLocationRef(variant.getLocationRef()); setLanguages(variant.getLanguages()); setMediaType(variant.getMediaType()); setModificationDate(modificationDate); setTag(tag); }