当前位置: 首页>>代码示例>>Java>>正文


Java ValidationEventCollector.getEvents方法代码示例

本文整理汇总了Java中javax.xml.bind.util.ValidationEventCollector.getEvents方法的典型用法代码示例。如果您正苦于以下问题:Java ValidationEventCollector.getEvents方法的具体用法?Java ValidationEventCollector.getEvents怎么用?Java ValidationEventCollector.getEvents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.bind.util.ValidationEventCollector的用法示例。


在下文中一共展示了ValidationEventCollector.getEvents方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: marshalToStream

import javax.xml.bind.util.ValidationEventCollector; //导入方法依赖的package包/类
private static <T> ValidationEvent[] marshalToStream(T object, OutputStream out, 
			boolean doFormatting, MarshallerType type, Class<?>... nestedClasses) throws JAXBException {
		ValidationEventCollector vec = new ValidationEventCollector();

		final Marshaller marshaller;
//		switch(type) {
//		case JSON:
//			marshaller = createJsonMarshaller(object, doFormatting, nestedClasses);
//			break;
//		default:
//			marshaller = createXmlMarshaller(object, doFormatting, nestedClasses);
//			break;
//		}
		marshaller = createXmlMarshaller(object, doFormatting, nestedClasses);
		marshaller.setEventHandler(vec);
		marshaller.marshal(object, out);
		
		checkEvents(vec);
		
		return vec.getEvents();
	}
 
开发者ID:Transkribus,项目名称:TranskribusCore,代码行数:22,代码来源:JaxbUtils.java

示例2: handleValidationEvents

import javax.xml.bind.util.ValidationEventCollector; //导入方法依赖的package包/类
/**
 * If there are any events, convert the events into an error message string and throw a new InterfaceValidationException.
 * 
 * @param jaxbException that prompted the check for validation events
 * @param handler ValidationEventController with any validation events
 * @param messageType String describing what type of message caused the error (Request, Response, or exception message)
 */
protected static void handleValidationEvents(JAXBException jaxbException, ValidationEventCollector handler,
                                             String messageType) {
    if (handler.hasEvents()) {
        ValidationEvent[] events = handler.getEvents();
        StringBuffer errorMessage = new StringBuffer();

        for (int i = 0; i < events.length; i++) {
            if (i > 0) {
                errorMessage.append(" ");
            }

            errorMessage.append(events[i].getMessage());
        }

        if (jaxbException == null) {
            throw new InterfaceValidationException(InterfaceValidationException.VALIDATION_ERROR,
                InterfaceException.PRE_ENCAPSULATION, messageType, errorMessage);
        }
        else {
            throw new InterfaceValidationException(jaxbException, InterfaceValidationException.VALIDATION_ERROR,
                InterfaceException.PRE_ENCAPSULATION, messageType, errorMessage);
        }
    }
}
 
开发者ID:OSEHRA-Sandbox,项目名称:MOCHA,代码行数:32,代码来源:XmlUtility.java

示例3: buildMsg

import javax.xml.bind.util.ValidationEventCollector; //导入方法依赖的package包/类
private static String buildMsg(ValidationEventCollector vec, PcGtsType page) {
	String imgFn = "";
	if (page.getPage()!=null) {
		imgFn = page.getPage().getImageFilename();
	}
	
	String msg;
	if (vec.hasEvents()) {
		msg="Events occured while marshalling xml file: " + vec.getEvents().length;
	} else {
		msg=NO_EVENTS_MSG;
	}
	if (!imgFn.isEmpty()) msg += " (img: "+imgFn+")";
	return msg;
}
 
开发者ID:Transkribus,项目名称:TranskribusCore,代码行数:16,代码来源:PageXmlUtils.java

示例4: checkEvents

import javax.xml.bind.util.ValidationEventCollector; //导入方法依赖的package包/类
private static void checkEvents(ValidationEventCollector vec) {
	if (vec.hasEvents()) {
		logger.info("Events occured while marshalling xml file: " + vec.getEvents().length);
		ValidationEvent[] events = vec.getEvents();
		for(ValidationEvent e : events){
			logger.info(e.getMessage());
		}
	} else {
		logger.debug("No events occured during marshalling xml file!");
	}
}
 
开发者ID:Transkribus,项目名称:TranskribusCore,代码行数:12,代码来源:JaxbUtils.java

示例5: read

import javax.xml.bind.util.ValidationEventCollector; //导入方法依赖的package包/类
private void read() throws JAXBException {
    long currentTime = file.lastModified();
    if (currentTime == lastModified) {
        return ;
    }
    Unmarshaller unmarshaller = getUnmarshaller();
    ValidationEventCollector errors = (ValidationEventCollector) unmarshaller.getEventHandler();
    WorkflowDefinition fetchedWf = null;
    try {
        WorkflowDefinition wf = (WorkflowDefinition) unmarshaller.unmarshal(file);
        if (!errors.hasEvents()) {
            readCaches(wf);
            fetchedWf = wf;
        }
    } catch (UnmarshalException ex) {
        if (!errors.hasEvents()) {
            throw ex;
        }
    } finally {
        setProfiles(fetchedWf, currentTime);
    }
    if (errors.hasEvents()) {
        StringBuilder err = new StringBuilder();
        for (ValidationEvent event : errors.getEvents()) {
            err.append(event).append('\n');
        }
        throw new JAXBException(err.toString());
    }
}
 
开发者ID:proarc,项目名称:proarc,代码行数:30,代码来源:WorkflowProfiles.java

示例6: validate

import javax.xml.bind.util.ValidationEventCollector; //导入方法依赖的package包/类
private void validate(ValidationEventCollector handler)
		throws ValidationException {
	if(handler.hasEvents()) {
		ValidationEvent[] events = handler.getEvents();
		StringBuilder sb = new StringBuilder();
		for(ValidationEvent event : events) {
			sb.append(event.getMessage());
		}
		throw new ValidationException(sb.toString());
	}
}
 
开发者ID:betfair,项目名称:cougar,代码行数:12,代码来源:XMLUnMarshaller.java


注:本文中的javax.xml.bind.util.ValidationEventCollector.getEvents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。