Repository: bval Updated Branches: refs/heads/master 7f5df08d6 -> c99b115ff
remove obsolete class Project: http://git-wip-us.apache.org/repos/asf/bval/repo Commit: http://git-wip-us.apache.org/repos/asf/bval/commit/c99b115f Tree: http://git-wip-us.apache.org/repos/asf/bval/tree/c99b115f Diff: http://git-wip-us.apache.org/repos/asf/bval/diff/c99b115f Branch: refs/heads/master Commit: c99b115ff09f9d2a4711ffd68c48b9b463d6873c Parents: 7f5df08 Author: Matt Benson <[email protected]> Authored: Tue Oct 30 09:25:20 2018 -0500 Committer: Matt Benson <[email protected]> Committed: Tue Oct 30 09:25:20 2018 -0500 ---------------------------------------------------------------------- .../org/apache/bval/jsr/xml/SchemaManager.java | 2 +- .../java/org/apache/bval/jsr/xml/XmlUtils.java | 67 -------------------- 2 files changed, 1 insertion(+), 68 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bval/blob/c99b115f/bval-jsr/src/main/java/org/apache/bval/jsr/xml/SchemaManager.java ---------------------------------------------------------------------- diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/xml/SchemaManager.java b/bval-jsr/src/main/java/org/apache/bval/jsr/xml/SchemaManager.java index 6650de5..ca05081 100644 --- a/bval-jsr/src/main/java/org/apache/bval/jsr/xml/SchemaManager.java +++ b/bval-jsr/src/main/java/org/apache/bval/jsr/xml/SchemaManager.java @@ -229,7 +229,7 @@ public class SchemaManager { } static Schema loadSchema(String resource) { - final URL schemaUrl = Reflection.loaderFromThreadOrClass(XmlUtils.class).getResource(resource); + final URL schemaUrl = Reflection.loaderFromThreadOrClass(SchemaManager.class).getResource(resource); try { return SCHEMA_FACTORY.newSchema(schemaUrl); } catch (SAXException e) { http://git-wip-us.apache.org/repos/asf/bval/blob/c99b115f/bval-jsr/src/main/java/org/apache/bval/jsr/xml/XmlUtils.java ---------------------------------------------------------------------- diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/xml/XmlUtils.java b/bval-jsr/src/main/java/org/apache/bval/jsr/xml/XmlUtils.java deleted file mode 100644 index 00e2933..0000000 --- a/bval-jsr/src/main/java/org/apache/bval/jsr/xml/XmlUtils.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.bval.jsr.xml; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.xml.XMLConstants; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.bind.helpers.DefaultValidationEventHandler; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; - -import org.apache.bval.util.reflection.Reflection; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -class XmlUtils { - private static final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance(); - private static final Logger log = Logger.getLogger(XmlUtils.class.getName()); - private static final SchemaFactory SCHEMA_FACTORY = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - - static Schema loadSchema(String resource) { - final URL schemaUrl = Reflection.loaderFromThreadOrClass(XmlUtils.class).getResource(resource); - try { - return SCHEMA_FACTORY.newSchema(schemaUrl); - } catch (SAXException e) { - log.log(Level.WARNING, String.format("Unable to parse schema: %s", resource), e); - return null; - } - } - - static Document parse(InputStream in) throws SAXException, IOException, ParserConfigurationException { - return DOCUMENT_BUILDER_FACTORY.newDocumentBuilder().parse(in); - } - - static <T> T unmarshal(Document document, Schema schema, Class<T> type) throws JAXBException { - final JAXBContext jc = JAXBContext.newInstance(type); - final Unmarshaller unmarshaller = jc.createUnmarshaller(); - unmarshaller.setSchema(schema); - unmarshaller.setEventHandler(new DefaultValidationEventHandler()); - final JAXBElement<T> root = unmarshaller.unmarshal(document, type); - return root.getValue(); - } -} \ No newline at end of file
