27 |
27 |
28 import java.util.Collections; |
28 import java.util.Collections; |
29 import java.util.HashMap; |
29 import java.util.HashMap; |
30 import java.util.Map; |
30 import java.util.Map; |
31 |
31 |
32 import javax.xml.bind.ValidationEvent; |
|
33 import javax.xml.bind.annotation.adapters.XmlAdapter; |
32 import javax.xml.bind.annotation.adapters.XmlAdapter; |
34 import javax.xml.bind.helpers.PrintConversionEventImpl; |
|
35 import javax.xml.bind.helpers.ValidationEventImpl; |
|
36 import javax.xml.bind.helpers.ValidationEventLocatorImpl; |
|
37 |
|
38 import com.sun.xml.internal.bind.util.ValidationEventLocatorExImpl; |
|
39 |
|
40 import org.xml.sax.SAXException; |
|
41 |
|
42 |
33 |
43 /** |
34 /** |
44 * @author Kohsuke Kawaguchi |
35 * @author Kohsuke Kawaguchi |
45 */ |
36 */ |
46 public class RuntimeUtil { |
37 public class RuntimeUtil { |
93 } |
84 } |
94 |
85 |
95 /** |
86 /** |
96 * Reports a print conversion error while marshalling. |
87 * Reports a print conversion error while marshalling. |
97 */ |
88 */ |
|
89 /* |
98 public static void handlePrintConversionException( |
90 public static void handlePrintConversionException( |
99 Object caller, Exception e, XMLSerializer serializer ) throws SAXException { |
91 Object caller, Exception e, XMLSerializer serializer ) throws SAXException { |
100 |
92 |
101 if( e instanceof SAXException ) |
93 if( e instanceof SAXException ) |
102 // assume this exception is not from application. |
94 // assume this exception is not from application. |
107 ValidationEvent ve = new PrintConversionEventImpl( |
99 ValidationEvent ve = new PrintConversionEventImpl( |
108 ValidationEvent.ERROR, e.getMessage(), |
100 ValidationEvent.ERROR, e.getMessage(), |
109 new ValidationEventLocatorImpl(caller), e ); |
101 new ValidationEventLocatorImpl(caller), e ); |
110 serializer.reportError(ve); |
102 serializer.reportError(ve); |
111 } |
103 } |
|
104 */ |
112 |
105 |
113 /** |
106 /** |
114 * Reports that the type of an object in a property is unexpected. |
107 * Reports that the type of an object in a property is unexpected. |
115 */ |
108 */ |
|
109 /* |
116 public static void handleTypeMismatchError( XMLSerializer serializer, |
110 public static void handleTypeMismatchError( XMLSerializer serializer, |
117 Object parentObject, String fieldName, Object childObject ) throws SAXException { |
111 Object parentObject, String fieldName, Object childObject ) throws SAXException { |
118 |
112 |
119 ValidationEvent ve = new ValidationEventImpl( |
113 ValidationEvent ve = new ValidationEventImpl( |
120 ValidationEvent.ERROR, // maybe it should be a fatal error. |
114 ValidationEvent.ERROR, // maybe it should be a fatal error. |
124 getTypeName(childObject) ), |
118 getTypeName(childObject) ), |
125 new ValidationEventLocatorExImpl(parentObject,fieldName) ); |
119 new ValidationEventLocatorExImpl(parentObject,fieldName) ); |
126 |
120 |
127 serializer.reportError(ve); |
121 serializer.reportError(ve); |
128 } |
122 } |
|
123 */ |
129 |
124 |
130 private static String getTypeName( Object o ) { |
125 private static String getTypeName( Object o ) { |
131 return o.getClass().getName(); |
126 return o.getClass().getName(); |
132 } |
127 } |
133 } |
128 } |