Java Code Examples for org.xml.sax.SAXException#getException()

The following examples show how to use org.xml.sax.SAXException#getException() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractUnmarshallerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an UnmarshalException from a SAXException.
 *
 * This is an utility method provided for the derived classes.
 *
 * <p>
 * When a provider-implemented ContentHandler wants to throw a
 * JAXBException, it needs to wrap the exception by a SAXException.
 * If the unmarshaller implementation blindly wrap SAXException
 * by JAXBException, such an exception will be a JAXBException
 * wrapped by a SAXException wrapped by another JAXBException.
 * This is silly.
 *
 * <p>
 * This method checks the nested exception of SAXException
 * and reduce those excessive wrapping.
 *
 * @return the resulting UnmarshalException
 */
protected UnmarshalException createUnmarshalException( SAXException e ) {
    // check the nested exception to see if it's an UnmarshalException
    Exception nested = e.getException();
    if(nested instanceof UnmarshalException)
        return (UnmarshalException)nested;

    if(nested instanceof RuntimeException)
        // typically this is an unexpected exception,
        // just throw it rather than wrap it, so that the full stack
        // trace can be displayed.
        throw (RuntimeException)nested;


    // otherwise simply wrap it
    if(nested!=null)
        return new UnmarshalException(nested);
    else
        return new UnmarshalException(e);
}
 
Example 2
Source File: AbstractUnmarshallerImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an UnmarshalException from a SAXException.
 *
 * This is an utility method provided for the derived classes.
 *
 * <p>
 * When a provider-implemented ContentHandler wants to throw a
 * JAXBException, it needs to wrap the exception by a SAXException.
 * If the unmarshaller implementation blindly wrap SAXException
 * by JAXBException, such an exception will be a JAXBException
 * wrapped by a SAXException wrapped by another JAXBException.
 * This is silly.
 *
 * <p>
 * This method checks the nested exception of SAXException
 * and reduce those excessive wrapping.
 *
 * @return the resulting UnmarshalException
 */
protected UnmarshalException createUnmarshalException( SAXException e ) {
    // check the nested exception to see if it's an UnmarshalException
    Exception nested = e.getException();
    if(nested instanceof UnmarshalException)
        return (UnmarshalException)nested;

    if(nested instanceof RuntimeException)
        // typically this is an unexpected exception,
        // just throw it rather than wrap it, so that the full stack
        // trace can be displayed.
        throw (RuntimeException)nested;


    // otherwise simply wrap it
    if(nested!=null)
        return new UnmarshalException(nested);
    else
        return new UnmarshalException(e);
}
 
Example 3
Source File: ScriptDocument.java    From L2jBrasil with GNU General Public License v3.0 6 votes vote down vote up
public ScriptDocument(String name, InputStream input)
{
    _name = name;

    DocumentBuilderFactory factory =
        DocumentBuilderFactory.newInstance();
    try {
       DocumentBuilder builder = factory.newDocumentBuilder();
       _document = builder.parse( input );

    } catch (SAXException sxe) {
       // Error generated during parsing)
       Exception  x = sxe;
       if (sxe.getException() != null)
           x = sxe.getException();
       x.printStackTrace();

    } catch (ParserConfigurationException pce) {
        // Parser with specified options can't be built
        pce.printStackTrace();

    } catch (IOException ioe) {
       // I/O error
       ioe.printStackTrace();
    }
}
 
Example 4
Source File: AbstractUnmarshallerImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an UnmarshalException from a SAXException.
 *
 * This is an utility method provided for the derived classes.
 *
 * <p>
 * When a provider-implemented ContentHandler wants to throw a
 * JAXBException, it needs to wrap the exception by a SAXException.
 * If the unmarshaller implementation blindly wrap SAXException
 * by JAXBException, such an exception will be a JAXBException
 * wrapped by a SAXException wrapped by another JAXBException.
 * This is silly.
 *
 * <p>
 * This method checks the nested exception of SAXException
 * and reduce those excessive wrapping.
 *
 * @return the resulting UnmarshalException
 */
