History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CASTOR-2196
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Werner Guttmann
Reporter: Bastian
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
castor

Accessing XMLFieldDescriptor from within FieldHandler

Created: 17/Oct/07 08:15 AM   Updated: 14/Mar/08 06:41 AM
Component/s: XML
Affects Version/s: 1.1.2.1
Fix Version/s: 1.2

Time Tracking:
Original Estimate: Not Specified
Remaining Estimate: 0 minutes
Time Spent - 1 hour, 50 minutes
Time Spent: 1 hour, 50 minutes
Time Spent - 1 hour, 50 minutes

File Attachments: 1. Text File patch.c2196.20071124-002.txt (4 kb)
2. Text File patch.c2196.20071124.txt (4 kb)



 Description  « Hide
I need to be able to access a XMLFieldDescriptor from my FieldHandler (subclass of GeneralizedFieldHandler) to get information about the XML element name and the namespace. The current implementation only gives acces to a FieldHandler via
protected final FieldDescriptor getFieldDescriptor();
The returned value isn't a XMLFieldDescriptor instance. With my debugger I found out, that a XMLFieldDescriptor instance with the desired information is on the stack. It would be nice being able to make a cast to XMLFieldDescriptor from getFieldDescriptor().

Sorry for not attaching any JUnit tests as described in http://www.castor.org/how-to-submit-an-xml-bug.html
I'm behind a firewall and am not able to checkout from svn. I wasn't able to build the snapshots from my box ("castor-1.1.2.1\cpa\src\main\java\org\castor\jdo\conf not found.")



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Werner Guttmann - 18/Oct/07 06:58 AM
Why don't you simply cast the FIeldDescriptor instance to XMLFIeldDescriptor, given that it is one ?

Werner Guttmann - 19/Oct/07 02:12 AM
Can you attach a working JUnit test case that I could use to advise you what to do ?

Werner Guttmann - 22/Oct/07 07:02 AM
Marking this as 'Won't fix' as discussed above. Please feel free to reopen at any time.

Bastian - 23/Oct/07 07:37 AM
org.exolab.castor.xml.XMLFieldDescriptor f = (org.exolab.castor.xml.XMLFieldDescriptor) getFieldDescriptor();
==>
ClassCastException: Cannot cast org.exolab.castor.mapping.loader.FieldDescriptorImpl (id=872624) to org.exolab.castor.xml.XMLFieldDescriptor

Werner Guttmann - 23/Oct/07 04:01 PM
Oops, my misunderstanding. Still (given the high load on myself and others), can you please attach a working JUnit test so that I don't have to 'reinvent' the wheel ?

Werner Guttmann - 23/Nov/07 03:40 AM - edited
if you wanted me to look at this before shipping the next release, I'd appreciate any help from your side (as indicated above).

Werner Guttmann - 24/Nov/07 02:40 PM
Initial patch for review. As a result of this patch, an XMLFieldDescriptorImpl instance is accessible by calling getFieldDescriptor() within a custom FieldHandler implementation. Please note that I have not performed any testing at all .... to make sure that nothing gets broken.

Werner Guttmann - 24/Nov/07 03:14 PM
Improved patch that has been tested against CTF - which still completes without a problem. Any feedback appreciated.

Werner Guttmann - 24/Nov/07 03:16 PM
Btw, I have not changed the return type of the getFieldDescriptor() method. But it's now possible to cast the object instance returned to an instance of XMLFieldDescriptor(Impl).

Werner Guttmann - 27/Nov/07 02:50 PM
In other words, code such as ...
    public Object convertUponGet(Object arg0) {
        FieldDescriptor descriptor = getFieldDescriptor();
        if (descriptor instanceof XMLFieldDescriptor) {
            XMLFieldDescriptor xmlDescriptor = (XMLFieldDescriptor) descriptor;
            String nameSpaceURI = xmlDescriptor.getNameSpaceURI();
        }
        return new Character(((String) arg0).charAt(0));
    }

works with problems.