diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Reflections.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Reflections.java index 658b687..b4ecc27 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Reflections.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Reflections.java @@ -36,6 +36,7 @@ */ package br.gov.frameworkdemoiselle.util; +import java.io.InputStream; import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Method; @@ -55,24 +56,24 @@ import java.util.List; public class Reflections { protected Reflections() { - //Impede instanciar subclasses desse tipo. + // Impede instanciar subclasses desse tipo. throw new UnsupportedOperationException(); } /** - * Return the parametized type used with a concrete implementation of - * a class that accepts generics. + * Return the parametized type used with a concrete implementation of a class that accepts generics. Ex: If you + * declare * - * Ex: If you declare - *
+ *
+ *
* public class SpecializedCollection implements Collection {
* // ...
* }
- *
- *
- * then the code getGenericTypeArgument(SpecializedCollection.class , 0);
will
- * return the type SpecializedType
.
+ *
+ *
*
+ * then the code getGenericTypeArgument(SpecializedCollection.class , 0);
will return the type
+ * SpecializedType
.
*/
@SuppressWarnings("unchecked")
public static Return the parametized type passed to field types that accepts Generics.
+ *+ * Return the parametized type passed to field types that accepts Generics. + *
+ *+ * Ex: If you declare * - *
Ex: If you declare - *
+ *
+ *
* public class MyClass{
* private Collection<String> myStringCollection;
* }
- *
- *
- * then the code getGenericTypeArgument( MyClass.class.getDeclaredField("myStringCollection") , 0);
will
- * return the type String
.
+ *
+ *
*
+ * then the code getGenericTypeArgument( MyClass.class.getDeclaredField("myStringCollection") , 0);
+ * will return the type String
.
*/
@SuppressWarnings("unchecked")
public static Return the parametized type passed to members (fields or methods) that accepts Generics.
+ *+ * Return the parametized type passed to members (fields or methods) that accepts Generics. + *
* * @see #getGenericTypeArgument(Field field, int idx) - * */ public staticReturn the parametized type passed to methods that accepts Generics.
+ *+ * Return the parametized type passed to methods that accepts Generics. + *
* * @see #getGenericTypeArgument(Field field, int idx) - * */ @SuppressWarnings("unchecked") public static- * Replaces the numbers between braces in the given string with the given parameters. - * The process will replace a number between braces for the parameter for which its order - * in the set of parameters matches with the number of the given string. + * Replaces the numbers between braces in the given string with the given parameters. The process will replace a + * number between braces for the parameter for which its order in the set of parameters matches with the number of + * the given string. *
- * For exemple, if is received the following string "Treats an {0} exception" and the set of parameters
- * {"DemoiselleException"}, the return will be the following string: "Treats an DemoiselleException exception".
+ * For exemple, if is received the following string "Treats an {0} exception" and the set of parameters
+ * {"DemoiselleException"}, the return will be the following string: "Treats an DemoiselleException exception".
*
- * @param string
- * with the numbers with braces to be replaced with the parameters.
+ * @param string
+ * with the numbers with braces to be replaced with the parameters.
* @param params
- * parameters that will replace the number with braces in the given string.
- * @return String
- * string with numbers replaced with the matching parameter.
+ * parameters that will replace the number with braces in the given string.
+ * @return String string with numbers replaced with the matching parameter.
*/
public static String getString(final String string, final Object... params) {
String result = null;
@@ -152,23 +165,19 @@ public final class Strings {
* Verifies if a given string is empty or null.
*
* @param string
- * string to be verified.
- *
- * @return boolean
- * returns true if the given string is empty or null and returns false otherwise.
+ * string to be verified.
+ * @return boolean returns true if the given string is empty or null and returns false otherwise.
*/
public static boolean isEmpty(String string) {
return string == null || string.trim().isEmpty();
}
/**
- * Converts any object to string.
+ * Converts any object to string.
*
* @param object
- * object to be converted.
- *
- * @return String
- * the given object converted to string.
+ * object to be converted.
+ * @return String the given object converted to string.
*/
public static String toString(Object object) {
StringBuffer result = new StringBuffer();
@@ -202,14 +211,13 @@ public final class Strings {
}
/**
- * Replace the camel case string for a lowercase string separated for a given symbol.
+ * Replace the camel case string for a lowercase string separated for a given symbol.
*
* @param string
- * string that separeted with camel case.
+ * string that separeted with camel case.
* @param symbol
- * simbol to be the new separator for the given string.
- * @return String
- * the given string separated with the given symbol.
+ * simbol to be the new separator for the given string.
+ * @return String the given string separated with the given symbol.
*/
public static String camelCaseToSymbolSeparated(String string, String symbol) {
if (symbol == null) {
@@ -220,12 +228,10 @@ public final class Strings {
}
/**
- * Sets the first character of a given string to upper case.
+ * Sets the first character of a given string to upper case.
*
* @param string
- *
- * @return String
- * the given string with the first character setted to upper case.
+ * @return String the given string with the first character setted to upper case.
*/
public static String firstToUpper(String string) {
String result = string;
@@ -238,12 +244,10 @@ public final class Strings {
}
/**
- * Removes braces from a given string.
+ * Removes braces from a given string.
*
* @param string
- *
- * @return String
- * the given string without braces.
+ * @return String the given string without braces.
*/
public static String removeBraces(String string) {
String result = string;
@@ -256,12 +260,10 @@ public final class Strings {
}
/**
- * Inserts braces in a given string.
+ * Inserts braces in a given string.
*
* @param string
- *
- * @return String
- * the given string with braces.
+ * @return String the given string with braces.
*/
public static String insertBraces(String string) {
String result = string;
@@ -272,4 +274,28 @@ public final class Strings {
return result;
}
+
+ public static String parse(InputStream inputStream) throws IOException {
+ StringBuilder result = new StringBuilder();
+
+ if (inputStream != null) {
+ BufferedReader reader = null;
+
+ try {
+ reader = new BufferedReader(new InputStreamReader(inputStream));
+ String line;
+
+ while ((line = reader.readLine()) != null) {
+ result.append(line);
+ }
+
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+
+ return result.length() > 0 ? result.toString() : null;
+ }
}
diff --git a/pom.xml b/pom.xml
index f80f309..5c46d1f 100755
--- a/pom.xml
+++ b/pom.xml
@@ -81,9 +81,9 @@