protected UnmarshalException createUnmarshalException( SAXException e ) {
    // check the nested exception to see if it's an UnmarshalException
    Exception nested = e.getException();
    if(nested instanceof UnmarshalException)
        return (UnmarshalException)nested;

    if(nested instanceof RuntimeException)
        // typically this is an unexpected exception,
        // just throw it rather than wrap it, so that the full stack
        // trace can be displayed.
        throw (RuntimeException)nested;


    // otherwise simply wrap it
    if(nested!=null)
        return new UnmarshalException(nested);
    else
        return new UnmarshalException(e);
}
 
Example 5
Source File: AbstractUnmarshallerImpl.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an UnmarshalException from a SAXException.
 *
 * This is an utility method provided for the derived classes.
 *
 * <p>
 * When a provider-implemented ContentHandler wants to throw a
 * JAXBException, it needs to wrap the exception by a SAXException.
 * If the unmarshaller implementation blindly wrap SAXException
 * by JAXBException, such an exception will be a JAXBException
 * wrapped by a SAXException wrapped by another JAXBException.
 * This is silly.
 *
 * <p>
 * This method checks the nested exception of SAXException
 * and reduce those excessive wrapping.
 *
 * @return the resulting UnmarshalException
 */
protected UnmarshalException createUnmarshalException( SAXException e ) {
    // check the nested exception to see if it's an UnmarshalException
    Exception nested = e.getException();
    if(nested instanceof UnmarshalException)
        return (UnmarshalException)nested;

    if(nested instanceof RuntimeException)
        // typically this is an unexpected exception,
        // just throw it rather than wrap it, so that the full stack
        // trace can be displayed.
        throw (RuntimeException)nested;


    // otherwise simply wrap it
    if(nested!=null)
        return new UnmarshalException(nested);
    else
        return new UnmarshalException(e);
}
 
Example 6
Source File: ParserContext.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ParserContext( XSOMParser owner, XMLParser parser ) {
    this.owner = owner;
    this.parser = parser;

    try {
        parse(new InputSource(ParserContext.class.getResource("datatypes.xsd").toExternalForm()));

        SchemaImpl xs = (SchemaImpl)
            schemaSet.getSchema("http://www.w3.org/2001/XMLSchema");
        xs.addSimpleType(schemaSet.anySimpleType,true);
        xs.addComplexType(schemaSet.anyType,true);
    } catch( SAXException e ) {
        // this must be a bug of XSOM
        if(e.getException()!=null)
            e.getException().printStackTrace();
        else
            e.printStackTrace();
        throw new InternalError();
    }
}
 
Example 7
Source File: CQL2XServerFindCommand.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public CQL2XServerFindCommand() {
	// initialize stack
	cqlStack = new java.util.Stack();
	
	// initialize SAX Parser
	SAXParserFactory factory;
	
	factory = SAXParserFactory.newInstance();
	factory.setNamespaceAware( true );
	try {
		saxParser = factory.newSAXParser();
	} catch (SAXException sxe) {
           // Error generated by this application
           // (or a parser-initialization error)
           Exception x = sxe;

           if (sxe.getException() != null) {
               x = sxe.getException();
           }

           log.warn( "CQL2XServerFindCommand() SAX exception: " + sxe.getMessage(),
           		x );
       } catch (ParserConfigurationException pce) {
           // Parser with specified options can't be built
       	log.warn( "CQL2XServerFindCommand() SAX parser cannot be built with " +
       			"specified options" );
       }
}
 
