Examples of ValidationEventHandler


Examples of javax.xml.bind.ValidationEventHandler

            marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
            marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);
            marshaller.setListener(databinding.getMarshallerListener());
            if (setEventHandler) {
                ValidationEventHandler h = veventHandler;
                if (veventHandler == null) {
                    h = new ValidationEventHandler() {
                        public boolean handleEvent(ValidationEvent event) {
                            //continue on warnings only
                            return event.getSeverity() == ValidationEvent.WARNING;
                        }
                    };
View Full Code Here

Examples of javax.xml.bind.ValidationEventHandler

            );

            JAXBContext ctx = JAXBContext.newInstance(Configuration.class);
            Unmarshaller unmarshaller = ctx.createUnmarshaller();
            unmarshaller.setSchema(schema);
            unmarshaller.setEventHandler(new ValidationEventHandler() {
                @Override
                public boolean handleEvent(ValidationEvent event) {
                    log.warn("Unmarshal warning", event.getMessage());
                    return true;
                }
View Full Code Here

Examples of javax.xml.bind.ValidationEventHandler

        if (schema != null) {
            SchemaFactory factory = getOrCreateSchemaFactory();
            try {
                Schema newSchema = factory.newSchema(getSources());
                unmarshaller.setSchema(newSchema);
                unmarshaller.setEventHandler(new ValidationEventHandler() {
                    public boolean handleEvent(ValidationEvent event) {
                        // stop unmarshalling if the event is an ERROR or FATAL ERROR
                        return event.getSeverity() == ValidationEvent.WARNING;
                    }
                });
View Full Code Here

Examples of javax.xml.bind.ValidationEventHandler

        if (schema != null) {
            SchemaFactory factory = getOrCreateSchemaFactory();
            try {
                Schema newSchema = factory.newSchema(getSources());
                marshaller.setSchema(newSchema);
                marshaller.setEventHandler(new ValidationEventHandler() {
                    public boolean handleEvent(ValidationEvent event) {
                        // stop marshalling if the event is an ERROR or FATAL ERROR
                        return event.getSeverity() == ValidationEvent.WARNING;
                    }
                });
View Full Code Here

Examples of javax.xml.bind.ValidationEventHandler

        currentTarget = oldTarget;
    }
   

    public void reportError( ValidationEvent ve ) throws AbortSerializationException {
        ValidationEventHandler handler;
       
        try {
            handler = owner.getEventHandler();
        } catch( JAXBException e ) {
            throw new AbortSerializationException(e);
        }
       
        if(!handler.handleEvent(ve)) {
            if(ve.getLinkedException() instanceof Exception)
                throw new AbortSerializationException((Exception)ve.getLinkedException());
            else
                throw new AbortSerializationException(ve.getMessage());
        }
View Full Code Here

Examples of javax.xml.bind.ValidationEventHandler

//
    private final UnmarshallerImpl parent;
    private boolean aborted = false;
   
    public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
        ValidationEventHandler eventHandler;
        try {
            eventHandler = parent.getEventHandler();
        } catch( JAXBException e ) {
            // impossible.
            throw new JAXBAssertionError();
        }

        boolean recover = eventHandler.handleEvent(event);
       
        // if the handler says "abort", we will not return the object
        // from the unmarshaller.getResult()
        if(!recover)    aborted = true;
       
View Full Code Here

Examples of javax.xml.bind.ValidationEventHandler

        factory.setValidating(false);
        SAXParser parser = factory.newSAXParser();

        JAXBContext ctx = getContext(type);
        Unmarshaller unmarshaller = ctx.createUnmarshaller();
        unmarshaller.setEventHandler(new ValidationEventHandler() {
            public boolean handleEvent(ValidationEvent validationEvent) {
                System.out.println(validationEvent);
                return false;
            }
        });
View Full Code Here

Examples of javax.xml.bind.ValidationEventHandler

        factory.setValidating(false);
        SAXParser parser = factory.newSAXParser();

        JAXBContext ctx = getContext(type);
        Unmarshaller unmarshaller = ctx.createUnmarshaller();
        unmarshaller.setEventHandler(new ValidationEventHandler() {
            public boolean handleEvent(ValidationEvent validationEvent) {
                System.out.println(validationEvent);
                return false;
            }
        });
View Full Code Here

Examples of javax.xml.bind.ValidationEventHandler

       
        SAXParser parser = factory.newSAXParser();

        JAXBContext ctx = JaxbJavaee.getContext(type);
        Unmarshaller unmarshaller = ctx.createUnmarshaller();
        unmarshaller.setEventHandler(new ValidationEventHandler(){
            public boolean handleEvent(ValidationEvent validationEvent) {
                String verbose = System.getProperty("openejb.validation.output.level");
                if (verbose != null && "VERBOSE".equals(verbose.toUpperCase())) {
                    System.err.println(validationEvent);
                }
View Full Code Here

Examples of javax.xml.bind.ValidationEventHandler

        factory.setValidating(validate);
        SAXParser parser = factory.newSAXParser();

        JAXBContext ctx = JaxbJavaee.getContext(type);
        Unmarshaller unmarshaller = ctx.createUnmarshaller();
        unmarshaller.setEventHandler(new ValidationEventHandler(){
            public boolean handleEvent(ValidationEvent validationEvent) {
                System.out.println(validationEvent);
                return false;
            }
        });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.