Class Util
- java.lang.Object
-
- org.restlet.ext.jaxrs.internal.util.Util
-
@Deprecated public class Util extends java.lang.ObjectDeprecated.Will be removed in next minor release.This class contains utility methods.
-
-
Field Summary
Fields Modifier and Type Field Description static CharacterSetJAX_RS_DEFAULT_CHARACTER_SETDeprecated.The default character set to be used, if no character set is given.static java.lang.StringJAX_RS_DEFAULT_CHARACTER_SET_AS_STRINGDeprecated.The default character set to be used, if no character set is given, as Stringstatic java.util.Comparator<MediaType>MEDIA_TYPE_COMPDeprecated.This comparator sorts the concrete MediaTypes to the beginning and the unconcrete to the end.private static byteNAME_READDeprecated.private static byteNAME_READ_READYDeprecated.private static byteNAME_READ_STARTDeprecated.static java.lang.StringORG_RESTLET_EXT_JAXRS_HTTP_HEADERSDeprecated.The name of the headerMultivaluedMap<String, String> in the attribute map.
-
Constructor Summary
Constructors Constructor Description Util()Deprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidappend(java.lang.Appendable stb, java.lang.CharSequence string, boolean convertBraces)Deprecated.appends the given String to the StringBuilder.static voidappend(java.lang.Appendable stb, java.lang.CharSequence string, boolean convertBraces, int startIndex)Deprecated.appends the given String to the StringBuilder.static voidappend(java.lang.Appendable stb, java.lang.CharSequence string, boolean convertBraces, int startIndex, int endIndex)Deprecated.appends the given String to the StringBuilder.static voidappend(java.lang.StringBuilder stb, java.lang.Object[] array)Deprecated.appends the array elements to theStringBuilder, separated by ", ".private static booleancheckClassAndInterfacesForAnnotation(java.lang.Class<?> jaxRsClass, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)Deprecated.Indicates if the given class (and its implemented interfaces) are annotated with the given annotation.static voidcheckClassConcrete(java.lang.Class<?> jaxRsClass, java.lang.String typeName)Deprecated.Checks, if the class is concrete.static voidcopyResponseHeaders(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> jaxRsHeaders, Response restletResponse)Deprecated.Copies headers into a response.static Series<Header>copyResponseHeaders(Response restletResponse)Deprecated.static <A> java.util.Collection<A>createColl(A... objects)Deprecated.Creates an modifiable Collection with the given Objects in it, and no other objects.static <A> java.util.List<A>createList(A... objects)Deprecated.Creates an modifiable List with the given Object in it, and no other objects.static java.util.Map<java.lang.String,java.lang.String>createMap(java.lang.String... keysAndValues)Deprecated.Creates a map with the given keys and values.static <A> java.util.Set<A>createSet(A... objects)Deprecated.Creates an modifiable Set with the given Object in it, and no other objects.static booleandoesImplement(java.lang.Class<?> clazz, java.lang.Class<?> interfaze)Deprecated.Checks, if the given class implements the given interface.static booleanendsWith(java.lang.CharSequence charSequence, char character)Deprecated.Checks, if the given CharSequence ends with the given character.static booleanequals(java.lang.Object object1, java.lang.Object object2)Deprecated.Check if the given objects are equal.static java.lang.StringformatDate(java.util.Date date, boolean cookie)Deprecated.Converts the given Date into a String.static java.lang.StringformatDimensions(java.util.Set<Dimension> dimensions)Deprecated.Formats the givenSetofDimensions to a String for the HTTP Vary header.private static java.lang.Class<?>getArrayClass(java.lang.reflect.Type genCompType, java.lang.reflect.Type forMessage)Deprecated.static java.lang.StringgetCharsetName(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders, CharacterSet defaultCs)Deprecated.Returns the character set as String of the given http headers (e.g.static <A> AgetFirstElement(java.lang.Iterable<A> coll)Deprecated.Returns the first element of the givenIterable.static <A> AgetFirstElement(java.util.Collection<A> coll)Deprecated.Returns the first element of the given collection.static <A> AgetFirstElement(java.util.List<A> list)Deprecated.Returns the first element of theList.static <A> AgetFirstElementOrNull(java.lang.Iterable<A> coll)Deprecated.Returns the first element of the givenIterable.static <K,V>
java.util.Map.Entry<K,V>getFirstEntry(java.util.Map<K,V> map)Deprecated.Returns the first entry of the givenMap.static <K,V>
KgetFirstKey(java.util.Map<K,V> map)Deprecated.Returns the key of the first entry of the givenMap.static <K,V>
VgetFirstValue(java.util.Map<K,V> map)Deprecated.Returns the value of the first entry of the givenMap.static java.lang.Class<?>getGenericClass(java.lang.Class<?> clazz, java.lang.Class<?> implInterface)Deprecated.private static java.lang.Class<?>getGenericClass(java.lang.Class<?> clazz, java.lang.Class<?> implInterface, java.lang.reflect.Type[] gsatp)Deprecated.static java.lang.Class<?>getGenericClass(java.lang.reflect.Type genericType)Deprecated.Example: in List<String> -> out: String.classstatic Series<Header>getHttpHeaders(Request request)Deprecated.static Series<Header>getHttpHeaders(Response response)Deprecated.static javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String>getJaxRsHttpHeaders(Request request)Deprecated.Returns the request headers asMultivaluedMap.static <A> AgetLastElement(java.lang.Iterable<A> iterable)Deprecated.Returns the last element of the givenIterable.static <A> AgetLastElement(java.util.Iterator<A> iter)Deprecated.Returns the last element of the givenIterator.static <A> AgetLastElement(java.util.List<A> list)Deprecated.Returns the last element of the givenList.static <A> AgetLastElementOrNull(java.lang.Iterable<A> iterable)Deprecated.Returns the last element of the givenIterable, or null, if the iterable is empty.static <A> AgetLastElementOrNull(java.util.Iterator<A> iter)Deprecated.Returns the last element of the givenIterator, or null, if the iterator is empty.static MediaTypegetMediaType(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders)Deprecated.Returns the RestletMediaTypeof the given http headers (e.g.static java.util.Collection<java.lang.reflect.Method>getMethodsByName(java.lang.Class<?> clazz, java.lang.String methodName)Deprecated.Returns all publicMethods of the class with the given name (case-sensitive)static <A> AgetOnlyElement(java.util.Collection<A> list)Deprecated.Returns the only element of the list, or null, if the List is null or empty.static java.lang.StringgetOnlyMetadataName(java.util.List<? extends Metadata> metadatas)Deprecated.Returns the Name of the only element of the list of the given Metadata.static javax.ws.rs.PathgetPathAnnotation(java.lang.Class<?> jaxRsClass)Deprecated.Returns the @Pathannotation of the given root resource class.static javax.ws.rs.PathgetPathAnnotation(java.lang.reflect.Method method)Deprecated.Returns the @Pathannotation of the given sub resource locator.static javax.ws.rs.PathgetPathAnnotationOrNull(java.lang.reflect.Method method)Deprecated.Returns the @Pathannotation of the given sub resource locator.static java.lang.StringgetPathTemplateWithoutRegExps(java.lang.Class<?> resource)Deprecated.Returns the perhaps decoded template of the path annotation.static java.lang.StringgetPathTemplateWithoutRegExps(java.lang.reflect.Method method)Deprecated.Returns the path template of the given sub resource locator or sub resource method.static java.lang.StringgetPathTemplateWithoutRegExps(java.lang.String pathTemplate, javax.ws.rs.Path pathForExcMess)Deprecated.static java.lang.StringgetPathTemplateWithoutRegExps(javax.ws.rs.Path path)Deprecated.Returns the path from the annotation.static CharacterSetgetSupportedCharSet(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpResponseHeaders)Deprecated.Returns the character set of the http response headers.static CharacterSetgetSupportedCharSet(CharacterSet characterSet)Deprecated.Returns the given character set, if it is supported on this system.static intindexBeginMatrixOfLastSegment(java.lang.CharSequence path)Deprecated.Returns the index of the first ";" in the last path segment.static intindexOfBetween(java.lang.CharSequence charSequence, char c, int beginIndex, int endIndex)Deprecated.Returns the index of the first occurrence of the given character between the given indexes.static voidinject(java.lang.Object resource, java.lang.reflect.AccessibleObject fieldOrBeanSetter, java.lang.Object toInject)Deprecated.Injects the given toInject in the resource field or the given bean setter.static voidinject(java.lang.Object resource, java.lang.reflect.Field field, java.lang.Object toInject)Deprecated.Inject the given toInject into the given field in the given resource (or whatever)static voidinject(java.lang.Object resource, java.lang.reflect.Method beanSetter, java.lang.Object toInject)Deprecated.Injects the given toInject in the resource with the given bean setter.static voidinvokeMethod(java.lang.Object object, java.lang.reflect.Method javaMethod, java.lang.Object... args)Deprecated.Invokes the given method without parameters.static booleanisEmpty(java.lang.Object[] array)Deprecated.Tests, if the given array is empty or null.static booleanisEmpty(java.util.List<?> list)Deprecated.Checks, if the list is empty or null.static booleanisEmptyOrSlash(java.lang.String string)Deprecated.Tests, if the given String is null, empty or "/".static booleanisNotEmpty(java.util.List<?> list)Deprecated.Checks, if the list contains elements.static booleanisProvider(java.lang.Class<?> jaxRsClass)Deprecated.Checks, if the given class is a JAX-RS provider.static booleanisRootResourceClass(java.lang.Class<?> jaxRsClass)Deprecated.Checks, if the given class is a JAX-RS root resource class.private static CharacterSetlogUnsupportedCharSet(java.lang.String charsetName)Deprecated.Logs a message that the wished character set is not supported and UTF-8 is used.static booleannotEndsWith(java.lang.CharSequence charSequence, char character)Deprecated.Checks, if the given CharSequence ends with the given character.static booleannotStartsWith(java.lang.CharSequence charSequence, char character)Deprecated.Checks, if the given CharSequence starts with the given character.private static intprocessTemplVarname(java.lang.String pathTemplate, int braceIndex, java.lang.StringBuilder stb, javax.ws.rs.Path pathForExcMess)Deprecated.static java.util.List<MediaType>sortByConcreteness(java.util.Collection<MediaType> mediaTypes)Deprecated.static intspecificness(MediaType mediaType)Deprecated.Returns the specificness of the givenMediaType: 1 for any concrete type (contains no star) 0 for the types (anything/*) -1 for '*/*static booleanstartsWith(java.lang.CharSequence charSequence, char character)Deprecated.Checks, if the given CharSequence starts with the given character.static java.lang.Object[]toArray(java.util.Collection<?> coll, java.lang.Class<?> arrayType)Deprecated.Creates an Array of the given type.static java.lang.StringtoString(java.util.Collection<?> collection, java.lang.String delimiter)Deprecated.Concatenate the members of the Set to a String, separated with the given delimiter.
-
-
-
Field Detail
-
JAX_RS_DEFAULT_CHARACTER_SET
public static final CharacterSet JAX_RS_DEFAULT_CHARACTER_SET
Deprecated.The default character set to be used, if no character set is given.
-
JAX_RS_DEFAULT_CHARACTER_SET_AS_STRING
public static final java.lang.String JAX_RS_DEFAULT_CHARACTER_SET_AS_STRING
Deprecated.The default character set to be used, if no character set is given, as String- See Also:
JAX_RS_DEFAULT_CHARACTER_SET
-
MEDIA_TYPE_COMP
public static final java.util.Comparator<MediaType> MEDIA_TYPE_COMP
Deprecated.This comparator sorts the concrete MediaTypes to the beginning and the unconcrete to the end. The last is '*/*'
-
NAME_READ
private static final byte NAME_READ
Deprecated.- See Also:
- Constant Field Values
-
NAME_READ_READY
private static final byte NAME_READ_READY
Deprecated.- See Also:
- Constant Field Values
-
NAME_READ_START
private static final byte NAME_READ_START
Deprecated.- See Also:
- Constant Field Values
-
ORG_RESTLET_EXT_JAXRS_HTTP_HEADERS
public static final java.lang.String ORG_RESTLET_EXT_JAXRS_HTTP_HEADERS
Deprecated.The name of the headerMultivaluedMap<String, String> in the attribute map.- See Also:
- Constant Field Values
-
-
Method Detail
-
append
public static void append(java.lang.Appendable stb, java.lang.CharSequence string, boolean convertBraces) throws java.io.IOExceptionDeprecated.appends the given String to the StringBuilder. If convertBraces is true, all "{" and "}" are converted to "%7B" and "%7D"- Parameters:
stb- the Appendable to append onstring- the CharSequence to appendconvertBraces- if true, all braces are converted, if false then not.- Throws:
java.io.IOException- If the Appendable have a problem
-
append
public static void append(java.lang.Appendable stb, java.lang.CharSequence string, boolean convertBraces, int startIndex) throws java.io.IOExceptionDeprecated.appends the given String to the StringBuilder. If convertBraces is true, all "{" and "}" are converted to "%7B" and "%7D"- Parameters:
stb- the Appendable to append onstring- the CharSequence to appendconvertBraces- if true, all braces are converted, if false then not.startIndex-- Throws:
java.io.IOException- If the Appendable have a problem
-
append
public static void append(java.lang.Appendable stb, java.lang.CharSequence string, boolean convertBraces, int startIndex, int endIndex) throws java.io.IOExceptionDeprecated.appends the given String to the StringBuilder. If convertBraces is true, all "{" and "}" are converted to "%7B" and "%7D"- Parameters:
stb- the Appendable to append onstring- the CharSequence to appendconvertBraces- if true, all braces are converted, if false then not.startIndex-endIndex-- Throws:
java.io.IOException- If the Appendable have a problem
-
append
public static void append(java.lang.StringBuilder stb, java.lang.Object[] array)Deprecated.appends the array elements to theStringBuilder, separated by ", ".- Parameters:
stb- TheStringBuilderto append the array elements.array- The array to append to theStringBuilder.
-
checkClassAndInterfacesForAnnotation
private static boolean checkClassAndInterfacesForAnnotation(java.lang.Class<?> jaxRsClass, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)Deprecated.Indicates if the given class (and its implemented interfaces) are annotated with the given annotation.- Parameters:
jaxRsClass- The class to check.annotationClass- The class of the annotation .- Returns:
- True if the given class (and its implemented interfaces) are annotated with the given annotation.
-
checkClassConcrete
public static void checkClassConcrete(java.lang.Class<?> jaxRsClass, java.lang.String typeName) throws java.lang.IllegalArgumentExceptionDeprecated.Checks, if the class is concrete.- Parameters:
jaxRsClass- JAX-RS root resource class or JAX-RS provider.typeName- for the exception message "root resource class" or "provider"- Throws:
java.lang.IllegalArgumentException- if the class is not concrete.
-
copyResponseHeaders
public static void copyResponseHeaders(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> jaxRsHeaders, Response restletResponse)Deprecated.Copies headers into a response.- Parameters:
jaxRsHeaders- Headers of an JAX-RS-Response.restletResponse- Restlet Response to copy the headers in.- See Also:
Response.getMetadata()
-
copyResponseHeaders
public static Series<Header> copyResponseHeaders(Response restletResponse)
Deprecated.- Parameters:
restletResponse- The response to update. Should contain aRepresentationto copy the representation headers from it.- Returns:
- The copied headers.
-
createColl
@SafeVarargs public static <A> java.util.Collection<A> createColl(A... objects)
Deprecated.Creates an modifiable Collection with the given Objects in it, and no other objects. nulls will be ignored.- Type Parameters:
A-- Parameters:
objects-- Returns:
- Returns the created list with the given objects in it.
-
createList
@SafeVarargs public static <A> java.util.List<A> createList(A... objects)
Deprecated.Creates an modifiable List with the given Object in it, and no other objects. If the given object is null, than an empty List will returned- Type Parameters:
A-- Parameters:
objects-- Returns:
- Returns the created list with the given object in it or an empty list, if the given object is null.
-
createMap
public static java.util.Map<java.lang.String,java.lang.String> createMap(java.lang.String... keysAndValues)
Deprecated.Creates a map with the given keys and values.- Parameters:
keysAndValues- first element is key1, second element value1, third element key2, forth element value2 and so on.- Returns:
- the created Map
-
createSet
@SafeVarargs public static <A> java.util.Set<A> createSet(A... objects)
Deprecated.Creates an modifiable Set with the given Object in it, and no other objects. If the given object is null, than an empty Set will returned.- Type Parameters:
A-- Parameters:
objects-- Returns:
- the created Set
-
doesImplement
public static boolean doesImplement(java.lang.Class<?> clazz, java.lang.Class<?> interfaze)Deprecated.Checks, if the given class implements the given interface.- Parameters:
clazz-interfaze-- Returns:
- true, if the class implements the given interface, otherwise false. if the clazz or interfaze is null, false is returned
-
endsWith
public static boolean endsWith(java.lang.CharSequence charSequence, char character)Deprecated.Checks, if the given CharSequence ends with the given character.- Parameters:
charSequence-character-- Returns:
- true, if the given charSequence ends with the given character, otherwise false.
- See Also:
notEndsWith(CharSequence, char),startsWith(CharSequence, char)
-
equals
public static boolean equals(java.lang.Object object1, java.lang.Object object2)Deprecated.Check if the given objects are equal. Can deal with null references. if both elements are null, than the result is true.- Parameters:
object1-object2-- Returns:
- true, if the objects are equal.
-
formatDate
public static java.lang.String formatDate(java.util.Date date, boolean cookie)Deprecated.Converts the given Date into a String. Copied fromorg.restlet.engine.Call.- Parameters:
date- Date to formatcookie- if true, using RFC 1036 format, otherwise RFC 1123 format.- Returns:
- The formated date
-
formatDimensions
public static java.lang.String formatDimensions(java.util.Set<Dimension> dimensions)
Deprecated.Formats the givenSetofDimensions to a String for the HTTP Vary header.- Parameters:
dimensions- the dimensions to format.- Returns:
- the Vary header or null, if dimensions is null or empty.
-
getArrayClass
private static java.lang.Class<?> getArrayClass(java.lang.reflect.Type genCompType, java.lang.reflect.Type forMessage) throws java.lang.NegativeArraySizeException, ImplementationExceptionDeprecated.- Parameters:
genCompType-forMessage-- Throws:
java.lang.NegativeArraySizeExceptionImplementationException
-
getCharsetName
public static java.lang.String getCharsetName(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders, CharacterSet defaultCs)Deprecated.Returns the character set as String of the given http headers (e.g. from a JAX-RSResponse).- Parameters:
httpHeaders- the JAX-RSResponsedefaultCs- the character set to return, if no one could be found.- Returns:
- the Restlet
CharacterSetof the given http headers, or the given defaultCs as String if the header "Content-Type" is not available or has no parameter "charset". Returns only null, if the given defaultCs is null. - See Also:
getSupportedCharSet(MultivaluedMap)
-
getFirstElement
public static <A> A getFirstElement(java.util.Collection<A> coll) throws java.util.NoSuchElementExceptionDeprecated.Returns the first element of the given collection. Throws an exception if the collection is empty.- Type Parameters:
A-- Parameters:
coll-- Returns:
- Returns the first Element of the collection
- Throws:
java.util.NoSuchElementException- If the collection is empty.
-
getFirstElement
public static <A> A getFirstElement(java.lang.Iterable<A> coll) throws java.util.NoSuchElementExceptionDeprecated.Returns the first element of the givenIterable. Throws an exception if theIterableis empty.- Type Parameters:
A-- Parameters:
coll-- Returns:
- Returns the first Element of the collection
- Throws:
java.util.NoSuchElementException- If the collection is empty
-
getFirstElement
public static <A> A getFirstElement(java.util.List<A> list) throws java.lang.IndexOutOfBoundsExceptionDeprecated.Returns the first element of theList. Throws an exception if the list is empty.- Type Parameters:
A-- Parameters:
list-- Returns:
- Returns the first Element of the collection
- Throws:
java.lang.IndexOutOfBoundsException- If the list is empty
-
getFirstElementOrNull
public static <A> A getFirstElementOrNull(java.lang.Iterable<A> coll)
Deprecated.Returns the first element of the givenIterable. Returns null, if theIterableis empty.- Type Parameters:
A-- Parameters:
coll-- Returns:
- the first element of the collection, or null if the iterable is empty.
-
getFirstEntry
public static <K,V> java.util.Map.Entry<K,V> getFirstEntry(java.util.Map<K,V> map) throws java.util.NoSuchElementExceptionDeprecated.Returns the first entry of the givenMap. Throws an exception if the Map is empty.- Type Parameters:
K-V-- Parameters:
map-- Returns:
- the first entry of the given
Map. - Throws:
java.util.NoSuchElementException- If the map is empty.
-
getFirstKey
public static <K,V> K getFirstKey(java.util.Map<K,V> map) throws java.util.NoSuchElementExceptionDeprecated.Returns the key of the first entry of the givenMap. Throws an exception if the Map is empty.- Type Parameters:
K-V-- Parameters:
map-- Returns:
- the key of the first entry of the given
Map. - Throws:
java.util.NoSuchElementException- If the map is empty.
-
getFirstValue
public static <K,V> V getFirstValue(java.util.Map<K,V> map) throws java.util.NoSuchElementExceptionDeprecated.Returns the value of the first entry of the givenMap. Throws an exception if the Map is empty.- Type Parameters:
K-V-- Parameters:
map-- Returns:
- the value of the first entry of the given
Map. - Throws:
java.util.NoSuchElementException- If the map is empty.
-
getGenericClass
public static java.lang.Class<?> getGenericClass(java.lang.Class<?> clazz, java.lang.Class<?> implInterface)Deprecated.- Parameters:
clazz- The class which implemented interface should be checked.implInterface- the interface from which the generic type should be returned.- Returns:
- the type parameter of the given class.
-
getGenericClass
private static java.lang.Class<?> getGenericClass(java.lang.Class<?> clazz, java.lang.Class<?> implInterface, java.lang.reflect.Type[] gsatp)Deprecated.
-
getGenericClass
public static java.lang.Class<?> getGenericClass(java.lang.reflect.Type genericType)
Deprecated.Example: in List<String> -> out: String.class- Parameters:
genericType-- Returns:
- otherwise null
-
getHttpHeaders
public static Series<Header> getHttpHeaders(Request request)
Deprecated.- Parameters:
request-- Returns:
- Returns the HTTP headers of the Request.
-
getHttpHeaders
public static Series<Header> getHttpHeaders(Response response)
Deprecated.- Parameters:
response-- Returns:
- Returns the HTTP headers of the Response.
-
getJaxRsHttpHeaders
public static javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getJaxRsHttpHeaders(Request request)
Deprecated.Returns the request headers asMultivaluedMap.- Parameters:
request-- Returns:
- the request headers as
MultivaluedMap.
-
getLastElement
public static <A> A getLastElement(java.lang.Iterable<A> iterable) throws java.lang.IndexOutOfBoundsException, java.util.NoSuchElementExceptionDeprecated.Returns the last element of the givenIterable. Throws an exception if the given iterable is empty.- Type Parameters:
A-- Parameters:
iterable-- Returns:
- Returns the last element of the
Iterable - Throws:
java.lang.IndexOutOfBoundsException- If theIterableis aListand its is empty.java.util.NoSuchElementException- If theIterableis empty and theIterableis not aList.
-
getLastElement
public static <A> A getLastElement(java.util.Iterator<A> iter) throws java.util.NoSuchElementExceptionDeprecated.Returns the last element of the givenIterator. Throws an exception if the given iterator is empty.- Type Parameters:
A-- Parameters:
iter-- Returns:
- Returns the last element of the
Iterator. - Throws:
java.util.NoSuchElementException- If theIteratoris empty.
-
getLastElement
public static <A> A getLastElement(java.util.List<A> list) throws java.lang.IndexOutOfBoundsExceptionDeprecated.Returns the last element of the givenList. Throws an exception if the given list is empty.- Type Parameters:
A-- Parameters:
list-- Returns:
- Returns the last element of the list
- Throws:
java.lang.IndexOutOfBoundsException- If the list is empty
-
getLastElementOrNull
public static <A> A getLastElementOrNull(java.lang.Iterable<A> iterable)
Deprecated.Returns the last element of the givenIterable, or null, if the iterable is empty. Returns null, if the iterable is empty.- Type Parameters:
A-- Parameters:
iterable-- Returns:
- Returns the last Element of the
Iterable, or null if it is empty.
-
getLastElementOrNull
public static <A> A getLastElementOrNull(java.util.Iterator<A> iter)
Deprecated.Returns the last element of the givenIterator, or null, if the iterator is empty. Returns null, if the iterator is empty.- Type Parameters:
A-- Parameters:
iter-- Returns:
- Returns the last Element of the
Iterator.
-
getMediaType
public static MediaType getMediaType(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders)
Deprecated.Returns the RestletMediaTypeof the given http headers (e.g. from a JAX-RSResponse).- Parameters:
httpHeaders- the JAX-RSResponse- Returns:
- the Restlet
MediaTypeof the given http headers, or null, if the header "Content-Type" is not available.
-
getMethodsByName
public static java.util.Collection<java.lang.reflect.Method> getMethodsByName(java.lang.Class<?> clazz, java.lang.String methodName) throws java.lang.IllegalArgumentExceptionDeprecated.Returns all publicMethods of the class with the given name (case-sensitive)- Parameters:
clazz- TheClassto search theMethods.methodName- The name of theMethodto search.- Returns:
- Returns a
Collectionall ofMethods with the given name. Never returns null. If no methods are found an empty Collection will be returned. The methodIterator.remove()of this collection is supported. - Throws:
java.lang.IllegalArgumentException- if the clazz or the method name is null.
-
getOnlyElement
public static <A> A getOnlyElement(java.util.Collection<A> list) throws java.lang.IllegalArgumentExceptionDeprecated.Returns the only element of the list, or null, if the List is null or empty.- Type Parameters:
A-- Parameters:
list- a List with at most one element- Returns:
- The element of the List, or null, if there is no element.
- Throws:
java.lang.IllegalArgumentException- if the list contains more than one element.
-
getOnlyMetadataName
public static java.lang.String getOnlyMetadataName(java.util.List<? extends Metadata> metadatas)
Deprecated.Returns the Name of the only element of the list of the given Metadata. Returns null, if the list is empty or null.- Parameters:
metadatas-- Returns:
- the name of the Metadata
- See Also:
#getOnlyElement(List)
-
getPathAnnotation
public static javax.ws.rs.Path getPathAnnotation(java.lang.Class<?> jaxRsClass) throws MissingAnnotationException, java.lang.IllegalArgumentExceptionDeprecated.Returns the @Pathannotation of the given root resource class.- Parameters:
jaxRsClass- the root resource class.- Returns:
- the @
Pathannotation of the given root resource class. - Throws:
MissingAnnotationException- if the path annotation is missingjava.lang.IllegalArgumentException- if the jaxRsClass is null.
-
getPathAnnotation
public static javax.ws.rs.Path getPathAnnotation(java.lang.reflect.Method method) throws java.lang.IllegalArgumentException, MissingAnnotationExceptionDeprecated.Returns the @Pathannotation of the given sub resource locator. Throws an exception if no @Pathannotation is available.- Parameters:
method- the java method to get the @Path from- Returns:
- the @Path annotation.
- Throws:
java.lang.IllegalArgumentException- if null was given.MissingAnnotationException- if the annotation is not present.
-
getPathAnnotationOrNull
public static javax.ws.rs.Path getPathAnnotationOrNull(java.lang.reflect.Method method) throws java.lang.IllegalArgumentExceptionDeprecated.Returns the @Pathannotation of the given sub resource locator. Returns null if no @Pathannotation is available.- Parameters:
method- the java method to get the @Path from- Returns:
- the @Path annotation or null, if not present.
- Throws:
java.lang.IllegalArgumentException- if the method is null.
-
getPathTemplateWithoutRegExps
public static java.lang.String getPathTemplateWithoutRegExps(java.lang.Class<?> resource) throws IllegalPathOnClassException, MissingAnnotationException, java.lang.IllegalArgumentExceptionDeprecated.Returns the perhaps decoded template of the path annotation.- Parameters:
resource-- Returns:
- Returns the path template as String. Never returns null.
- Throws:
IllegalPathOnClassExceptionMissingAnnotationExceptionjava.lang.IllegalArgumentException
-
getPathTemplateWithoutRegExps
public static java.lang.String getPathTemplateWithoutRegExps(java.lang.reflect.Method method) throws java.lang.IllegalArgumentException, IllegalPathOnMethodException, MissingAnnotationExceptionDeprecated.Returns the path template of the given sub resource locator or sub resource method. It is encoded (if necessary) and valid.- Parameters:
method- the java method- Returns:
- the path template
- Throws:
IllegalPathOnMethodExceptionjava.lang.IllegalArgumentExceptionMissingAnnotationException
-
getPathTemplateWithoutRegExps
public static java.lang.String getPathTemplateWithoutRegExps(javax.ws.rs.Path path) throws IllegalPathExceptionDeprecated.Returns the path from the annotation. It will be encoded if necessary. If it should not be encoded, this method checks, if all characters are valid.- Parameters:
path- ThePathannotation. Must not be null.- Returns:
- the encoded path template
- Throws:
IllegalPathException- See Also:
Path#encode()
-
getPathTemplateWithoutRegExps
public static java.lang.String getPathTemplateWithoutRegExps(java.lang.String pathTemplate, javax.ws.rs.Path pathForExcMess) throws IllegalPathExceptionDeprecated.- Parameters:
pathTemplate-pathForExcMess-- Returns:
- Throws:
IllegalPathException
-
getSupportedCharSet
public static CharacterSet getSupportedCharSet(CharacterSet characterSet)
Deprecated.Returns the given character set, if it is supported on this system. Returns UTF-8 otherwise.- Parameters:
characterSet- the wishedCharacterSet- Returns:
- a supported
CharacterSet, never null. - See Also:
getCharsetName(MultivaluedMap, CharacterSet)
-
getSupportedCharSet
public static CharacterSet getSupportedCharSet(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpResponseHeaders)
Deprecated.Returns the character set of the http response headers. If no character set is available or it is not supported, UFT-8 is returned.- Parameters:
httpResponseHeaders-- Returns:
- a supported
CharacterSet, never null. - See Also:
getCharsetName(MultivaluedMap, CharacterSet)
-
indexBeginMatrixOfLastSegment
public static int indexBeginMatrixOfLastSegment(java.lang.CharSequence path)
Deprecated.Returns the index of the first ";" in the last path segment.- Parameters:
path- the path, without a query.- Returns:
- the index of the first ";" in the last path segment. Returns -1, if no ';' is available.
-
indexOfBetween
public static int indexOfBetween(java.lang.CharSequence charSequence, char c, int beginIndex, int endIndex)Deprecated.Returns the index of the first occurrence of the given character between the given indexes.- Parameters:
charSequence- the char sequence to look inc- the character to look for.beginIndex-endIndex-- Returns:
- the index of the given character between the given indexes, or -1 if the character could not be found in the given range.
- See Also:
String.indexOf(String, int),String.substring(int, int)
-
inject
public static void inject(java.lang.Object resource, java.lang.reflect.AccessibleObject fieldOrBeanSetter, java.lang.Object toInject) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalArgumentException, InjectExceptionDeprecated.Injects the given toInject in the resource field or the given bean setter.- Parameters:
resource-fieldOrBeanSetter-toInject-- Throws:
java.lang.reflect.InvocationTargetExceptionjava.lang.IllegalArgumentExceptionInjectException
-
inject
public static void inject(java.lang.Object resource, java.lang.reflect.Field field, java.lang.Object toInject) throws InjectExceptionDeprecated.Inject the given toInject into the given field in the given resource (or whatever)- Parameters:
resource- the concrete Object to inject the other object in. If the field is static, thsi object may be null.field- the field to inject the third parameter in.toInject- the object to inject in the first parameter object.- Throws:
InjectException- if the injection was not possible. SeeThrowable.getCause()for the reason.
-
inject
public static void inject(java.lang.Object resource, java.lang.reflect.Method beanSetter, java.lang.Object toInject) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalArgumentException, InjectExceptionDeprecated.Injects the given toInject in the resource with the given bean setter.- Parameters:
resource-beanSetter-toInject-- Throws:
java.lang.reflect.InvocationTargetExceptionjava.lang.IllegalArgumentExceptionInjectException
-
invokeMethod
public static void invokeMethod(java.lang.Object object, java.lang.reflect.Method javaMethod, java.lang.Object... args) throws MethodInvokeException, java.lang.reflect.InvocationTargetException, java.lang.IllegalArgumentExceptionDeprecated.Invokes the given method without parameters. This constraint is not checked; but the method could also be called, if access is normally not allowed.
If no javaMethod is given, nothing happens.- Parameters:
object- the object to call the method on.javaMethod- the method to callargs- the arguments of the method- Throws:
MethodInvokeExceptionjava.lang.reflect.InvocationTargetExceptionjava.lang.IllegalArgumentException- if at least one argument does not match the required method parameters.- See Also:
inject(Object, Field, Object),#findPostConstructMethod(Class),#findPreDestroyMethod(Class)
-
isEmpty
public static boolean isEmpty(java.util.List<?> list)
Deprecated.Checks, if the list is empty or null.- Parameters:
list-- Returns:
- true, if the list is empty or null, or false, if the list contains elements.
- See Also:
isEmpty(Object[])
-
isEmpty
public static boolean isEmpty(java.lang.Object[] array)
Deprecated.Tests, if the given array is empty or null. Will not throw a NullPointerException.- Parameters:
array-- Returns:
- Returns true, if the given array ist null or has zero elements, otherwise false.
- See Also:
isEmpty(List)
-
isEmptyOrSlash
public static boolean isEmptyOrSlash(java.lang.String string)
Deprecated.Tests, if the given String is null, empty or "/". Will not throw a NullPointerException.- Parameters:
string-- Returns:
- Returns true, if the given string ist null, empty or equals "/", otherwise false.
-
isNotEmpty
public static boolean isNotEmpty(java.util.List<?> list)
Deprecated.Checks, if the list contains elements.- Parameters:
list-- Returns:
- true, if the list contains elements, or false, if the list is empty or null.
-
isProvider
public static boolean isProvider(java.lang.Class<?> jaxRsClass)
Deprecated.Checks, if the given class is a JAX-RS provider.- Parameters:
jaxRsClass- the class to check- Returns:
- true, if the class is a JAX-RS provider, otherwise false.
-
isRootResourceClass
public static boolean isRootResourceClass(java.lang.Class<?> jaxRsClass)
Deprecated.Checks, if the given class is a JAX-RS root resource class.- Parameters:
jaxRsClass- the class to check- Returns:
- true, if the class is a JAX-RS root resource class, otherwise false.
-
logUnsupportedCharSet
private static CharacterSet logUnsupportedCharSet(java.lang.String charsetName)
Deprecated.Logs a message that the wished character set is not supported and UTF-8 is used.- Parameters:
csn-- Returns:
- UFT-8
-
notEndsWith
public static boolean notEndsWith(java.lang.CharSequence charSequence, char character)Deprecated.Checks, if the given CharSequence ends with the given character.- Parameters:
charSequence-character-- Returns:
- true, if the given charSequence ends with the given character, otherwise false.
- See Also:
endsWith(CharSequence, char),notStartsWith(CharSequence, char)
-
notStartsWith
public static boolean notStartsWith(java.lang.CharSequence charSequence, char character)Deprecated.Checks, if the given CharSequence starts with the given character.- Parameters:
charSequence-character-- Returns:
- true, if the given charSequence starts with the given character, otherwise false.
- See Also:
startsWith(CharSequence, char),notEndsWith(CharSequence, char)
-
processTemplVarname
private static int processTemplVarname(java.lang.String pathTemplate, int braceIndex, java.lang.StringBuilder stb, javax.ws.rs.Path pathForExcMess) throws IllegalPathExceptionDeprecated.- Parameters:
pathTemplate-braceIndex-stb-pathForExcMess-- Throws:
IllegalPathException
-
sortByConcreteness
public static java.util.List<MediaType> sortByConcreteness(java.util.Collection<MediaType> mediaTypes)
Deprecated.Returns a newList, which contains allMediaTypes of the given List, sorted by it's concreteness, the concreteMediaTypeat the beginning.- Parameters:
mediaTypes-- Returns:
- the sorted media types
- See Also:
specificness(org.restlet.data.MediaType)
-
specificness
public static int specificness(MediaType mediaType)
Deprecated.Returns the specificness of the givenMediaType:- 1 for any concrete type (contains no star)
- 0 for the types (anything/*)
- -1 for '*/*
- Parameters:
mediaType-- Returns:
- 1, 0 or -1
- See Also:
#isConcrete(org.restlet.data.MediaType),sortByConcreteness(Collection)
-
startsWith
public static boolean startsWith(java.lang.CharSequence charSequence, char character)Deprecated.Checks, if the given CharSequence starts with the given character.- Parameters:
charSequence-character-- Returns:
- true, if the given charSequence starts with the given character, otherwise false.
- See Also:
notStartsWith(CharSequence, char),endsWith(CharSequence, char)
-
toArray
public static java.lang.Object[] toArray(java.util.Collection<?> coll, java.lang.Class<?> arrayType)Deprecated.Creates an Array of the given type.- Parameters:
coll-arrayType-- Returns:
- the object array
- Throws:
java.lang.NegativeArraySizeException
-
toString
public static java.lang.String toString(java.util.Collection<?> collection, java.lang.String delimiter)Deprecated.Concatenate the members of the Set to a String, separated with the given delimiter.- Parameters:
collection-delimiter-- Returns:
- the concatenated
-
-