Example 8
Source File: SynthParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses a set of styles from <code>inputStream</code>, adding the
 * resulting styles to the passed in DefaultSynthStyleFactory.
 * Resources are resolved either from a URL or from a Class. When calling
 * this method, one of the URL or the Class must be null but not both at
 * the same time.
 *
 * @param inputStream XML document containing the styles to read
 * @param factory DefaultSynthStyleFactory that new styles are added to
 * @param urlResourceBase the URL used to resolve any resources, such as Images
 * @param classResourceBase the Class used to resolve any resources, such as Images
 * @param defaultsMap Map that UIDefaults properties are placed in
 */
public void parse(InputStream inputStream,
                  DefaultSynthStyleFactory factory,
                  URL urlResourceBase, Class<?> classResourceBase,
                  Map<String, Object> defaultsMap)
                  throws ParseException, IllegalArgumentException {
    if (inputStream == null || factory == null ||
        (urlResourceBase == null && classResourceBase == null)) {
        throw new IllegalArgumentException(
            "You must supply an InputStream, StyleFactory and Class or URL");
    }

    assert(!(urlResourceBase != null && classResourceBase != null));

    _factory = factory;
    _classResourceBase = classResourceBase;
    _urlResourceBase = urlResourceBase;
    _defaultsMap = defaultsMap;
    try {
        try {
            SAXParser saxParser = SAXParserFactory.newInstance().
                                               newSAXParser();
            saxParser.parse(new BufferedInputStream(inputStream), this);
        } catch (ParserConfigurationException e) {
            throw new ParseException("Error parsing: " + e, 0);
        }
        catch (SAXException se) {
            throw new ParseException("Error parsing: " + se + " " +
                                     se.getException(), 0);
        }
        catch (IOException ioe) {
            throw new ParseException("Error parsing: " + ioe, 0);
        }
    } finally {
        reset();
    }
}
 
Example 9
Source File: SAXAdapter.java    From awacs with Apache License 2.0 5 votes vote down vote up
protected void addDocumentEnd() {
    try {
        h.endDocument();
    } catch (SAXException ex) {
        throw new RuntimeException(ex.getMessage(), ex.getException());
    }
}
 
Example 10
Source File: EntityResolver2Wrapper.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>Locates an external subset for documents which do not explicitly
 * provide one. If no external subset is provided, this method should
 * return <code>null</code>.</p>
 *
 * @param grammarDescription a description of the DTD
 *
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource getExternalSubset(XMLDTDDescription grammarDescription)
        throws XNIException, IOException {

    if (fEntityResolver != null) {

        String name = grammarDescription.getRootName();
        String baseURI = grammarDescription.getBaseSystemId();

        // Resolve using EntityResolver2
        try {
            InputSource inputSource = fEntityResolver.getExternalSubset(name, baseURI);
            return (inputSource != null) ? createXMLInputSource(inputSource, baseURI) : null;
        }
        // error resolving external subset
        catch (SAXException e) {
            Exception ex = e.getException();
            if (ex == null) {
                ex = e;
            }
            throw new XNIException(ex);
        }
    }

    // unable to resolve external subset
    return null;

}
 
Example 11
Source File: SAXAdapter.java    From awacs with Apache License 2.0 5 votes vote down vote up
protected final void addStart(final String name, final Attributes attrs) {
    try {
        h.startElement("", name, name, attrs);
    } catch (SAXException ex) {
        throw new RuntimeException(ex.getMessage(), ex.getException());
    }
}
 
Example 12
Source File: EntityResolver2Wrapper.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * <p>Locates an external subset for documents which do not explicitly
 * provide one. If no external subset is provided, this method should
 * return <code>null</code>.</p>
 *
 * @param grammarDescription a description of the DTD
 *
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource getExternalSubset(XMLDTDDescription grammarDescription)
        throws XNIException, IOException {

    if (fEntityResolver != null) {

        String name = grammarDescription.getRootName();
        String baseURI = grammarDescription.getBaseSystemId();

        // Resolve using EntityResolver2
        try {
            InputSource inputSource = fEntityResolver.getExternalSubset(name, baseURI);
            return (inputSource != null) ? createXMLInputSource(inputSource, baseURI) : null;
        }
        // error resolving external subset
        catch (SAXException e) {
            Exception ex = e.getException();
            if (ex == null) {
                ex = e;
            }
            throw new XNIException(ex);
        }
    }

    // unable to resolve external subset
    return null;

}
 
