[ 
https://issues.apache.org/jira/browse/XMLBEANS-432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12971243#action_12971243
 ] 

Raino Kolk commented on XMLBEANS-432:
-------------------------------------

I added patch for prepost handler. Not perfect but petter than nothing

I introduced new PrePostExtension types
/** Operation code for setting a property with null value. */
    int OPERATION_SET_NIL = 4;
    
    /** Operation code for inserting a property with value. */
    int OPERATION_INSERT_WVAL = 5;

There are cases vhen object is null but set (or insert) should be executed

Because simple types cant convert themself to Object ( maybe should cast to 
object) I have to create some additional hanler methods
    
    public static boolean preSet(int opType, XmlObject xo, QName prop, boolean 
isAttr, int index, float value) {
        return true;
    }
    
    public static boolean preSet(int opType, XmlObject xo, QName prop, boolean 
isAttr, int index, long value) {
        return true;
    }
    
    public static boolean preSet(int opType, XmlObject xo, QName prop, boolean 
isAttr, int index, boolean value) {
        return true;
    }

and most important now i can use object value in preSet
public static boolean preSet(int opType, XmlObject xo, QName prop, boolean 
isAttr, int index, Object value) {
        if (value == null && (PrePostExtension.OPERATION_SET == opType || 
PrePostExtension.OPERATION_INSERT == opType)) {
            return false;
        }
        return true;
    }

> Add the value that will be set to the PrePostSetFeature interface
> -----------------------------------------------------------------
>
>                 Key: XMLBEANS-432
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-432
>             Project: XMLBeans
>          Issue Type: Improvement
>          Components: Compiler
>         Environment: All platforms
>            Reporter: Tom
>         Attachments: xmlbeans.patch
>
>
> The PrePostSetFeature is very useful but the current handler interface lacks 
> the value that will be set (especially in the preSet method):
>     public static boolean preSet(int opType, XmlObject xo, QName prop, 
> boolean isAttr, int index)
>     {
>         ...
>         return true;  
>     }
> If the value that will be set was passed to the handler it would be possible 
> to write handlers that can filter or manipulate the data before it is set. 
> This would also allow writing a simple handler that does not set null values, 
> what many people would appreciate (according to postings in the forum).
> Therefore I suggest to enhance the interface as follows:
>     public static boolean preSet(int opType, XmlObject xo, QName prop, 
> boolean isAttr, int index, Object value)
>     {
>         ...
>         return true;  
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org
For additional commands, e-mail: dev-h...@xmlbeans.apache.org

Reply via email to