Skip to content

Commit

Permalink
Added JavaDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
breucode committed May 6, 2020
1 parent 3c6e461 commit b6684e9
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 7 deletions.
64 changes: 58 additions & 6 deletions src/main/java/com/poiji/bind/Poiji.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,54 @@ public final class Poiji {
private Poiji() {
}

/**
* converts excel properties into an object
*
* @param file excel file ending with .xlsx.
* @param type type of the root object.
* @param <T> type of the root object.
* @return the newly created objects
* @throws PoijiException if an internal exception occurs during the mapping process.
* @throws InvalidExcelFileExtension if the specified excel file extension is invalid.
* @throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final.
* @see Poiji#fromExcelProperties(File, Class, PoijiOptions)
*/
public static <T> T fromExcelProperties(final File file, final Class<T> type) {
return fromExcelProperties(file, type, PoijiOptionsBuilder.settings().build());
}

/**
* converts excel properties into an object
*
* @param inputStream excel file stream
* @param excelType type of the excel file, xlsx only!
* @param type type of the root object.
* @param <T> type of the root object.
* @return the newly created object
* @throws PoijiException if an internal exception occurs during the mapping process.
* @throws InvalidExcelFileExtension if the specified excel file extension is invalid.
* @throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final.
* @see Poiji#fromExcelProperties(InputStream, PoijiExcelType, Class, PoijiOptions)
*/
public static <T> T fromExcelProperties(final InputStream inputStream,
PoijiExcelType excelType,
final Class<T> type) {
return fromExcelProperties(inputStream, excelType, type, PoijiOptionsBuilder.settings().build());
}

/**
* converts excel properties into an object
*
* @param file excel file ending with .xlsx.
* @param type type of the root object.
* @param <T> type of the root object.
* @param options specifies to change the default behaviour of the poiji. In this case, only the password has an effect
* @return the newly created object
* @throws PoijiException if an internal exception occurs during the mapping process.
* @throws InvalidExcelFileExtension if the specified excel file extension is invalid.
* @throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final.
* @see Poiji#fromExcelProperties(File, Class)
*/
public static <T> T fromExcelProperties(final File file, final Class<T> type, final PoijiOptions options) {
String extension = files.getExtension(file.getName());

Expand All @@ -74,6 +112,20 @@ public static <T> T fromExcelProperties(final File file, final Class<T> type, fi
}
}

/**
* converts excel properties into an object
*
* @param inputStream excel file stream
* @param excelType type of the excel file, xlsx only!
* @param type type of the root object.
* @param <T> type of the root object.
* @param options specifies to change the default behaviour of the poiji. In this case, only the password has an effect
* @return the newly created object
* @throws PoijiException if an internal exception occurs during the mapping process.
* @throws InvalidExcelFileExtension if the specified excel file extension is invalid.
* @throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final.
* @see Poiji#fromExcelProperties(InputStream, PoijiExcelType, Class)
*/
public static <T> T fromExcelProperties(final InputStream inputStream,
PoijiExcelType excelType,
final Class<T> type,
Expand Down Expand Up @@ -101,7 +153,7 @@ public static <T> T fromExcelProperties(final InputStream inputStream,
* @param file excel file ending with .xls or .xlsx.
* @param type type of the root object.
* @param <T> type of the root object.
* @return the newly created a list of objects
* @return the newly created list of objects
* @throws PoijiException if an internal exception occurs during the mapping process.
* @throws InvalidExcelFileExtension if the specified excel file extension is invalid.
* @throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final.
Expand Down Expand Up @@ -139,11 +191,11 @@ public static <T> void fromExcel(final File file, final Class<T> type, final Con
* @param excelType type of the excel file, xls or xlsx
* @param type type of the root object.
* @param <T> type of the root object.
* @return the newly created a list of objects
* @return the newly created list of objects
* @throws PoijiException if an internal exception occurs during the mapping process.
* @throws InvalidExcelFileExtension if the specified excel file extension is invalid.
* @throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final.
* @see Poiji#fromExcel(File, Class, PoijiOptions)
* @see Poiji#fromExcel(InputStream, PoijiExcelType, Class, PoijiOptions)
*/
public static <T> List<T> fromExcel(final InputStream inputStream,
PoijiExcelType excelType,
Expand Down Expand Up @@ -183,7 +235,7 @@ public static <T> void fromExcel(final InputStream inputStream,
* @param type type of the root object.
* @param <T> type of the root object.
* @param options specifies to change the default behaviour of the poiji.
* @return the newly created a list of objects
* @return the newly created list of objects
* @throws PoijiException if an internal exception occurs during the mapping process.
* @throws InvalidExcelFileExtension if the specified excel file extension is invalid.
* @throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final.
Expand Down Expand Up @@ -221,11 +273,11 @@ public static <T> void fromExcel(final File file, final Class<T> type, final Poi
* @param type type of the root object.
* @param <T> type of the root object.
* @param options specifies to change the default behaviour of the poiji.
* @return the newly created a list of objects
* @return the newly created list of objects
* @throws PoijiException if an internal exception occurs during the mapping process.
* @throws InvalidExcelFileExtension if the specified excel file extension is invalid.
* @throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final.
* @see Poiji#fromExcel(File, Class)
* @see Poiji#fromExcel(InputStream, PoijiExcelType, Class)
*/
public static <T> List<T> fromExcel(final InputStream inputStream,
final PoijiExcelType excelType,
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/poiji/bind/mapping/PropertyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ private PropertyHandler() {

}

/**
* Creates an instance of {@code type} and deserializes the {@code poixmlProperties} into the fields annotated with {@link ExcelProperty}
* @param type The type to deserialize into
* @param poixmlProperties The properties to read from
* @param <T> The type to deserialize into
* @return An instance of {@code type}
*/
public static <T> T unmarshal(Class<T> type, POIXMLProperties poixmlProperties) {

T unmarshalledObject = ReflectUtil.newInstanceOf(type);
Expand Down Expand Up @@ -89,7 +96,6 @@ private static void setPropertyValueOnTarget(String propertyName, POIXMLProperti
if (poixmlProperties.getCustomProperties().getProperty(propertyName) != null) {
ReflectUtil.setFieldData(targetField, poixmlProperties.getCustomProperties().getProperty(propertyName).getLpwstr(), targetObject);
}

break;
}
}
Expand Down

0 comments on commit b6684e9

Please sign in to comment.