Example 13
Source File: EntityResolver2Wrapper.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * <p>Locates an external subset for documents which do not explicitly
 * provide one. If no external subset is provided, this method should
 * return <code>null</code>.</p>
 *
 * @param grammarDescription a description of the DTD
 *
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource getExternalSubset(XMLDTDDescription grammarDescription)
        throws XNIException, IOException {

    if (fEntityResolver != null) {

        String name = grammarDescription.getRootName();
        String baseURI = grammarDescription.getBaseSystemId();

        // Resolve using EntityResolver2
        try {
            InputSource inputSource = fEntityResolver.getExternalSubset(name, baseURI);
            return (inputSource != null) ? createXMLInputSource(inputSource, baseURI) : null;
        }
        // error resolving external subset
        catch (SAXException e) {
            Exception ex = e.getException();
            if (ex == null) {
                ex = e;
            }
            throw new XNIException(ex);
        }
    }

    // unable to resolve external subset
    return null;

}
 
Example 14
Source File: MockIndicatorCriteriaDAO.java    From webcurator with Apache License 2.0 5 votes vote down vote up
public MockIndicatorCriteriaDAO(String filename)
{
	try
	{
		userRoleDAO = new MockUserRoleDAO(filename);
        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
        theFile = docBuilder.parse (new File(filename));
        
    	NodeList indicatorCriteriaNodes = theFile.getElementsByTagName("indicator-criteria");
    	
    	//force a nested load of everything
        loadIndicatorCriteriasFromNodeList(indicatorCriteriaNodes);
	}
   	catch (SAXParseException err) 
   	{
        log.debug ("** Parsing error" + ", line " 
             + err.getLineNumber () + ", uri " + err.getSystemId ());
        log.debug(" " + err.getMessage ());
       }
   	catch (SAXException se) 
   	{
           Exception x = se.getException ();
           ((x == null) ? se : x).printStackTrace ();
       }
    catch (Exception e) 
    {
    	log.debug(e.getClass().getName() + ": " + e.getMessage ());
    }
}
 
Example 15
Source File: JsonFromCat.java    From EventCoreference with Apache License 2.0 5 votes vote down vote up
public void parseFile(String filePath) {
        initPart();
        fileName = new File(filePath).getName();
        initSingletonId(filePath);
        String myerror = "";
        try {
            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setValidating(false);
            SAXParser parser = factory.newSAXParser();
            InputSource inp = new InputSource (new FileReader(filePath));
            parser.parse(inp, this);
/*
            System.out.println("eventTermArrayList.size(); = " + eventTermArrayList.size());
            System.out.println("timeLinks = " + timeLinks.size());
            System.out.println("locationLinks = " + locationLinks.size());
            System.out.println("plotLinks = " + plotLinks.size());
*/

        } catch (SAXParseException err) {
            myerror = "\n** Parsing error" + ", line " + err.getLineNumber()
                    + ", uri " + err.getSystemId();
            myerror += "\n" + err.getMessage();
            System.out.println("myerror = " + myerror);
        } catch (SAXException e) {
            Exception x = e;
            if (e.getException() != null)
                x = e.getException();
            myerror += "\nSAXException --" + x.getMessage();
            System.out.println("myerror = " + myerror);
        } catch (Exception eee) {
            eee.printStackTrace();
            myerror += "\nException --" + eee.getMessage();
            System.out.println("myerror = " + myerror);
        }
        //System.out.println("myerror = " + myerror);
    }
 
