Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
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 javax.xml.bind.helpers;
 
 import java.io.File;
 import java.io.Reader;
 import java.net.URL;
 
 
 
 
 public abstract class AbstractUnmarshallerImpl implements Unmarshaller {
 
     protected boolean validating;
     private XMLReader reader;
 
         Exception nested = e.getException();
         if (nested instanceof UnmarshalException) {
             return (UnmarshalException)nested;
         } else if(nested instanceof RuntimeException) {
             throw (RuntimeException)nested;
         } else if (nested != null) {
             return new UnmarshalException(nested);
         } else {
             return new UnmarshalException(e);
         }
     }
 
     protected XMLReader getXMLReader() throws JAXBException {
         if ( == null) {
             try {
                 SAXParserFactory parserFactory = SAXParserFactory.newInstance();
                 parserFactory.setNamespaceAware(true);
                 parserFactory.setValidating(false);
                  = parserFactory.newSAXParser().getXMLReader();
             } catch(ParserConfigurationException e) {
                 throw new JAXBException(e);
             } catch(SAXException e) {
                 throw new JAXBException(e);
             }
         }
         return ;
     }
 
     public <A extends XmlAdapter> A getAdapter(Class<A> type) {
         throw new UnsupportedOperationException();
     }
 
         throw new UnsupportedOperationException();
     }
 
     public ValidationEventHandler getEventHandler() throws JAXBException {
         return ;
     }
 
     public Listener getListener() {
         throw new UnsupportedOperationException();
     }
    public Object getProperty(String namethrows PropertyException {
        if(name == null) {
            throw new IllegalArgumentException("name must not be null");
        }
        throw new PropertyException(name);
    }
    public Schema getSchema() {
        throw new UnsupportedOperationException();
    }
    public boolean isValidating() throws JAXBException {
        return ;
    }
    public <A extends XmlAdaptervoid setAdapter(Class<A> type, A adapter) {
        throw new UnsupportedOperationException();
    }
    public void setAdapter(XmlAdapter adapter) {
        if (adapter == null) {
            throw new IllegalArgumentException();
        }
        setAdapter((Class<XmlAdapter>) adapter.getClass(), adapter);
    }
        throw new UnsupportedOperationException();
    }
    public void setEventHandler(ValidationEventHandler handlerthrows JAXBException {
        if (handler == null) {
            handler = new DefaultValidationEventHandler();
        }
         = handler;
    }
    public void setListener(Listener listener) {
        throw new UnsupportedOperationException();
    }
    public void setProperty(String nameObject valuethrows PropertyException {
        if(name == null) {
            throw new IllegalArgumentException("name must not be null");
        }
        throw new PropertyException(namevalue);
    }
    public void setSchema(Schema schema) {
        throw new UnsupportedOperationException();
    }
    public void setValidating(boolean validatingthrows JAXBException {
        this. = validating;
    }
    public final Object unmarshal(File filethrows JAXBException {
        if (file == null) {
            throw new IllegalArgumentException("file must not be null");
        }
        try
        {
            String path = file.getAbsolutePath();
            if (. != '/') {
                path = path.replace(.'/');
            }
            if (!path.startsWith("/")) {
                path = "/" + path;
            }
            if (!path.endsWith("/") && file.isDirectory()) {
                path = path + "/";
            }
            return unmarshal(new URL("file"""path));
        }
        catch(MalformedURLException e) {
            throw new IllegalArgumentException(e.getMessage());
        }
    }
    public final Object unmarshal(InputSource sourcethrows JAXBException {
        if (source == null) {
            throw new IllegalArgumentException("source must not be null");
        }
        return unmarshal(getXMLReader(), source);
    }
    public final Object unmarshal(InputStream isthrows JAXBException {
        if (is == null) {
            throw new IllegalArgumentException("is must not be null");
        }
        return unmarshal(new InputSource(is));
    }
    public <T> JAXBElement<T> unmarshal(Node nodeClass<T> declaredTypethrows JAXBException {
        throw new UnsupportedOperationException();
    }
    public final Object unmarshal(Reader readerthrows JAXBException {
        if (reader == null) {
            throw new IllegalArgumentException("reader must not be null");
        }
        return unmarshal(new InputSource(reader));
    }
    public Object unmarshal(Source sourcethrows JAXBException {
        if (source == null) {
            throw new IllegalArgumentException("source must not be null");
        } else if (source instanceof SAXSource) {
            SAXSource saxSource = (SAXSourcesource;
            XMLReader reader = saxSource.getXMLReader();
            if (reader == null) {
                reader = getXMLReader();
            }
            return unmarshal(readersaxSource.getInputSource());
        } else if (source instanceof StreamSource) {
            StreamSource ss = (StreamSourcesource;
            InputSource is = new InputSource();
            is.setSystemId(ss.getSystemId());
            is.setByteStream(ss.getInputStream());
            is.setCharacterStream(ss.getReader());
            return unmarshal(is);
        } else if (source instanceof DOMSource)
            return unmarshal(((DOMSourcesource).getNode());
        else
            throw new IllegalArgumentException();
    }
    protected abstract Object unmarshal(XMLReader xmlreaderInputSource inputsourcethrows JAXBException;
    public <T> JAXBElement<T> unmarshal(Source sourceClass<T> declaredTypethrows JAXBException {
        throw new UnsupportedOperationException();
    }
    public final Object unmarshal(URL urlthrows JAXBException {
        if(url == null) {
            throw new IllegalArgumentException("url must not be null");
        }
        return unmarshal(new InputSource(url.toExternalForm()));
    }
    public Object unmarshal(XMLEventReader readerthrows JAXBException {
        throw new UnsupportedOperationException();
    }
    public <T> JAXBElement<T> unmarshal(XMLEventReader readerClass<T> declaredTypethrows JAXBException {
        throw new UnsupportedOperationException();
    }
    public Object unmarshal(XMLStreamReader readerthrows JAXBException {
        throw new UnsupportedOperationException();
    }
    public <T> JAXBElement<T> unmarshal(XMLStreamReader readerClass<T> declaredTypethrows JAXBException {
        throw new UnsupportedOperationException();
    }
New to GrepCode? Check out our FAQ X