Java 类javax.xml.bind.helpers.ValidationEventImpl 实例源码
项目:OpenJSharp
文件:RuntimeBuiltinLeafInfoImpl.java
public String print(XMLGregorianCalendar cal) {
XMLSerializer xs = XMLSerializer.getInstance();
QName type = xs.getSchemaType();
if (type != null) {
try {
checkXmlGregorianCalendarFieldRef(type, cal);
String format = xmlGregorianCalendarFormatString.get(type);
if (format != null) {
return format(format, cal);
}
} catch (javax.xml.bind.MarshalException e) {
// see issue 649
xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(),
xs.getCurrentLocation(null) ));
return "";
}
}
return cal.toXMLFormat();
}
项目:OpenJSharp
文件:Coordinator.java
private void propagateEvent( int severity, SAXParseException saxException )
throws SAXException {
ValidationEventImpl ve =
new ValidationEventImpl( severity, saxException.getMessage(), getLocation() );
Exception e = saxException.getException();
if( e != null ) {
ve.setLinkedException( e );
} else {
ve.setLinkedException( saxException );
}
// call the client's event handler. If it returns false, then bail-out
// and terminate the unmarshal operation.
boolean result = handleEvent( ve );
if( ! result ) {
// bail-out of the parse with a SAX exception, but convert it into
// an UnmarshalException back in in the AbstractUnmarshaller
throw saxException;
}
}
项目:OpenJSharp
文件:ClassBeanInfoImpl.java
public void serializeRoot(BeanT bean, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
if(tagName==null) {
Class beanClass = bean.getClass();
String message;
if (beanClass.isAnnotationPresent(XmlRootElement.class)) {
message = Messages.UNABLE_TO_MARSHAL_UNBOUND_CLASS.format(beanClass.getName());
} else {
message = Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(beanClass.getName());
}
target.reportError(new ValidationEventImpl(ValidationEvent.ERROR,message,null, null));
} else {
target.startElement(tagName,bean);
target.childAsSoleContent(bean,null);
target.endElement();
if (retainPropertyInfo) {
target.currentProperty.remove();
}
}
}
项目:openjdk-jdk10
文件:RuntimeBuiltinLeafInfoImpl.java
public String print(XMLGregorianCalendar cal) {
XMLSerializer xs = XMLSerializer.getInstance();
QName type = xs.getSchemaType();
if (type != null) {
try {
checkXmlGregorianCalendarFieldRef(type, cal);
String format = xmlGregorianCalendarFormatString.get(type);
if (format != null) {
return format(format, cal);
}
} catch (javax.xml.bind.MarshalException e) {
// see issue 649
xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(),
xs.getCurrentLocation(null) ));
return "";
}
}
return cal.toXMLFormat();
}
项目:openjdk-jdk10
文件:Coordinator.java
private void propagateEvent( int severity, SAXParseException saxException )
throws SAXException {
ValidationEventImpl ve =
new ValidationEventImpl( severity, saxException.getMessage(), getLocation() );
Exception e = saxException.getException();
if( e != null ) {
ve.setLinkedException( e );
} else {
ve.setLinkedException( saxException );
}
// call the client's event handler. If it returns false, then bail-out
// and terminate the unmarshal operation.
boolean result = handleEvent( ve );
if( ! result ) {
// bail-out of the parse with a SAX exception, but convert it into
// an UnmarshalException back in in the AbstractUnmarshaller
throw saxException;
}
}
项目:openjdk-jdk10
文件:ClassBeanInfoImpl.java
public void serializeRoot(BeanT bean, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
if(tagName==null) {
Class beanClass = bean.getClass();
String message;
if (beanClass.isAnnotationPresent(XmlRootElement.class)) {
message = Messages.UNABLE_TO_MARSHAL_UNBOUND_CLASS.format(beanClass.getName());
} else {
message = Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(beanClass.getName());
}
target.reportError(new ValidationEventImpl(ValidationEvent.ERROR,message,null, null));
} else {
target.startElement(tagName,bean);
target.childAsSoleContent(bean,null);
target.endElement();
if (retainPropertyInfo) {
target.currentProperty.remove();
}
}
}
项目:openjdk9
文件:RuntimeBuiltinLeafInfoImpl.java
public String print(XMLGregorianCalendar cal) {
XMLSerializer xs = XMLSerializer.getInstance();
QName type = xs.getSchemaType();
if (type != null) {
try {
checkXmlGregorianCalendarFieldRef(type, cal);
String format = xmlGregorianCalendarFormatString.get(type);
if (format != null) {
return format(format, cal);
}
} catch (javax.xml.bind.MarshalException e) {
// see issue 649
xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(),
xs.getCurrentLocation(null) ));
return "";
}
}
return cal.toXMLFormat();
}
项目:openjdk9
文件:Coordinator.java
private void propagateEvent( int severity, SAXParseException saxException )
throws SAXException {
ValidationEventImpl ve =
new ValidationEventImpl( severity, saxException.getMessage(), getLocation() );
Exception e = saxException.getException();
if( e != null ) {
ve.setLinkedException( e );
} else {
ve.setLinkedException( saxException );
}
// call the client's event handler. If it returns false, then bail-out
// and terminate the unmarshal operation.
boolean result = handleEvent( ve );
if( ! result ) {
// bail-out of the parse with a SAX exception, but convert it into
// an UnmarshalException back in in the AbstractUnmarshaller
throw saxException;
}
}
项目:openjdk9
文件:ClassBeanInfoImpl.java
public void serializeRoot(BeanT bean, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
if(tagName==null) {
Class beanClass = bean.getClass();
String message;
if (beanClass.isAnnotationPresent(XmlRootElement.class)) {
message = Messages.UNABLE_TO_MARSHAL_UNBOUND_CLASS.format(beanClass.getName());
} else {
message = Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(beanClass.getName());
}
target.reportError(new ValidationEventImpl(ValidationEvent.ERROR,message,null, null));
} else {
target.startElement(tagName,bean);
target.childAsSoleContent(bean,null);
target.endElement();
if (retainPropertyInfo) {
target.currentProperty.remove();
}
}
}
项目:lookaside_java-1.8.0-openjdk
文件:RuntimeBuiltinLeafInfoImpl.java
public String print(XMLGregorianCalendar cal) {
XMLSerializer xs = XMLSerializer.getInstance();
QName type = xs.getSchemaType();
if (type != null) {
try {
checkXmlGregorianCalendarFieldRef(type, cal);
String format = xmlGregorianCalendarFormatString.get(type);
if (format != null) {
return format(format, cal);
}
} catch (javax.xml.bind.MarshalException e) {
// see issue 649
xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(),
xs.getCurrentLocation(null) ));
return "";
}
}
return cal.toXMLFormat();
}
项目:lookaside_java-1.8.0-openjdk
文件:Coordinator.java
private void propagateEvent( int severity, SAXParseException saxException )
throws SAXException {
ValidationEventImpl ve =
new ValidationEventImpl( severity, saxException.getMessage(), getLocation() );
Exception e = saxException.getException();
if( e != null ) {
ve.setLinkedException( e );
} else {
ve.setLinkedException( saxException );
}
// call the client's event handler. If it returns false, then bail-out
// and terminate the unmarshal operation.
boolean result = handleEvent( ve );
if( ! result ) {
// bail-out of the parse with a SAX exception, but convert it into
// an UnmarshalException back in in the AbstractUnmarshaller
throw saxException;
}
}
项目:lookaside_java-1.8.0-openjdk
文件:ClassBeanInfoImpl.java
public void serializeRoot(BeanT bean, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
if(tagName==null) {
Class beanClass = bean.getClass();
String message;
if (beanClass.isAnnotationPresent(XmlRootElement.class)) {
message = Messages.UNABLE_TO_MARSHAL_UNBOUND_CLASS.format(beanClass.getName());
} else {
message = Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(beanClass.getName());
}
target.reportError(new ValidationEventImpl(ValidationEvent.ERROR,message,null, null));
} else {
target.startElement(tagName,bean);
target.childAsSoleContent(bean,null);
target.endElement();
if (retainPropertyInfo) {
target.currentProperty.remove();
}
}
}
项目:infobip-open-jdk-8
文件:RuntimeBuiltinLeafInfoImpl.java
public String print(XMLGregorianCalendar cal) {
XMLSerializer xs = XMLSerializer.getInstance();
QName type = xs.getSchemaType();
if (type != null) {
try {
checkXmlGregorianCalendarFieldRef(type, cal);
String format = xmlGregorianCalendarFormatString.get(type);
if (format != null) {
return format(format, cal);
}
} catch (javax.xml.bind.MarshalException e) {
// see issue 649
xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(),
xs.getCurrentLocation(null) ));
return "";
}
}
return cal.toXMLFormat();
}
项目:infobip-open-jdk-8
文件:Coordinator.java
private void propagateEvent( int severity, SAXParseException saxException )
throws SAXException {
ValidationEventImpl ve =
new ValidationEventImpl( severity, saxException.getMessage(), getLocation() );
Exception e = saxException.getException();
if( e != null ) {
ve.setLinkedException( e );
} else {
ve.setLinkedException( saxException );
}
// call the client's event handler. If it returns false, then bail-out
// and terminate the unmarshal operation.
boolean result = handleEvent( ve );
if( ! result ) {
// bail-out of the parse with a SAX exception, but convert it into
// an UnmarshalException back in in the AbstractUnmarshaller
throw saxException;
}
}
项目:infobip-open-jdk-8
文件:ClassBeanInfoImpl.java
public void serializeRoot(BeanT bean, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
if(tagName==null) {
Class beanClass = bean.getClass();
String message;
if (beanClass.isAnnotationPresent(XmlRootElement.class)) {
message = Messages.UNABLE_TO_MARSHAL_UNBOUND_CLASS.format(beanClass.getName());
} else {
message = Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(beanClass.getName());
}
target.reportError(new ValidationEventImpl(ValidationEvent.ERROR,message,null, null));
} else {
target.startElement(tagName,bean);
target.childAsSoleContent(bean,null);
target.endElement();
if (retainPropertyInfo) {
target.currentProperty.remove();
}
}
}
项目:cxf-plus
文件:Coordinator.java
private void propagateEvent( int severity, SAXParseException saxException )
throws SAXException {
ValidationEventImpl ve =
new ValidationEventImpl( severity, saxException.getMessage(), getLocation() );
Exception e = saxException.getException();
if( e != null ) {
ve.setLinkedException( e );
} else {
ve.setLinkedException( saxException );
}
// call the client's event handler. If it returns false, then bail-out
// and terminate the unmarshal operation.
boolean result = handleEvent( ve );
if( ! result ) {
// bail-out of the parse with a SAX exception, but convert it into
// an UnmarshalException back in in the AbstractUnmarshaller
throw saxException;
}
}
项目:cxf-plus
文件:ClassBeanInfoImpl.java
public void serializeRoot(BeanT bean, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
if(tagName==null) {
Class beanClass = bean.getClass();
String message;
if (beanClass.isAnnotationPresent(XmlRootElement.class)) {
message = Messages.UNABLE_TO_MARSHAL_UNBOUND_CLASS.format(beanClass.getName());
} else {
message = Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(beanClass.getName());
}
target.reportError(new ValidationEventImpl(ValidationEvent.ERROR,message,null, null));
}
else {
target.startElement(tagName,bean);
target.childAsSoleContent(bean,null);
target.endElement();
if (retainPropertyInfo) {
target.currentProperty.remove();
}
}
}
项目:OLD-OpenJDK8
文件:RuntimeBuiltinLeafInfoImpl.java
public String print(XMLGregorianCalendar cal) {
XMLSerializer xs = XMLSerializer.getInstance();
QName type = xs.getSchemaType();
if (type != null) {
try {
checkXmlGregorianCalendarFieldRef(type, cal);
String format = xmlGregorianCalendarFormatString.get(type);
if (format != null) {
return format(format, cal);
}
} catch (javax.xml.bind.MarshalException e) {
// see issue 649
xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(),
xs.getCurrentLocation(null) ));
return "";
}
}
return cal.toXMLFormat();
}
项目:OLD-OpenJDK8
文件:Coordinator.java
private void propagateEvent( int severity, SAXParseException saxException )
throws SAXException {
ValidationEventImpl ve =
new ValidationEventImpl( severity, saxException.getMessage(), getLocation() );
Exception e = saxException.getException();
if( e != null ) {
ve.setLinkedException( e );
} else {
ve.setLinkedException( saxException );
}
// call the client's event handler. If it returns false, then bail-out
// and terminate the unmarshal operation.
boolean result = handleEvent( ve );
if( ! result ) {
// bail-out of the parse with a SAX exception, but convert it into
// an UnmarshalException back in in the AbstractUnmarshaller
throw saxException;
}
}
项目:OLD-OpenJDK8
文件:ClassBeanInfoImpl.java
public void serializeRoot(BeanT bean, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
if(tagName==null) {
Class beanClass = bean.getClass();
String message;
if (beanClass.isAnnotationPresent(XmlRootElement.class)) {
message = Messages.UNABLE_TO_MARSHAL_UNBOUND_CLASS.format(beanClass.getName());
} else {
message = Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(beanClass.getName());
}
target.reportError(new ValidationEventImpl(ValidationEvent.ERROR,message,null, null));
} else {
target.startElement(tagName,bean);
target.childAsSoleContent(bean,null);
target.endElement();
if (retainPropertyInfo) {
target.currentProperty.remove();
}
}
}
项目:openjdk-icedtea7
文件:RuntimeBuiltinLeafInfoImpl.java
public String print(XMLGregorianCalendar cal) {
XMLSerializer xs = XMLSerializer.getInstance();
QName type = xs.getSchemaType();
if (type != null) {
try {
checkXmlGregorianCalendarFieldRef(type, cal);
String format = xmlGregorianCalendarFormatString.get(type);
if (format != null) {
return format(format, cal);
}
} catch (javax.xml.bind.MarshalException e) {
// see issue 649
xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(),
xs.getCurrentLocation(null) ));
return "";
}
}
return cal.toXMLFormat();
}
项目:openjdk-icedtea7
文件:Coordinator.java
private void propagateEvent( int severity, SAXParseException saxException )
throws SAXException {
ValidationEventImpl ve =
new ValidationEventImpl( severity, saxException.getMessage(), getLocation() );
Exception e = saxException.getException();
if( e != null ) {
ve.setLinkedException( e );
} else {
ve.setLinkedException( saxException );
}
// call the client's event handler. If it returns false, then bail-out
// and terminate the unmarshal operation.
boolean result = handleEvent( ve );
if( ! result ) {
// bail-out of the parse with a SAX exception, but convert it into
// an UnmarshalException back in in the AbstractUnmarshaller
throw saxException;
}
}
项目:openjdk-icedtea7
文件:ClassBeanInfoImpl.java
public void serializeRoot(BeanT bean, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
if(tagName==null) {
Class beanClass = bean.getClass();
String message;
if (beanClass.isAnnotationPresent(XmlRootElement.class)) {
message = Messages.UNABLE_TO_MARSHAL_UNBOUND_CLASS.format(beanClass.getName());
} else {
message = Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(beanClass.getName());
}
target.reportError(new ValidationEventImpl(ValidationEvent.ERROR,message,null, null));
} else {
target.startElement(tagName,bean);
target.childAsSoleContent(bean,null);
target.endElement();
if (retainPropertyInfo) {
target.currentProperty.remove();
}
}
}
项目:javacash
文件:ErrorHandlerAdaptor.java
private void propagateEvent( int severity, SAXParseException saxException )
throws SAXException {
// get location info:
// sax locators simply use the location info embedded in the
// sax exception, dom locators keep a reference to their DOMScanner
// and call back to figure out where the error occurred.
ValidationEventLocator vel =
locator.getLocation( saxException );
ValidationEventImpl ve =
new ValidationEventImpl( severity, saxException.getMessage(), vel );
Exception e = saxException.getException();
if( e != null ) {
ve.setLinkedException( e );
} else {
ve.setLinkedException( saxException );
}
// call the client's event handler.
host.handleEvent( ve, severity!=ValidationEvent.FATAL_ERROR );
}
项目:wustl-common-package
文件:ErrorHandlerAdaptor.java
private void propagateEvent( int severity, SAXParseException saxException )
throws SAXException {
// get location info:
// sax locators simply use the location info embedded in the
// sax exception, dom locators keep a reference to their DOMScanner
// and call back to figure out where the error occurred.
ValidationEventLocator vel =
locator.getLocation( saxException );
ValidationEventImpl ve =
new ValidationEventImpl( severity, saxException.getMessage(), vel );
Exception e = saxException.getException();
if( e != null ) {
ve.setLinkedException( e );
} else {
ve.setLinkedException( saxException );
}
// call the client's event handler.
host.handleEvent( ve, severity!=ValidationEvent.FATAL_ERROR );
}
项目:OpenJSharp
文件:RuntimeBuiltinLeafInfoImpl.java
public Base64Data print(Image v) {
ByteArrayOutputStreamEx imageData = new ByteArrayOutputStreamEx();
XMLSerializer xs = XMLSerializer.getInstance();
String mimeType = xs.getXMIMEContentType();
if(mimeType==null || mimeType.startsWith("image/*"))
// because PNG is lossless, it's a good default
//
// mime type can be a range, in which case we can't just pass that
// to ImageIO.getImageWritersByMIMEType, so here I'm just assuming
// the default of PNG. Not sure if this is complete.
mimeType = "image/png";
try {
Iterator<ImageWriter> itr = ImageIO.getImageWritersByMIMEType(mimeType);
if(itr.hasNext()) {
ImageWriter w = itr.next();
ImageOutputStream os = ImageIO.createImageOutputStream(imageData);
w.setOutput(os);
w.write(convertToBufferedImage(v));
os.close();
w.dispose();
} else {
// no encoder
xs.handleEvent(new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.NO_IMAGE_WRITER.format(mimeType),
xs.getCurrentLocation(null) ));
// TODO: proper error reporting
throw new RuntimeException("no encoder for MIME type "+mimeType);
}
} catch (IOException e) {
xs.handleError(e);
// TODO: proper error reporting
throw new RuntimeException(e);
}
Base64Data bd = new Base64Data();
imageData.set(bd,mimeType);
return bd;
}
项目:OpenJSharp
文件:CompositeStructureBeanInfo.java
public void serializeRoot(CompositeStructure o, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
target.reportError(
new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(o.getClass().getName()),
null,
null));
}
项目:OpenJSharp
文件:AnyTypeBeanInfo.java
public void serializeRoot(Object element, XMLSerializer target) throws SAXException {
target.reportError(
new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(element.getClass().getName()),
null,
null));
}
项目:OpenJSharp
文件:XMLSerializer.java
/**
* Pushes the object to {@link #cycleDetectionStack} and also
* detect any cycles.
*
* When a cycle is found, this method tries to recover from it.
*
* @return
* the object that should be marshalled instead of the given <tt>obj</tt>,
* or null if the error is found and we need to avoid marshalling this object
* to prevent infinite recursion. When this method returns null, the error
* has already been reported.
*/
private Object pushObject(Object obj, String fieldName) throws SAXException {
if(!cycleDetectionStack.push(obj))
return obj;
// allow the object to nominate its replacement
if(obj instanceof CycleRecoverable) {
obj = ((CycleRecoverable)obj).onCycleDetected(new CycleRecoverable.Context(){
public Marshaller getMarshaller() {
return marshaller;
}
});
if(obj!=null) {
// object nominated its replacement.
// we still need to make sure that the nominated.
// this may cause inifinite recursion on its own.
cycleDetectionStack.pop();
return pushObject(obj,fieldName);
} else
return null;
}
// cycle detected and no one is catching the error.
reportError(new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.CYCLE_IN_MARSHALLER.format(cycleDetectionStack.getCycleString()),
getCurrentLocation(fieldName),
null));
return null;
}
项目:OpenJSharp
文件:XMLSerializer.java
public boolean handleError(Exception e,Object source,String fieldName) {
return handleEvent(
new ValidationEventImpl(
ValidationEvent.ERROR,
e.getMessage(),
new ValidationEventLocatorExImpl(source,fieldName),
e));
}
项目:OpenJSharp
文件:XMLSerializer.java
private void reportMissingObjectError(String fieldName) throws SAXException {
reportError(new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.MISSING_OBJECT.format(fieldName),
getCurrentLocation(fieldName),
new NullPointerException() ));
}
项目:OpenJSharp
文件:XMLSerializer.java
/**
* Called when a referenced object doesn't have an ID.
*/
public void errorMissingId(Object obj) throws SAXException {
reportError( new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.MISSING_ID.format(obj),
new ValidationEventLocatorImpl(obj)) );
}
项目:OpenJSharp
文件:LeafBeanInfoImpl.java
public final void serializeRoot(BeanT bean, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
if(tagName==null) {
target.reportError(
new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(bean.getClass().getName()),
null,
null));
}
else {
target.startElement(tagName,bean);
target.childAsSoleContent(bean,null);
target.endElement();
}
}
项目:OpenJSharp
文件:UnmarshallingContext.java
/**
* Called when there's no corresponding ID value.
*/
public void errorUnresolvedIDREF(Object bean, String idref, LocatorEx loc) throws SAXException {
handleEvent( new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.UNRESOLVED_IDREF.format(idref),
loc.getLocation()), true );
}
项目:OpenJSharp
文件:UnmarshallingContext.java
/**
* Based on current {@link Logger} {@link Level} and errorCounter value determines if error should be reported.
*
* If the method called and return true it is expected that error will be reported. And that's why
* errorCounter is automatically decremented during the check.
*
* NOT THREAD SAFE!!! In case of heave concurrency access several additional errors could be reported. It's not expected to be the
* problem. Otherwise add synchronization here.
*
* @return true in case if {@link Level#FINEST} is set OR we haven't exceed errors reporting limit.
*/
public boolean shouldErrorBeReported() throws SAXException {
if (logger.isLoggable(Level.FINEST))
return true;
if (errorsCounter >= 0) {
--errorsCounter;
if (errorsCounter == 0) // it's possible to miss this because of concurrency. If required add synchronization here
handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, Messages.ERRORS_LIMIT_EXCEEDED.format(),
getLocator().getLocation(), null), true);
}
return errorsCounter >= 0;
}
项目:OpenJSharp
文件:Loader.java
public static void reportError(String msg, Exception nested, boolean canRecover) throws SAXException {
UnmarshallingContext context = UnmarshallingContext.getInstance();
context.handleEvent( new ValidationEventImpl(
canRecover? ValidationEvent.ERROR : ValidationEvent.FATAL_ERROR,
msg,
context.getLocator().getLocation(),
nested ), canRecover );
}
项目:OpenJSharp
文件:ArrayBeanInfoImpl.java
public final void serializeRoot(Object array, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
target.reportError(
new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(array.getClass().getName()),
null,
null));
}
项目:OpenJSharp
文件:ValueListBeanInfoImpl.java
public final void serializeRoot(Object array, XMLSerializer target) throws SAXException {
target.reportError(
new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(array.getClass().getName()),
null,
null));
}
项目:openjdk-jdk10
文件:RuntimeBuiltinLeafInfoImpl.java
public Base64Data print(Image v) {
ByteArrayOutputStreamEx imageData = new ByteArrayOutputStreamEx();
XMLSerializer xs = XMLSerializer.getInstance();
String mimeType = xs.getXMIMEContentType();
if(mimeType==null || mimeType.startsWith("image/*"))
// because PNG is lossless, it's a good default
//
// mime type can be a range, in which case we can't just pass that
// to ImageIO.getImageWritersByMIMEType, so here I'm just assuming
// the default of PNG. Not sure if this is complete.
mimeType = "image/png";
try {
Iterator<ImageWriter> itr = ImageIO.getImageWritersByMIMEType(mimeType);
if(itr.hasNext()) {
ImageWriter w = itr.next();
ImageOutputStream os = ImageIO.createImageOutputStream(imageData);
w.setOutput(os);
w.write(convertToBufferedImage(v));
os.close();
w.dispose();
} else {
// no encoder
xs.handleEvent(new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.NO_IMAGE_WRITER.format(mimeType),
xs.getCurrentLocation(null) ));
// TODO: proper error reporting
throw new RuntimeException("no encoder for MIME type "+mimeType);
}
} catch (IOException e) {
xs.handleError(e);
// TODO: proper error reporting
throw new RuntimeException(e);
}
Base64Data bd = new Base64Data();
imageData.set(bd,mimeType);
return bd;
}
项目:openjdk-jdk10
文件:CompositeStructureBeanInfo.java
public void serializeRoot(CompositeStructure o, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
target.reportError(
new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(o.getClass().getName()),
null,
null));
}