001 // 002 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.1-05/30/2003 05:06 AM(java_re)-fcs 003 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 004 // Any modifications to this file will be lost upon recompilation of the source schema. 005 // Generated on: 2004.10.11 at 12:13:34 EDT 006 // 007 008 /* 009 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 010 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 011 */ 012 package astronomy.data.spectra.impl.runtime; 013 014 import javax.xml.bind.ValidationEvent; 015 import javax.xml.bind.helpers.PrintConversionEventImpl; 016 import javax.xml.bind.helpers.ValidationEventLocatorImpl; 017 018 import org.xml.sax.SAXException; 019 020 import com.sun.xml.bind.ProxyGroup; 021 022 /** 023 * 024 * @author 025 * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) 026 */ 027 public class Util { 028 /** 029 * Report a print conversion error while marshalling. 030 */ 031 public static void handlePrintConversionException( 032 Object caller, Exception e, XMLSerializer serializer ) throws SAXException { 033 034 if( e instanceof SAXException ) 035 // assume this exception is not from application. 036 // (e.g., when a marshaller aborts the processing, this exception 037 // will be thrown) 038 throw (SAXException)e; 039 040 ValidationEvent ve = new PrintConversionEventImpl( 041 ValidationEvent.ERROR, e.getMessage(), 042 new ValidationEventLocatorImpl(caller) ); 043 serializer.reportError(ve); 044 } 045 046 047 private static final Class[] xmlSerializableSatellite = new Class[] { 048 XMLSerializable.class, 049 XMLSerializer.class, 050 NamespaceContext2.class 051 }; 052 053 public static XMLSerializable toXMLSerializable(Object o) { 054 return (XMLSerializable)ProxyGroup.blindWrap( o, XMLSerializable.class, xmlSerializableSatellite ); 055 } 056 057 058 private static final Class[] validatableSatellite = new Class[] { 059 XMLSerializable.class, 060 XMLSerializer.class, 061 ValidatableObject.class, 062 NamespaceContext2.class 063 }; 064 065 public static ValidatableObject toValidatableObject(Object o) { 066 return (ValidatableObject)ProxyGroup.blindWrap( o, ValidatableObject.class, validatableSatellite ); 067 } 068 }