You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by si...@apache.org on 2009/04/13 23:43:52 UTC

svn commit: r764626 - in /maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder: PomClassicDomainModel.java ProcessorContext.java interpolator/DomainModel.java

Author: sisbell
Date: Mon Apr 13 21:43:52 2009
New Revision: 764626

URL: http://svn.apache.org/viewvc?rev=764626&view=rev
Log:
Centralized usage of model properties into processor context. Moved usage from domain model.

Modified:
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ProcessorContext.java
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/interpolator/DomainModel.java

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java?rev=764626&r1=764625&r2=764626&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java (original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java Mon Apr 13 21:43:52 2009
@@ -7,26 +7,11 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
 
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.project.builder.interpolator.DomainModel;
-import org.apache.maven.project.builder.interpolator.ModelProperty;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.WriterFactory;
@@ -47,8 +32,6 @@
     private File parentFile;
 
     private File projectDirectory;
-
-    private List<ModelProperty> modelProperties;
     
     private int lineageCount;
     
@@ -68,37 +51,33 @@
     	String groupId = null, artifactId = null, version = null;
 
     	groupId = model.getGroupId();
-
     	artifactId = model.getArtifactId();
     	version = model.getVersion();
     	
     	if( model.getParent() != null)
     	{
     		parentArtifactId =model.getParent().getArtifactId();
-
     		parentGroupId = model.getParent().getGroupId();
-
     		parentVersion = model.getParent().getVersion();
-
     		parentRelativePath = model.getParent().getRelativePath();
-    	}
-
-    	if( groupId == null && parentGroupId != null)
-    	{
-    		groupId = parentGroupId;
-    	}
-    	if( artifactId == null && parentArtifactId != null)
-    	{
-    		artifactId = parentArtifactId;
-    	}
-    	if( version == null && parentVersion != null )
-    	{
-    		version = parentVersion;
-    	}
-
-    	if(parentGroupId != null && parentArtifactId != null && parentVersion != null)
-    	{
-    		parentId = parentGroupId + ":" + parentArtifactId + ":" + parentVersion;
+    		
+    		if( groupId == null && parentGroupId != null)
+    		{
+    			groupId = parentGroupId;
+    		}
+    		if( artifactId == null && parentArtifactId != null)
+    		{
+    			artifactId = parentArtifactId;
+    		}
+    		if( version == null && parentVersion != null )
+    		{
+    			version = parentVersion;
+    		}
+    		
+        	if(parentGroupId != null && parentArtifactId != null && parentVersion != null)
+        	{
+        		parentId = parentGroupId + ":" + parentArtifactId + ":" + parentVersion;
+        	}
     	}
 
     	if(parentRelativePath == null)
@@ -218,8 +197,7 @@
     {
         return id;
     }
-
-
+    
     public boolean matchesParentOf( PomClassicDomainModel domainModel ) throws IOException
     {
         if ( domainModel == null )
@@ -266,40 +244,6 @@
         return file;
     }
 
-    public List<ModelProperty> getModelProperties() throws IOException
-    {
-        if(modelProperties == null)
-        {
-            Set<String> s = new HashSet<String>();
-            //TODO: Should add all collections from ProjectUri
-            s.addAll(URIS);
-            s.add(ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri);
-            s.add(ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.xUri);
-            s.add(ProjectUri.Dependencies.Dependency.Exclusions.xUri);
-            s.add(ProjectUri.Build.Plugins.Plugin.Executions.xUri);
-            s.add(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.xURI);
-            s.add(ProjectUri.Reporting.Plugins.Plugin.ReportSets.xUri);
-            s.add(ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.configuration);
-            s.add(ProjectUri.Build.Plugins.Plugin.Executions.Execution.configuration);
-            //TODO: More profile info
-            s.add(ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Executions.xUri);
-            s.add(ProjectUri.Profiles.Profile.DependencyManagement.Dependencies.Dependency.Exclusions.xUri);
-            s.add(ProjectUri.Profiles.Profile.Dependencies.Dependency.Exclusions.xUri);
-            s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Executions.xUri);
-            s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Executions.Execution.Goals.xURI);
-            s.add(ProjectUri.Profiles.Profile.Reporting.Plugins.Plugin.ReportSets.xUri);
-            s.add(ProjectUri.Profiles.Profile.Reporting.Plugins.Plugin.ReportSets.ReportSet.configuration);
-            s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Executions.Execution.configuration);
-            s.add(ProjectUri.Profiles.Profile.properties);
-            s.add(ProjectUri.Profiles.Profile.modules);
-            s.add(ProjectUri.Profiles.Profile.Dependencies.xUri);
-            s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.configuration);
-            
-            modelProperties = marshallXmlToModelProperties(getInputStream(), ProjectUri.baseUri, s );
-        }
-        return new ArrayList<ModelProperty>(modelProperties);
-    }
-
     public int getLineageCount()
     {
         return lineageCount;
@@ -341,222 +285,5 @@
         return String.valueOf( id );
     }
     
