|
| 1 | +# EasyCommons-EasyObjectUtils |
| 2 | + |
| 3 | +--------------- |
| 4 | +EasyImageUtils is [EasyCommons](https://github.com/ushelp/EasyCommons "EasyCommons") project group image processing component. |
| 5 | + |
| 6 | + |
| 7 | +EasyObjectUtils is EasyCommons project group Obejct operations component. |
| 8 | + |
| 9 | +## 1. EasyObject FieldExpression language |
| 10 | + |
| 11 | +EasyObjectUtils the tools used to **EasyObject FieldExpression (field expression) language** for property positioning when you operate object. |
| 12 | + |
| 13 | +**Syntax:** |
| 14 | +``` |
| 15 | +Specified attributes: property |
| 16 | +Specify the attribute that: property.property |
| 17 | +Each object in the specified collection: {collection} |
| 18 | +Each object in the specified array: [array] Attribute specifies for each object in the collection: {collection} .property |
| 19 | +Attribute specifies for each object in the array: [array] .property |
| 20 | +
|
| 21 | +Alias definitions (only for EasyObjectExtract): FieldExpression#Alias |
| 22 | +``` |
| 23 | + |
| 24 | +## 2. API |
| 25 | +EasyObjectUtils It includes the following components: |
| 26 | + |
| 27 | +1. **EasyObjectExtract**:Extraction of the object. Using field expression from the object (`FieldExpression`) to extract the specified property deposited **key-value** Map collection. |
| 28 | + **Scene**: JSON output, specify the output attributes and values extracted from the object. |
| 29 | + ```JAVA |
| 30 | + /** |
| 31 | + * Two ways to modify the properties file (instead of store method): |
| 32 | + * - Merge: The Properties object into the specified file (add, change, delete) |
| 33 | + * - Modify: Modify the Properties object to the specified file (add, change, delete the original file does not include having a parameter) |
| 34 | + * |
| 35 | + *@param object the object data to be extracted |
| 36 | + *@param collection object data set to be extracted |
| 37 | + *@param array array object data to be extracted |
| 38 | + *@param fieldExpressionAndOutNameMap Map list field expression and output alias, optional default field expression name as the output name |
| 39 | + *@param fieldExpressions A list of the fields to be extracted expression, variable parameters, is case-sensitive; support hash character alias definition |
| 40 | + *@return Map collection extracted results |
| 41 | + */ |
| 42 | + Map extract(object [, fieldExpressionAndOutNameMap], fieldExpressions) |
| 43 | + List<Map> extract(collection [, fieldExpressionAndOutNameMap], fieldExpressions) |
| 44 | + List<Map> extract(array [, fieldExpressionAndOutNameMap], fieldExpressions) |
| 45 | + ``` |
| 46 | + ** Example:** |
| 47 | + ```JAVA |
| 48 | + List<Map> list = EasyObjectExtract.extract(getData(), |
| 49 | + "userId", "name", "status", "{sysRoles}.name#roleNames", |
| 50 | + "{sysRoles}.roleId#roleIds"); |
| 51 | + ``` |
| 52 | + |
| 53 | +2. **EasyObjectFilter**:Object filtering. The JavaBean object properties of special characters (<,>, ...) to filter out, into the escape character; or custom character transformation maps. |
| 54 | + **Scene** : the special character JavaBean object properties contains a string to filter into character entity; or a character string property objects included replacing all the specified character. For example, the data in the file upload Struts2 package submitted to the object, a special string to the user object may contain submitted escaped. |
| 55 | + ```JAVA |
| 56 | + /** |
| 57 | + * Special character filtering object attribute contains the string, the default Replace <,> is the character entity & lt ;, & gt |
| 58 | + * |
| 59 | + *@param object Object to filter content |
| 60 | + *@param collection set of objects you want to filter content |
| 61 | + *@param array object array to filter content |
| 62 | + *@param specialCharacterMap Filter mapping listparam specialCharacterMap custom (key for the character you want to filter, value character filtered) |
| 63 | + *@param DoNotFieldArray does not filter the array of field names |
| 64 | + */ |
| 65 | + filter(object [, specialCharacterMap] [, doNotFieldArray]); |
| 66 | + filter(collection [, specialCharacterMap] [, doNotFieldArray]); |
| 67 | + filter(array [, specialCharacterMap] [, doNotFieldArray]); |
| 68 | + ``` |
| 69 | + |
| 70 | + **Example:** |
| 71 | + ```JAVA |
| 72 | + Map replaceMap=new HashMap(); |
| 73 | + replaceMap.put("drug","*"); |
| 74 | + replaceMap.put("fuck","F***"); |
| 75 | + EasyObjectExtract.filter(news,replaceMap); |
| 76 | + ``` |
| 77 | + |
| 78 | +3. **EasyObjectSetNull**:Object Properties empty. Using field expressions (`FieldExpression`) specified property set to null object. |
| 79 | + **Scene** : Hibernate object loaded some delay attribute set can not be loaded is empty, to prevent abnormal when no session serialized property. |
| 80 | + ```JAVA |
| 81 | + /** |
| 82 | + * The field is set to the value specified for the null FieldExpression |
| 83 | + * |
| 84 | + *@param Object setNUll of the object to be over |
| 85 | + *@param Collection of objects you want to lead a collection of objects setNUll |
| 86 | + *@param Array array object to object to lead setNUll |
| 87 | + * Expression array list fieldExpressions segmentparam, uncertain parameters |
| 88 | + */ |
| 89 | + setNull(Object, fieldExpressions) |
| 90 | + setNull(Collection, fieldExpressions) |
| 91 | + setNull(Object[], fieldExpressions) |
| 92 | + ``` |
| 93 | + **Example:** |
| 94 | + ```JAVA |
| 95 | + EasyObjectSetNull.setNull(users, "password","{roles}.rights"); |
| 96 | + ``` |
| 97 | + |
| 98 | +## 3. Maven |
| 99 | +```XML |
| 100 | +<!-- EasyObjectUtils --> |
| 101 | +<dependency> |
| 102 | + <groupId>cn.easyproject</groupId> |
| 103 | + <artifactId>easycommons-object</artifactId> |
| 104 | + <version>1.7.4-RELEASE</version> |
| 105 | +</dependency> |
| 106 | +``` |
| 107 | + |
| 108 | + |
| 109 | +## End |
| 110 | + |
| 111 | +[Comments](http://www.easyproject.cn/easycommons/en/index.jsp#about 'Comments') |
| 112 | + |
| 113 | +If you have more comments, suggestions or ideas, please contact me. |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | +[http://www.easyproject.cn](http://www.easyproject.cn "EasyProject Home") |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | +[http://www.easyproject.cn](http://www.easyproject.cn "EasyProject Home") |
0 commit comments