/** * * @param type * @param subtype * @param parameters * @return a new <code>ContentType</code> object */ public static ContentType create(final String type, final String subtype, final Map<String, String> parameters) { return new ContentType(type, subtype, mapToODataFormat(type, subtype), parameters); }
/** * Validates if given <code>format</code> is parseable and can be used as input for {@link #create(String)} method. * @param format to be validated string * @return <code>true</code> if format is parseable otherwise <code>false</code> */ public static boolean isParseableAsCustom(final String format) { try { return ContentType.create(format) != null; } catch (IllegalArgumentException e) { return false; } }
/** * Check if a valid match for this {@link ContentType} exists in given list. * For more detail what a valid match is see {@link #match(List)}. * * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType} * @return <code>true</code> if a matching content type was found in given list * or <code>false</code> if none matching content type match was found */ public boolean hasMatch(final List<ContentType> toMatchContentTypes) { return match(toMatchContentTypes) != null; }
private ContentType ensureCharset(final ContentType contentType) { if (ContentType.APPLICATION_ATOM_XML.isCompatible(contentType) || ContentType.APPLICATION_ATOM_SVC.isCompatible(contentType) || ContentType.APPLICATION_XML.isCompatible(contentType)) { return contentType.receiveWithCharsetParameter(DEFAULT_CHARSET); } return contentType; } }
/** * * @return <code>true</code> if this {@link ContentType} is text related (in the view of OData) */ public boolean isContentTypeODataTextRelated() { return (ContentType.TEXT_PLAIN.equals(this) || (getODataFormat() == ODataFormat.XML) || (getODataFormat() == ODataFormat.ATOM) || (getODataFormat() == ODataFormat.JSON)); }
/** * Check if a valid compatible match for this {@link ContentType} exists in given list. * Compatible in this case means that <b>all set parameters are ignored</b>. * For more detail what a valid match is see {@link #matchCompatible(List)}. * * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType} * @return <code>true</code> if a compatible content type was found in given list * or <code>false</code> if none compatible content type match was found */ public boolean hasCompatible(final List<ContentType> toMatchContentTypes) { return matchCompatible(toMatchContentTypes) != null; }
/** * Encodes a Java String (in its internal UTF-16 encoding) into its * percent-encoded UTF-8 representation according to * <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>, * suitable for parts of an OData path segment. * @param value the Java String * @return the encoded String */ public static String encode(final String value) { return encoder.encodeInternal(value); }
/** * Creates a content type from type and subtype * @param type * @param subtype * @return a new <code>ContentType</code> object */ public static ContentType create(final String type, final String subtype) { return new ContentType(type, subtype, mapToODataFormat(type, subtype), null); }
/** * Validates if given <code>format</code> is parseable and can be used as input for {@link #create(String)} method. * @param format to be validated string * @return <code>true</code> if format is parseable otherwise <code>false</code> */ public static boolean isParseable(final String format) { try { return ContentType.create(format) != null; } catch (IllegalArgumentException e) { return false; } }
private ContentType ensureCharset(final ContentType contentType) { if (ContentType.APPLICATION_ATOM_XML.isCompatible(contentType) || ContentType.APPLICATION_ATOM_SVC.isCompatible(contentType) || ContentType.APPLICATION_XML.isCompatible(contentType)) { return contentType.receiveWithCharsetParameter(DEFAULT_CHARSET); } return contentType; } }
/** * * @return <code>true</code> if this {@link ContentType} is text related (in the view of OData) */ public boolean isContentTypeODataTextRelated() { return (ContentType.TEXT_PLAIN.equals(this) || (getODataFormat() == ODataFormat.XML) || (getODataFormat() == ODataFormat.ATOM) || (getODataFormat() == ODataFormat.JSON)); }
/** * Check if a valid compatible match for this {@link ContentType} exists in given list. * Compatible in this case means that <b>all set parameters are ignored</b>. * For more detail what a valid match is see {@link #matchCompatible(List)}. * * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType} * @return <code>true</code> if a compatible content type was found in given list * or <code>false</code> if none compatible content type match was found */ public boolean hasCompatible(final List<ContentType> toMatchContentTypes) { return matchCompatible(toMatchContentTypes) != null; }
/** * Encodes a Java String (in its internal UTF-16 encoding) into its * percent-encoded UTF-8 representation according to * <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>, * suitable for parts of an OData path segment. * @param value the Java String * @return the encoded String */ public static String encode(final String value) { return encoder.encodeInternal(value); }
/** * Creates a content type from type and subtype * @param type * @param subtype * @return a new <code>ContentType</code> object */ public static ContentType create(final String type, final String subtype) { return new ContentType(type, subtype, mapToODataFormat(type, subtype), null); }
/** * Validates if given <code>format</code> is parseable and can be used as input for {@link #create(String)} method. * @param format to be validated string * @return <code>true</code> if format is parseable otherwise <code>false</code> */ public static boolean isParseableAsCustom(final String format) { try { return ContentType.create(format) != null; } catch (IllegalArgumentException e) { return false; } }
/** * Validates if given <code>format</code> is parseable and can be used as input for {@link #create(String)} method. * @param format to be validated string * @return <code>true</code> if format is parseable otherwise <code>false</code> */ public static boolean isParseableAsCustom(final String format) { try { return ContentType.create(format) != null; } catch (IllegalArgumentException e) { return false; } }
/** * Validates if given <code>format</code> is parseable and can be used as input for {@link #create(String)} method. * @param format to be validated string * @return <code>true</code> if format is parseable otherwise <code>false</code> */ public static boolean isParseable(final String format) { try { return ContentType.create(format) != null; } catch (IllegalArgumentException e) { return false; } }
@Override public ODataRequestBuilder contentType(final String contentType) { this.contentType = ContentType.create(contentType); return this; }
@Override public ODataRequestBuilder contentType(final String contentType) { this.contentType = ContentType.create(contentType); return this; }
/** * Validates if given <code>format</code> is parseable and can be used as input for {@link #create(String)} method. * @param format to be validated string * @return <code>true</code> if format is parseable otherwise <code>false</code> */ public static boolean isParseable(final String format) { try { return ContentType.create(format) != null; } catch (IllegalArgumentException e) { return false; } }