ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model Resources.properties ModelElementUtil.java
Date Sun, 02 Jun 2002 04:59:40 GMT
adammurdoch    2002/06/01 21:59:40

  Modified:    container/src/java/org/apache/myrmidon/interfaces/model
                        ModelElementUtil.java
  Added:       container/src/java/org/apache/myrmidon/interfaces/model
                        Resources.properties
  Log:
  Added an error message.
  
  Revision  Changes    Path
  1.2       +25 -11    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/ModelElementUtil.java
  
  Index: ModelElementUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/ModelElementUtil.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ModelElementUtil.java	18 May 2002 04:05:58 -0000	1.1
  +++ ModelElementUtil.java	2 Jun 2002 04:59:40 -0000	1.2
  @@ -10,16 +10,22 @@
   import javax.xml.parsers.SAXParser;
   import javax.xml.parsers.SAXParserFactory;
   import org.apache.myrmidon.api.metadata.ModelElement;
  +import org.apache.myrmidon.interfaces.ComponentException;
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
  +import org.apache.avalon.excalibur.i18n.Resources;
   import org.xml.sax.XMLReader;
   
   /**
    * Utility methods for dealing with {@link org.apache.myrmidon.api.metadata.ModelElement}
objects.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.1 $ $Date: 2002/05/18 04:05:58 $
  + * @version $Revision: 1.2 $ $Date: 2002/06/02 04:59:40 $
    */
   public class ModelElementUtil
   {
  +    private static final Resources REZ =
  +        ResourceManager.getPackageResources( ModelElementUtil.class );
  +
       /**
        * Loads a model from an XML document.
        *
  @@ -29,18 +35,26 @@
       public static ModelElement loadModel( final String systemId )
           throws Exception
       {
  -        final ModelElementSaxHandler contentHandler = new ModelElementSaxHandler();
  -        final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
  -        final SAXParser saxParser = saxParserFactory.newSAXParser();
  -        final XMLReader parser = saxParser.getXMLReader();
  -        parser.setFeature( "http://xml.org/sax/features/namespace-prefixes", false );
  -        parser.setFeature( "http://xml.org/sax/features/namespaces", false );
  -        //parser.setFeature( "http://xml.org/sax/features/validation", false );
  +        try
  +        {
  +            final ModelElementSaxHandler contentHandler = new ModelElementSaxHandler();
  +            final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
  +            final SAXParser saxParser = saxParserFactory.newSAXParser();
  +            final XMLReader parser = saxParser.getXMLReader();
  +            parser.setFeature( "http://xml.org/sax/features/namespace-prefixes", false
);
  +            parser.setFeature( "http://xml.org/sax/features/namespaces", false );
  +            //parser.setFeature( "http://xml.org/sax/features/validation", false );
   
  -        parser.setContentHandler( contentHandler );
  -        parser.parse( systemId );
  +            parser.setContentHandler( contentHandler );
  +            parser.parse( systemId );
   
  -        return contentHandler.getModel();
  +            return contentHandler.getModel();
  +        }
  +        catch( final Exception e )
  +        {
  +            final String message = REZ.getString( "load-model.error", systemId );
  +            throw new ComponentException( message, e );
  +        }
       }
   
       /**
  
  
  
  1.3       +1 -6      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/Resources.properties
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message