Browse Source

Modified interface to reflect the fact it is no longer a flyweight and

thus can be passed Parameters via standard mechanisms (Parameterizable).

Also rearranged implementation so that it is friendly for inheritance (Still needs lots more work).


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269192 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
112b6039b3
1 changed files with 32 additions and 14 deletions
  1. +32
    -14
      proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java

+ 32
- 14
proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java View File

@@ -51,7 +51,7 @@ public class DefaultProjectBuilder
* @exception IOException if an error occurs * @exception IOException if an error occurs
* @exception Exception if an error occurs * @exception Exception if an error occurs
*/ */
public Project build( final String source, final Parameters parameters )
public Project build( final String source )
throws Exception throws Exception
{ {
final File file = new File( source ); final File file = new File( source );
@@ -62,25 +62,15 @@ public class DefaultProjectBuilder
throws Exception throws Exception
{ {
final String systemID = file.toURL().toString(); final String systemID = file.toURL().toString();

Project result = (Project)projects.get( systemID );
final Project result = (Project)projects.get( systemID );
if( null != result ) if( null != result )
{ {
return result; return result;
} }


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 );

final SAXConfigurationHandler handler = new SAXConfigurationHandler(); final SAXConfigurationHandler handler = new SAXConfigurationHandler();
parser.setContentHandler( handler );
parser.setErrorHandler( handler );


parser.parse( systemID );
process( systemID, handler );


final Configuration configuration = handler.getConfiguration(); final Configuration configuration = handler.getConfiguration();
final DefaultProject project = buildProject( file, configuration ); final DefaultProject project = buildProject( file, configuration );
@@ -93,6 +83,34 @@ public class DefaultProjectBuilder
return project; return project;
} }


protected void process( final String systemID,
final SAXConfigurationHandler handler )
throws Exception
{
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( handler );
parser.setErrorHandler( handler );
parser.parse( systemID );
/*
// Create a transform factory instance.
final TransformerFactory factory = TransformerFactory.newInstance();
// Create a transformer for the stylesheet.
final Transformer transformer = factory.newTransformer( new StreamSource(xslID) );

final Result result = new SAXResult( handler );

// Transform the source XML to System.out.
transformer.transform( new StreamSource(sourceID), result );
*/
}

/** /**
* build project from configuration. * build project from configuration.
* *
@@ -139,7 +157,7 @@ public class DefaultProjectBuilder
* @param configuration the Configuration * @param configuration the Configuration
* @exception Exception if an error occurs * @exception Exception if an error occurs
*/ */
private void buildTopLevelProject( final DefaultProject project,
private void buildTopLevelProject( final DefaultProject project,
final Configuration configuration, final Configuration configuration,
final HashMap projects ) final HashMap projects )
throws Exception throws Exception


Loading…
Cancel
Save