Example 16
Source File: EntityResolver2Wrapper.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier contains the physical co-ordinates of the resource to be resolved
 *
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
        throws XNIException, IOException {

    if (fEntityResolver != null) {

        String pubId = resourceIdentifier.getPublicId();
        String sysId = resourceIdentifier.getLiteralSystemId();
        String baseURI = resourceIdentifier.getBaseSystemId();
        String name = null;
        if (resourceIdentifier instanceof XMLDTDDescription) {
            name = "[dtd]";
        }
        else if (resourceIdentifier instanceof XMLEntityDescription) {
            name = ((XMLEntityDescription) resourceIdentifier).getEntityName();
        }

        // When both pubId and sysId are null, the user's entity resolver
        // can do nothing about it. We'd better not bother calling it.
        // This happens when the resourceIdentifier is a GrammarDescription,
        // which describes a schema grammar of some namespace, but without
        // any schema location hint. -Sg
        if (pubId == null && sysId == null) {
            return null;
        }

        // Resolve using EntityResolver2
        try {
            InputSource inputSource =
                fEntityResolver.resolveEntity(name, pubId, baseURI, sysId);
            return (inputSource != null) ? createXMLInputSource(inputSource, baseURI) : null;
        }
        // error resolving entity
        catch (SAXException e) {
            Exception ex = e.getException();
            if (ex == null) {
                ex = e;
            }
            throw new XNIException(ex);
        }
    }

    // unable to resolve entity
    return null;

}
 
Example 17
Source File: EntityResolverWrapper.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier        contains the physical co-ordinates of the resource to be resolved
 *
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException {

    // When both pubId and sysId are null, the user's entity resolver
    // can do nothing about it. We'd better not bother calling it.
    // This happens when the resourceIdentifier is a GrammarDescription,
    // which describes a schema grammar of some namespace, but without
    // any schema location hint. -Sg
    String pubId = resourceIdentifier.getPublicId();
    String sysId = resourceIdentifier.getExpandedSystemId();
    if (pubId == null && sysId == null)
        return null;

    // resolve entity using SAX entity resolver
    if (fEntityResolver != null && resourceIdentifier != null) {
        try {
            InputSource inputSource = fEntityResolver.resolveEntity(pubId, sysId);
            if (inputSource != null) {
                String publicId = inputSource.getPublicId();
                String systemId = inputSource.getSystemId();
                String baseSystemId = resourceIdentifier.getBaseSystemId();
                InputStream byteStream = inputSource.getByteStream();
                Reader charStream = inputSource.getCharacterStream();
                String encoding = inputSource.getEncoding();
                XMLInputSource xmlInputSource =
                    new XMLInputSource(publicId, systemId, baseSystemId);
                xmlInputSource.setByteStream(byteStream);
                xmlInputSource.setCharacterStream(charStream);
                xmlInputSource.setEncoding(encoding);
                return xmlInputSource;
            }
        }

        // error resolving entity
        catch (SAXException e) {
            Exception ex = e.getException();
            if (ex == null) {
                ex = e;
            }
            throw new XNIException(ex);
        }
    }

    // unable to resolve entity
    return null;

}
 
Example 18
Source File: EntityResolverWrapper.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier        contains the physical co-ordinates of the resource to be resolved
 *
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException {

    // When both pubId and sysId are null, the user's entity resolver
    // can do nothing about it. We'd better not bother calling it.
    // This happens when the resourceIdentifier is a GrammarDescription,
    // which describes a schema grammar of some namespace, but without
    // any schema location hint. -Sg
    String pubId = resourceIdentifier.getPublicId();
    String sysId = resourceIdentifier.getExpandedSystemId();
    if (pubId == null && sysId == null)
        return null;

    // resolve entity using SAX entity resolver
    if (fEntityResolver != null && resourceIdentifier != null) {
        try {
            InputSource inputSource = fEntityResolver.resolveEntity(pubId, sysId);
            if (inputSource != null) {
                String publicId = inputSource.getPublicId();
                String systemId = inputSource.getSystemId();
                String baseSystemId = resourceIdentifier.getBaseSystemId();
                InputStream byteStream = inputSource.getByteStream();
                Reader charStream = inputSource.getCharacterStream();
                String encoding = inputSource.getEncoding();
                XMLInputSource xmlInputSource =
                    new XMLInputSource(publicId, systemId, baseSystemId);
                xmlInputSource.setByteStream(byteStream);
                xmlInputSource.setCharacterStream(charStream);
                xmlInputSource.setEncoding(encoding);
                return xmlInputSource;
            }
        }

        // error resolving entity
        catch (SAXException e) {
            Exception ex = e.getException();
            if (ex == null) {
                ex = e;
            }
            throw new XNIException(ex);
        }
    }

    // unable to resolve entity
    return null;

}
 
