本文整理汇总了Java中javax.xml.bind.helpers.ValidationEventImpl类的典型用法代码示例。如果您正苦于以下问题:Java ValidationEventImpl类的具体用法?Java ValidationEventImpl怎么用?Java ValidationEventImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ValidationEventImpl类属于javax.xml.bind.helpers包,在下文中一共展示了ValidationEventImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: print
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
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();
}
示例2: propagateEvent
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
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;
}
}
示例3: serializeRoot
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
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();
}
}
}
示例4: serializeRoot
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
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();
}
}
}
示例5: propagateEvent
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
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 );
}
示例6: serializeRoot
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
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));
}
示例7: serializeRoot
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
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));
}
示例8: pushObject
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
/**
* 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;
}
示例9: handleError
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
public boolean handleError(Exception e,Object source,String fieldName) {
return handleEvent(
new ValidationEventImpl(
ValidationEvent.ERROR,
e.getMessage(),
new ValidationEventLocatorExImpl(source,fieldName),
e));
}
示例10: reportMissingObjectError
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
private void reportMissingObjectError(String fieldName) throws SAXException {
reportError(new ValidationEventImpl(
ValidationEvent.ERROR,
Messages.MISSING_OBJECT.format(fieldName),
getCurrentLocation(fieldName),
new NullPointerException() ));
}
示例11: errorMissingId
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
/**
* 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)) );
}
示例12: serializeRoot
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
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();
}
}
示例13: errorUnresolvedIDREF
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
/**
* 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 );
}
示例14: shouldErrorBeReported
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
/**
* 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;
}
示例15: reportError
import javax.xml.bind.helpers.ValidationEventImpl; //导入依赖的package包/类
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 );
}