-    private static final Set<String> URIS = Collections.unmodifiableSet(new HashSet<String>( Arrays.asList(  ProjectUri.Build.Extensions.xUri,
-            ProjectUri.Build.PluginManagement.Plugins.xUri,
-            ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration,
-            ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri,
-            ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.Execution.Goals.xURI,
-            ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
-            ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri,
-            ProjectUri.Build.Plugins.xUri,
-            ProjectUri.properties,
-            ProjectUri.Build.Plugins.Plugin.configuration,
-            ProjectUri.Reporting.Plugins.xUri,
-            ProjectUri.Reporting.Plugins.Plugin.configuration,
-            ProjectUri.Build.Plugins.Plugin.Dependencies.xUri,
-            ProjectUri.Build.Resources.xUri,
-            ProjectUri.Build.Resources.Resource.includes,
-            ProjectUri.Build.Resources.Resource.excludes,
-            ProjectUri.Build.TestResources.xUri,
-            ProjectUri.Build.Filters.xUri,
-            ProjectUri.CiManagement.Notifiers.xUri,
-            ProjectUri.Contributors.xUri,
-            ProjectUri.Dependencies.xUri,
-            ProjectUri.DependencyManagement.Dependencies.xUri,
-            ProjectUri.Developers.xUri,
-            ProjectUri.Developers.Developer.roles,
-            ProjectUri.Licenses.xUri,
-            ProjectUri.MailingLists.xUri,
-            ProjectUri.Modules.xUri,
-            ProjectUri.PluginRepositories.xUri,
-            ProjectUri.Profiles.xUri,
-            ProjectUri.Profiles.Profile.Build.Plugins.xUri,
-            ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Dependencies.xUri,
-            ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Executions.xUri,
-            ProjectUri.Profiles.Profile.Build.Resources.xUri,
-            ProjectUri.Profiles.Profile.Build.TestResources.xUri,
-            ProjectUri.Profiles.Profile.Dependencies.xUri,
-            ProjectUri.Profiles.Profile.DependencyManagement.Dependencies.xUri,
-            ProjectUri.Profiles.Profile.PluginRepositories.xUri,
-            ProjectUri.Profiles.Profile.Reporting.Plugins.xUri,
-            ProjectUri.Profiles.Profile.Repositories.xUri,
-            ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.xUri,
-            ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
-            ProjectUri.Reporting.Plugins.xUri,
-            ProjectUri.Repositories.xUri) ));    
-    
-   /**
-    * Returns list of model properties transformed from the specified input stream.
-    *
-    * @param inputStream input stream containing the xml document. May not be null.
-    * @param baseUri     the base uri of every model property. May not be null or empty.
-    * @param collections set of uris that are to be treated as a collection (multiple entries). May be null.
-    * @return list of model properties transformed from the specified input stream.
-    * @throws IOException if there was a problem doing the transform
-    */
-    public static List<ModelProperty> marshallXmlToModelProperties( InputStream inputStream, String baseUri,
-            Set<String> collections )
-			throws IOException {
-		if (inputStream == null) {
-			throw new IllegalArgumentException("inputStream: null");
-		}
-
-		if (baseUri == null || baseUri.trim().length() == 0) {
-			throw new IllegalArgumentException("baseUri: null");
-		}
-
-		if (collections == null) {
-			collections = Collections.emptySet();
-		}
-
-		List<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
-		XMLInputFactory xmlInputFactory = new com.ctc.wstx.stax.WstxInputFactory();
-		xmlInputFactory.setProperty(
-				XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
-		xmlInputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE,
-				Boolean.FALSE);
-
-		Uri uri = new Uri(baseUri);
-		String tagName = baseUri;
-		StringBuilder tagValue = new StringBuilder(256);
-
-		int depth = 0;
-		int depthOfTagValue = depth;
-		XMLStreamReader xmlStreamReader = null;
-		try {
-			xmlStreamReader = xmlInputFactory
-					.createXMLStreamReader(inputStream);
-
-			Map<String, String> attributes = new HashMap<String, String>();
-			for (;; xmlStreamReader.next()) {
-				int type = xmlStreamReader.getEventType();
-				switch (type) {
-
-				case XMLStreamConstants.CDATA:
-				case XMLStreamConstants.CHARACTERS: {
-					if (depth == depthOfTagValue) {
-						tagValue.append(xmlStreamReader.getTextCharacters(),
-								xmlStreamReader.getTextStart(), xmlStreamReader
-										.getTextLength());
-					}
-					break;
-				}
-
-				case XMLStreamConstants.START_ELEMENT: {
-					if (!tagName.equals(baseUri)) {
-						String value = null;
-						if (depth < depthOfTagValue) {
-							value = tagValue.toString().trim();
-						}
-						modelProperties.add(new ModelProperty(tagName, value));
-						if (!attributes.isEmpty()) {
-							for (Map.Entry<String, String> e : attributes
-									.entrySet()) {
-								modelProperties.add(new ModelProperty(e
-										.getKey(), e.getValue()));
-							}
-							attributes.clear();
-						}
-					}
-
-					depth++;
-					tagName = uri.getUriFor(xmlStreamReader.getName()
-							.getLocalPart(), depth);
-					if (collections.contains(tagName + "#collection")) {
-						tagName = tagName + "#collection";
-						uri.addTag(xmlStreamReader.getName().getLocalPart()
-								+ "#collection");
-					} else if (collections.contains(tagName + "#set")) {
-						tagName = tagName + "#set";
-						uri.addTag(xmlStreamReader.getName().getLocalPart()
-								+ "#set");
-					} else {
-						uri.addTag(xmlStreamReader.getName().getLocalPart());
-					}
-					tagValue.setLength(0);
-					depthOfTagValue = depth;
-				}
-				case XMLStreamConstants.ATTRIBUTE: {
-					for (int i = 0; i < xmlStreamReader.getAttributeCount(); i++) {
-
-						attributes.put(tagName
-								+ "#property/"
-								+ xmlStreamReader.getAttributeName(i)
-										.getLocalPart(), xmlStreamReader
-								.getAttributeValue(i));
-					}
-					break;
-				}
-				case XMLStreamConstants.END_ELEMENT: {
-					depth--;
-					break;
-				}
-				case XMLStreamConstants.END_DOCUMENT: {
-					modelProperties.add(new ModelProperty(tagName, tagValue
-							.toString().trim()));
-					if (!attributes.isEmpty()) {
-						for (Map.Entry<String, String> e : attributes
-								.entrySet()) {
-							modelProperties.add(new ModelProperty(e.getKey(), e
-									.getValue()));
-						}
-						attributes.clear();
-					}
-					return modelProperties;
-				}
-				}
-			}
-		} catch (XMLStreamException e) {
-			throw new IOException(":" + e.toString());
-		} finally {
-			if (xmlStreamReader != null) {
-				try {
-					xmlStreamReader.close();
-				} catch (XMLStreamException e) {
-					e.printStackTrace();
-				}
-			}
-			try {
-				inputStream.close();
-			} catch (IOException e) {
-
-			}
-		}
-	}
-   /**
-    * Class for storing information about URIs.
-    */
-   private static class Uri
-   {
-
-       List<String> uris;
-
-       Uri( String baseUri )
-       {
-           uris = new LinkedList<String>();
-           uris.add( baseUri );
-       }
-
-       String getUriFor( String tag, int depth )
-       {
-           setUrisToDepth( depth );
-           StringBuffer sb = new StringBuffer();
-           for ( String tagName : uris )
-           {
-               sb.append( tagName ).append( "/" );
-           }
-           sb.append( tag );
-           return sb.toString();
-       }
-
-       void addTag( String tag )
-       {
-           uris.add( tag );
-       }
-
-       void setUrisToDepth( int depth )
-       {
-           uris = new LinkedList<String>( uris.subList( 0, depth ) );
-       }
-   }
+ 
 }

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ProcessorContext.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ProcessorContext.java?rev=764626&r1=764625&r2=764626&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ProcessorContext.java (original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ProcessorContext.java Mon Apr 13 21:43:52 2009
@@ -22,6 +22,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -30,8 +31,15 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
 
 import org.apache.maven.model.BuildBase;
 import org.apache.maven.model.Dependency;
@@ -454,7 +462,7 @@
 			aliases.put("\\$\\{project.version\\}", "\\$\\{version\\}");
 		}
 		//TODO: Insert customized logic for parsing