Example 19
Source File: EntityResolverWrapper.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier        contains the physical co-ordinates of the resource to be resolved
 *
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException {

    // When both pubId and sysId are null, the user's entity resolver
    // can do nothing about it. We'd better not bother calling it.
    // This happens when the resourceIdentifier is a GrammarDescription,
    // which describes a schema grammar of some namespace, but without
    // any schema location hint. -Sg
    String pubId = resourceIdentifier.getPublicId();
    String sysId = resourceIdentifier.getExpandedSystemId();
    if (pubId == null && sysId == null)
        return null;

    // resolve entity using SAX entity resolver
    if (fEntityResolver != null && resourceIdentifier != null) {
        try {
            InputSource inputSource = fEntityResolver.resolveEntity(pubId, sysId);
            if (inputSource != null) {
                String publicId = inputSource.getPublicId();
                String systemId = inputSource.getSystemId();
                String baseSystemId = resourceIdentifier.getBaseSystemId();
                InputStream byteStream = inputSource.getByteStream();
                Reader charStream = inputSource.getCharacterStream();
                String encoding = inputSource.getEncoding();
                XMLInputSource xmlInputSource =
                    new XMLInputSource(publicId, systemId, baseSystemId);
                xmlInputSource.setByteStream(byteStream);
                xmlInputSource.setCharacterStream(charStream);
                xmlInputSource.setEncoding(encoding);
                return xmlInputSource;
            }
        }

        // error resolving entity
        catch (SAXException e) {
            Exception ex = e.getException();
            if (ex == null) {
                ex = e;
            }
            throw new XNIException(ex);
        }
    }

    // unable to resolve entity
    return null;

}
 
Example 20
Source File: MockTargetDAO.java    From webcurator with Apache License 2.0 4 votes vote down vote up
public MockTargetDAO(String filename) 
{
	
	factory.setProfileManager(new MockProfileManager(filename));
	userRoleDAO = new MockUserRoleDAO(filename);
	annotationDAO = new MockAnnotationDAO(filename);
	siteDAO = new MockSiteDAO(filename);
	
	try
	{
        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
        theFile = docBuilder.parse (new File(filename));
        
    	NodeList profileNodes = theFile.getElementsByTagName("profile");
    	NodeList targetNodes = theFile.getElementsByTagName("target");
    	NodeList groupNodes = theFile.getElementsByTagName("group");
    	NodeList groupMemberNodes = theFile.getElementsByTagName("group-member");
    	
    	//force a nested load of everything
        loadProfilesFromNodeList(profileNodes);
        loadTargetsFromNodeList(targetNodes);
        loadGroupsFromNodeList(groupNodes);
        loadGroupMembersFromNodeList(groupMemberNodes);
        
	}
   	catch (SAXParseException err) 
   	{
        log.debug ("** Parsing error" + ", line " 
             + err.getLineNumber () + ", uri " + err.getSystemId ());
        log.debug(" " + err.getMessage ());
       }
   	catch (SAXException se) 
   	{
           Exception x = se.getException ();
           ((x == null) ? se : x).printStackTrace ();
       }
    catch (Exception e) 
    {
    	log.debug(e.getClass().getName() + ": " + e.getMessage ());
    }
}