@Override public void write(OutputStream outputStream) throws IOException { CharacterSet characterSet = target.getCharacterSet(); if (characterSet == null) { characterSet = CharacterSet.UTF_8; } writeFragment(outputStream, source, characterSet); } };
if (getCharacterSet() != null) { if (!first) { sb.append(","); sb.append(getCharacterSet());
if (getCharacterSet() != null) { if (!first) { sb.append(","); sb.append(getCharacterSet());
/** * 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()); }
/** * Indicates if the current variant includes the given variant. * * @param other * The other variant. * @return True if the current variant includes the other. */ public boolean includes(Variant other) { boolean result = other != null; // Compare the character set if (result) { result = (getCharacterSet() == null) || getCharacterSet().includes(other.getCharacterSet()); } // Compare the media type if (result) { result = (getMediaType() == null) || getMediaType().includes(other.getMediaType()); } // Compare the languages if (result) { result = (getLanguages().isEmpty()) || getLanguages().contains(Language.ALL) || getLanguages().containsAll(other.getLanguages()); } return result; }
result = (getCharacterSet() == null) || getCharacterSet().includes(other.getCharacterSet());
.getCharacterSet()); if (extension != null) { result.add(extension);
result = ((getCharacterSet() == null) && (otherVariant.getCharacterSet() == null) || (getCharacterSet() != null) && getCharacterSet().equals( otherVariant.getCharacterSet()));
/** * 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; }
Set<Dimension> dimensions = this.response.getDimensions(); if (bestRestlVar.getCharacterSet() != null) { dimensions.add(Dimension.CHARACTER_SET);
result.setCharacterSet(target.getCharacterSet());
if (variant.getCharacterSet() == null) { final CharacterSet defaultCharacterSet = metadataService .getDefaultCharacterSet();
/** * 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); }
/** * 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()); setLocationRef(variant.getLocationRef()); setLanguages(variant.getLanguages()); setMediaType(variant.getMediaType()); setModificationDate(modificationDate); setTag(tag); }
@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; } }
/** * 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); }