-		List<ModelProperty> modelProperties = dm.getModelProperties();
+		List<ModelProperty> modelProperties = getModelProperties(dm.getInputStream());
 
 		if ("jar".equals(dm.getModel().getPackaging())) {
 			modelProperties.add(new ModelProperty(ProjectUri.packaging, "jar"));
@@ -848,4 +856,251 @@
         return sb.toString();
     }    
     
+    public static List<ModelProperty> getModelProperties(InputStream is) throws IOException
+    {
+            Set<String> s = new HashSet<String>();
+            //TODO: Should add all collections from ProjectUri
+            s.addAll(URIS);
+            s.add(ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri);
+            s.add(ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.xUri);
+            s.add(ProjectUri.Dependencies.Dependency.Exclusions.xUri);
+            s.add(ProjectUri.Build.Plugins.Plugin.Executions.xUri);
+            s.add(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.xURI);
+            s.add(ProjectUri.Reporting.Plugins.Plugin.ReportSets.xUri);
+            s.add(ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.configuration);
+            s.add(ProjectUri.Build.Plugins.Plugin.Executions.Execution.configuration);
+            //TODO: More profile info
+            s.add(ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Executions.xUri);
+            s.add(ProjectUri.Profiles.Profile.DependencyManagement.Dependencies.Dependency.Exclusions.xUri);
+            s.add(ProjectUri.Profiles.Profile.Dependencies.Dependency.Exclusions.xUri);
+            s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Executions.xUri);
+            s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Executions.Execution.Goals.xURI);
+            s.add(ProjectUri.Profiles.Profile.Reporting.Plugins.Plugin.ReportSets.xUri);
+            s.add(ProjectUri.Profiles.Profile.Reporting.Plugins.Plugin.ReportSets.ReportSet.configuration);
+            s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Executions.Execution.configuration);
+            s.add(ProjectUri.Profiles.Profile.properties);
+            s.add(ProjectUri.Profiles.Profile.modules);
+            s.add(ProjectUri.Profiles.Profile.Dependencies.xUri);
+            s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.configuration);
+            
+        return new ArrayList<ModelProperty>(marshallXmlToModelProperties(is, ProjectUri.baseUri, s ));
+    }    
+    private static final Set<String> URIS = Collections.unmodifiableSet(new HashSet<String>( Arrays.asList(  ProjectUri.Build.Extensions.xUri,
+            ProjectUri.Build.PluginManagement.Plugins.xUri,
+            ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration,
+            ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri,
+            ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.Execution.Goals.xURI,
+            ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
+            ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri,
+            ProjectUri.Build.Plugins.xUri,
+            ProjectUri.properties,
+            ProjectUri.Build.Plugins.Plugin.configuration,
+            ProjectUri.Reporting.Plugins.xUri,
+            ProjectUri.Reporting.Plugins.Plugin.configuration,
+            ProjectUri.Build.Plugins.Plugin.Dependencies.xUri,
+            ProjectUri.Build.Resources.xUri,
+            ProjectUri.Build.Resources.Resource.includes,
+            ProjectUri.Build.Resources.Resource.excludes,
+            ProjectUri.Build.TestResources.xUri,
+            ProjectUri.Build.Filters.xUri,
+            ProjectUri.CiManagement.Notifiers.xUri,
+            ProjectUri.Contributors.xUri,
+            ProjectUri.Dependencies.xUri,
+            ProjectUri.DependencyManagement.Dependencies.xUri,
+            ProjectUri.Developers.xUri,
+            ProjectUri.Developers.Developer.roles,
+            ProjectUri.Licenses.xUri,
+            ProjectUri.MailingLists.xUri,
+            ProjectUri.Modules.xUri,
+            ProjectUri.PluginRepositories.xUri,
+            ProjectUri.Profiles.xUri,
+            ProjectUri.Profiles.Profile.Build.Plugins.xUri,
+            ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Dependencies.xUri,
+            ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Executions.xUri,
+            ProjectUri.Profiles.Profile.Build.Resources.xUri,
+            ProjectUri.Profiles.Profile.Build.TestResources.xUri,
+            ProjectUri.Profiles.Profile.Dependencies.xUri,
+            ProjectUri.Profiles.Profile.DependencyManagement.Dependencies.xUri,
+            ProjectUri.Profiles.Profile.PluginRepositories.xUri,
+            ProjectUri.Profiles.Profile.Reporting.Plugins.xUri,
+            ProjectUri.Profiles.Profile.Repositories.xUri,
+            ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.xUri,
+            ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
+            ProjectUri.Reporting.Plugins.xUri,
+            ProjectUri.Repositories.xUri) ));    
+    
+   /**
+    * Returns list of model properties transformed from the specified input stream.
+    *
+    * @param inputStream input stream containing the xml document. May not be null.
+    * @param baseUri     the base uri of every model property. May not be null or empty.
+    * @param collections set of uris that are to be treated as a collection (multiple entries). May be null.
+    * @return list of model properties transformed from the specified input stream.
+    * @throws IOException if there was a problem doing the transform
+    */
+    public static List<ModelProperty> marshallXmlToModelProperties( InputStream inputStream, String baseUri,
+            Set<String> collections )
+			throws IOException {
+		if (inputStream == null) {
+			throw new IllegalArgumentException("inputStream: null");
+		}
+
+		if (baseUri == null || baseUri.trim().length() == 0) {
+			throw new IllegalArgumentException("baseUri: null");
+		}
+
+		if (collections == null) {
+			collections = Collections.emptySet();
+		}
+
+		List<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
+		XMLInputFactory xmlInputFactory = new com.ctc.wstx.stax.WstxInputFactory();
+		xmlInputFactory.setProperty(
+				XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
+		xmlInputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE,
+				Boolean.FALSE);
+
+		Uri uri = new Uri(baseUri);
+		String tagName = baseUri;
+		StringBuilder tagValue = new StringBuilder(256);
+
+		int depth = 0;
+		int depthOfTagValue = depth;
+		XMLStreamReader xmlStreamReader = null;
+		try {
+			xmlStreamReader = xmlInputFactory
+					.createXMLStreamReader(inputStream);
+
+			Map<String, String> attributes = new HashMap<String, String>();
+			for (;; xmlStreamReader.next()) {
+				int type = xmlStreamReader.getEventType();
+				switch (type) {
+
+				case XMLStreamConstants.CDATA:
+				case XMLStreamConstants.CHARACTERS: {
+					if (depth == depthOfTagValue) {
+						tagValue.append(xmlStreamReader.getTextCharacters(),
+								xmlStreamReader.getTextStart(), xmlStreamReader
+										.getTextLength());
+					}
+					break;
+				}
+
+				case XMLStreamConstants.START_ELEMENT: {
+					if (!tagName.equals(baseUri)) {
+						String value = null;
+						if (depth < depthOfTagValue) {
+							value = tagValue.toString().trim();
+						}
+						modelProperties.add(new ModelProperty(tagName, value));
+						if (!attributes.isEmpty()) {
+							for (Map.Entry<String, String> e : attributes
+									.entrySet()) {
+								modelProperties.add(new ModelProperty(e
+										.getKey(), e.getValue()));
+							}
+							attributes.clear();
+						}
+					}
+
+					depth++;
+					tagName = uri.getUriFor(xmlStreamReader.getName()
+							.getLocalPart(), depth);
+					if (collections.contains(tagName + "#collection")) {
+						tagName = tagName + "#collection";
+						uri.addTag(xmlStreamReader.getName().getLocalPart()
+								+ "#collection");
+					} else if (collections.contains(tagName + "#set")) {
+						tagName = tagName + "#set";
+						uri.addTag(xmlStreamReader.getName().getLocalPart()
+								+ "#set");
+					} else {
+						uri.addTag(xmlStreamReader.getName().getLocalPart());
+					}
+					tagValue.setLength(0);
+					depthOfTagValue = depth;
+				}
+				case XMLStreamConstants.ATTRIBUTE: {
+					for (int i = 0; i < xmlStreamReader.getAttributeCount(); i++) {
+
+						attributes.put(tagName
+								+ "#property/"
+								+ xmlStreamReader.getAttributeName(i)
+										.getLocalPart(), xmlStreamReader
+								.getAttributeValue(i));
+					}
+					break;
+				}
+				case XMLStreamConstants.END_ELEMENT: {
+					depth--;
+					break;
+				}
+				case XMLStreamConstants.END_DOCUMENT: {
+					modelProperties.add(new ModelProperty(tagName, tagValue
+							.toString().trim()));
+					if (!attributes.isEmpty()) {
+						for (Map.Entry<String, String> e : attributes
+								.entrySet()) {
+							modelProperties.add(new ModelProperty(e.getKey(), e
+									.getValue()));
+						}
+						attributes.clear();
+					}
+					return modelProperties;
+				}
+				}
+			}
+		} catch (XMLStreamException e) {
+			throw new IOException(":" + e.toString());
+		} finally {
+			if (xmlStreamReader != null) {
+				try {
+					xmlStreamReader.close();
+				} catch (XMLStreamException e) {
+					e.printStackTrace();
+				}
+			}
+			try {
+				inputStream.close();
+			} catch (IOException e) {
+
+			}
+		}
+	}
+   /**
+    * Class for storing information about URIs.
+    */
+   private static class Uri
+   {
+
+       List<String> uris;
+
+       Uri( String baseUri )
+       {
+           uris = new LinkedList<String>();
+           uris.add( baseUri );
+       }
+
+       String getUriFor( String tag, int depth )
+       {
+           setUrisToDepth( depth );
+           StringBuffer sb = new StringBuffer();
+           for ( String tagName : uris )
+           {
+               sb.append( tagName ).append( "/" );
+           }
+           sb.append( tag );
+           return sb.toString();
+       }
+
+       void addTag( String tag )
+       {
+           uris.add( tag );
+       }
+
+       void setUrisToDepth( int depth )
+       {
+           uris = new LinkedList<String>( uris.subList( 0, depth ) );
+       }
+   }    
 }

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/interpolator/DomainModel.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/interpolator/DomainModel.java?rev=764626&r1=764625&r2=764626&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/interpolator/DomainModel.java (original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/interpolator/DomainModel.java Mon Apr 13 21:43:52 2009
@@ -4,8 +4,6 @@
 import java.util.List;
 
 public interface DomainModel {
-	
-    List<ModelProperty> getModelProperties() throws IOException;
     
     boolean isMostSpecialized();