qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r526446 [2/6] - in /incubator/qpid/trunk/qpid/gentools: src/org/apache/qpid/gentools/ templ.cpp/ templ.cpp/class/ templ.cpp/field/ templ.cpp/method/ templ.cpp/model/ templ.java/ templ.java/class/ templ.java/field/ templ.java/method/ templ.j...
Date Sat, 07 Apr 2007 16:01:46 GMT
Modified: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpFieldMap.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpFieldMap.java?view=diff&rev=526446&r1=526445&r2=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpFieldMap.java (original)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpFieldMap.java Sat Apr  7 09:01:43 2007
@@ -20,329 +20,419 @@
  */
 package org.apache.qpid.gentools;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
 import java.util.TreeMap;
 
 @SuppressWarnings("serial")
-public class AmqpFieldMap extends TreeMap<String, AmqpField> implements VersionConsistencyCheck
+public class AmqpFieldMap implements VersionConsistencyCheck
 {
-	public void removeVersion(AmqpVersion version)
-	{
-		String[] fieldNameArray = new String[size()];
-		keySet().toArray(fieldNameArray);
-		for (String fieldName : fieldNameArray)
-		{
-			get(fieldName).removeVersion(version);
-			remove(fieldName);
-		}
-	}
-	
-	public AmqpFieldMap getFieldMapForOrdinal(int ordinal)
-	{
-		AmqpFieldMap newMap = new AmqpFieldMap();
-		for (String thisFieldName: keySet())
-		{
-			AmqpField field = get(thisFieldName);
-			TreeMap<Integer, AmqpVersionSet> ordinalMap = field.ordinalMap;
-			AmqpVersionSet ordinalVersions = ordinalMap.get(ordinal);
-			if (ordinalVersions != null)
-			{
-				newMap.put(field.name, field);
-			}
-		}
-		return newMap;
-	}
-	
-	public AmqpOrdinalFieldMap getMapForVersion(AmqpVersion version, boolean codeTypeFlag,
-		LanguageConverter converter)
-		throws AmqpTypeMappingException
-	{
-		// TODO: REVIEW THIS! There may be a bug here that affects C++ generation (only with >1 version)...
-		// If version == null (a common scenario) then the version map is built up on the
-		// basis of first found item, and ignores other version variations.
-		// This should probably be disallowed by throwing an NPE, as AmqpOrdinalFieldMap cannot
-		// represent these possibilities.
-		// *OR*
-		// Change the structure of AmqpOrdianlFieldMap to allow for the various combinations that
-		// will result from version variation - but that is what AmqpFieldMap is... :-$
-		AmqpOrdinalFieldMap ordinalFieldMap = new AmqpOrdinalFieldMap();
-		for (String thisFieldName: keySet())
-		{
-			AmqpField field = get(thisFieldName);
-			if (version == null || field.versionSet.contains(version))
-			{
-				// 1. Search for domain name in field domain map with version that matches
-				String domain = "";
-				boolean dFound = false;
-				for (String thisDomainName : field.domainMap.keySet())
-				{
-					domain = thisDomainName;
-					AmqpVersionSet versionSet = field.domainMap.get(domain);
-					if (version == null || versionSet.contains(version))
-					{
-						if (codeTypeFlag)
-							domain = converter.getGeneratedType(domain, version);
-						dFound = true;
-					}
-				}
-				
-				// 2. Search for ordinal in field ordianl map with version that matches
-				int ordinal = -1;
-				boolean oFound = false;
-				for (Integer thisOrdinal : field.ordinalMap.keySet())
-				{
-					ordinal = thisOrdinal;
-					AmqpVersionSet versionSet = field.ordinalMap.get(ordinal);
-					if (version == null || versionSet.contains(version))
-						oFound = true;
-				}
-				
-				if (dFound && oFound)
-				{
-					String[] fieldDomainPair = {field.name, domain};
-					ordinalFieldMap.put(ordinal, fieldDomainPair);
-				}
-			}
-		}
-		return ordinalFieldMap;
-	}
-		
-	public boolean isDomainConsistent(Generator generator, AmqpVersionSet versionSet)
-        throws AmqpTypeMappingException
-	{
-		if (size() != 1) // Only one field for this ordinal
-			return false;
-		return get(firstKey()).isConsistent(generator);
-	}
-	
-	public int getNumFields(AmqpVersion version)
-	{
-		int fCntr = 0;
-		for (String thisFieldName : keySet())
-		{
-			AmqpField field = get(thisFieldName);
-			if (field.versionSet.contains(version))
-				fCntr++;
-		}
-		return fCntr;
-	}
-	
-	public String parseFieldMap(Method commonGenerateMethod, Method mangledGenerateMethod,
-		int indentSize, int tabSize, LanguageConverter converter)
-        throws AmqpTypeMappingException, IllegalAccessException, InvocationTargetException
-	{
-		String indent = Utils.createSpaces(indentSize);
-		String cr = Utils.lineSeparator;
-		StringBuffer sb = new StringBuffer();
-		
-		if (commonGenerateMethod == null)
-		{
-			// Generate warnings in code if required methods are null.
-			sb.append(indent + "/*********************************************************" + cr);
-			sb.append(indent + " * WARNING: Generated code could be missing." + cr);
-			sb.append(indent + " * In call to parseFieldMap(), generation method was null." + cr);
-			sb.append(indent + " * Check for NoSuchMethodException on startup." + cr);
-			sb.append(indent + " *********************************************************/" + cr);
-		}
-
-		Iterator<String> itr = keySet().iterator();
-		while (itr.hasNext())
-		{
-			String fieldName = itr.next();
-			AmqpField field = get(fieldName);
-			if (field.isCodeTypeConsistent(converter))
-			{
-				// All versions identical - Common declaration
-				String domainName = field.domainMap.firstKey();
-				AmqpVersionSet versionSet = field.domainMap.get(domainName);
-				String codeType = converter.getGeneratedType(domainName, versionSet.first());
-				if (commonGenerateMethod != null)
-					sb.append(commonGenerateMethod.invoke(converter, codeType, field, versionSet,
-					    indentSize, tabSize, itr.hasNext()));
-			}
-			else if (mangledGenerateMethod != null) // Version-mangled
-			{
-				sb.append(mangledGenerateMethod.invoke(converter, field, indentSize, tabSize,
-					itr.hasNext()));
-			}
-		}
-		return sb.toString();		
-	}
-	
-	public String parseFieldMapOrdinally(Method generateMethod, Method bitGenerateMethod,
-		int indentSize, int tabSize, Generator codeGenerator)
-	    throws AmqpTypeMappingException, IllegalAccessException, InvocationTargetException
-	{
-		String indent = Utils.createSpaces(indentSize);
-		String cr = Utils.lineSeparator;
-		StringBuffer sb = new StringBuffer();	    
-
-		// Generate warnings in code if required methods are null.
-		if (generateMethod == null || bitGenerateMethod == null)
-		{
-			sb.append(indent + "/***********************************************" + cr);
-			sb.append(indent + " * WARNING: In call to parseFieldMapOrdinally():" + cr);
-			if (generateMethod == null)
-				sb.append(indent + " *  => generateMethod is null." + cr);
-			if (bitGenerateMethod == null)
-				sb.append(indent + " *  => bitGenerateMethod is null." + cr);
-			sb.append(indent + " * Generated code could be missing." + cr);
-			sb.append(indent + " * Check for NoSuchMethodException on startup." + cr);
-			sb.append(indent + " ***********************************************/" + cr);
-		}
-
-		/* We must process elements in ordinal order because adjacent booleans (bits)
-		 * must be combined into a single byte (in groups of up to 8). Start with shared
-		 * declarations until an ordinal divergence is found. (For most methods where
-		 * there is no difference between versions, this will simplify the generated
-		 * code. */
-
-		ArrayList<String> bitFieldList = new ArrayList<String>();
-		boolean ordinalDivergenceFlag = false;
-		int ordinal = 0;
-		while (ordinal < size() && !ordinalDivergenceFlag)
-		{
-			/* Since the getFieldMapOrdinal() function may map more than one Field to
-			 * an ordinal, the number of ordinals may be less than the total number of
-			 * fields in the fieldMap. Check for empty fieldmaps... */
-			AmqpFieldMap ordinalFieldMap = getFieldMapForOrdinal(ordinal);
-			if (ordinalFieldMap.size() > 0)
-			{
-				if (ordinalFieldMap.isDomainConsistent(codeGenerator, codeGenerator.globalVersionSet))
-				{
-					String fieldName = ordinalFieldMap.firstKey();
-					String domain = ordinalFieldMap.get(fieldName).domainMap.firstKey();
-					String domainType = codeGenerator.getDomainType(domain,
-						codeGenerator.globalVersionSet.first());
-					if (domainType.compareTo("bit") == 0)
-						bitFieldList.add(fieldName);
-					else if (bitFieldList.size() > 0)
-					{
-						// End of bit types - handle deferred bit type generation
-						if (bitGenerateMethod != null)
-							sb.append(bitGenerateMethod.invoke(codeGenerator, bitFieldList, ordinal,
-								indentSize, tabSize));
-						bitFieldList.clear();
-					}
-					if (!ordinalDivergenceFlag)
-					{
-						// Defer generation of bit types until all adjacent bits have been
-						// accounted for.
-						if (bitFieldList.size() == 0 && generateMethod != null)
-							sb.append(generateMethod.invoke(codeGenerator, domainType, fieldName, ordinal,
-								indentSize, tabSize));
-					}
-					ordinal++;
-				}
-				else
-				{
-					ordinalDivergenceFlag = true;
-				}
-			}
-		}
-
-		// Check if there is still more to do under a version-specific breakout
-		if (ordinalDivergenceFlag && ordinal< size())
-		{
-			// 1. Cycle through all versions in order, create outer if(version) structure
-			AmqpVersion[] versionArray = new AmqpVersion[codeGenerator.globalVersionSet.size()];
-			codeGenerator.globalVersionSet.toArray(versionArray);
-			for (int v=0; v<versionArray.length; v++)
-			{
-				sb.append(indent);
-				if (v > 0)
-					sb.append("else ");
-				sb.append("if (major == " + versionArray[v].getMajor() + " && minor == " +
-					versionArray[v].getMinor() + ")" + cr);
-				sb.append(indent + "{" + cr);
-				
-				// 2. Cycle though each ordinal from where we left off in the loop above.
-				ArrayList<String> bitFieldList2 = new ArrayList<String>(bitFieldList);
-				for (int o = ordinal; o<size(); o++)
-				{
-					AmqpFieldMap ordinalFieldMap = getFieldMapForOrdinal(o);
-					if (ordinalFieldMap.size() > 0)
-					{
-						// 3. Cycle through each of the fields that have this ordinal.
-						Iterator<String> i = ordinalFieldMap.keySet().iterator();
-						while (i.hasNext())
-						{
-							String fieldName = i.next();
-							AmqpField field = ordinalFieldMap.get(fieldName);
-
-							// 4. Some fields may have more than one ordinal - match by both
-							//    ordinal and version.
-							Iterator<Integer> j = field.ordinalMap.keySet().iterator();
-							while (j.hasNext())
-							{
-								int thisOrdinal = j.next();
-								AmqpVersionSet v1 = field.ordinalMap.get(thisOrdinal);
-								if (thisOrdinal == o && v1.contains(versionArray[v]))
-								{
-									// 5. Now get the domain for this version
-									int domainCntr = 0;
-									Iterator<String> k = field.domainMap.keySet().iterator();
-									while (k.hasNext())
-									{
-										// Mangle domain-divergent field names
-										String mangledFieldName = fieldName;
-										if (field.domainMap.size() > 1)
-											mangledFieldName += "_" + (domainCntr++);
-										String domainName = k.next();
-										AmqpVersionSet v2 = field.domainMap.get(domainName);
-										if (v2.contains(versionArray[v]))
-										{
-											// 6. (Finally!!) write the declaration
-											String domainType = codeGenerator.getDomainType(domainName,
-												versionArray[v]);
-											if (domainType.compareTo("bit") == 0)
-												bitFieldList2.add(mangledFieldName);
-											else if (bitFieldList2.size() > 0)
-											{
-												// End of bit types - handle deferred bit type generation
-												if (bitGenerateMethod != null)
-													sb.append(bitGenerateMethod.invoke(codeGenerator,
-														bitFieldList2, o, indentSize + tabSize,
-														tabSize));
-												bitFieldList2.clear();
-											}
-											// Defer generation of bit types until all adjacent bits have
-											// been accounted for.
-											if (bitFieldList2.size() == 0 && generateMethod != null)
-												sb.append(generateMethod.invoke(codeGenerator, domainType,
-														mangledFieldName, o, indentSize + tabSize, tabSize));
-										}
-									}
-								}
-							}
-						}
-					}
-				}
-				// Check for remaining deferred bits
-				if (bitFieldList2.size() > 0 && bitGenerateMethod != null)
-					sb.append(bitGenerateMethod.invoke(codeGenerator, bitFieldList2, size(),
-						indentSize + tabSize, tabSize));
-				sb.append(indent + "}" + cr);
-			}
-		}
-		// Check for remaining deferred bits
-		else if (bitFieldList.size() > 0 && bitGenerateMethod != null)
-			sb.append(bitGenerateMethod.invoke(codeGenerator, bitFieldList, size(),
-				indentSize, tabSize));
-		return sb.toString();		
-	}
-	
-	public boolean isVersionConsistent(AmqpVersionSet globalVersionSet)
-	{
-		for (String thisFieldName : keySet())
-		{
-			AmqpField field = get(thisFieldName);
-			if (!field.isVersionConsistent(globalVersionSet))
-				return false;
-		}
-		return true;
-	}
+
+    private final TreeMap<String, AmqpField> _map = new TreeMap<String, AmqpField>();
+
+    private final AmqpVersionSet _versionSet = new AmqpVersionSet();
+
+    public void removeVersion(AmqpVersion version)
+    {
+        String[] fieldNameArray = new String[size()];
+        _map.keySet().toArray(fieldNameArray);
+        Iterator<Entry<String, AmqpField>> iter = _map.entrySet().iterator();
+
+        while (iter.hasNext())
+        {
+            Entry<String, AmqpField> entry = iter.next();
+            entry.getValue().removeVersion(version);
+            iter.remove();
+        }
+    }
+
+    public int size()
+    {
+        return _map.size();
+
+    }
+
+    public AmqpFieldMap getFieldMapForOrdinal(int ordinal)
+    {
+        AmqpFieldMap newMap = new AmqpFieldMap();
+        for (AmqpField field : _map.values())
+        {
+
+            TreeMap<Integer, AmqpVersionSet> ordinalMap = field.getOrdinalMap();
+            AmqpVersionSet ordinalVersions = ordinalMap.get(ordinal);
+            if (ordinalVersions != null)
+            {
+                newMap.add(field.getName(), field);
+            }
+        }
+        return newMap;
+    }
+
+    public void add(String name, AmqpField field)
+    {
+        _versionSet.addAll(field.getVersionSet());
+        _map.put(name, field);
+    }
+
+    public AmqpOrdinalFieldMap getMapForVersion(AmqpVersion version, boolean codeTypeFlag,
+                                                LanguageConverter converter)
+    {
+        // TODO: REVIEW THIS! There may be a bug here that affects C++ generation (only with >1 version)...
+        // If version == null (a common scenario) then the version map is built up on the
+        // basis of first found item, and ignores other version variations.
+        // This should probably be disallowed by throwing an NPE, as AmqpOrdinalFieldMap cannot
+        // represent these possibilities.
+        // *OR*
+        // Change the structure of AmqpOrdianlFieldMap to allow for the various combinations that
+        // will result from version variation - but that is what AmqpFieldMap is... :-$
+        AmqpOrdinalFieldMap ordinalFieldMap = new AmqpOrdinalFieldMap();
+        for (AmqpField field : _map.values())
+        {
+
+            if (version == null || field.getVersionSet().contains(version))
+            {
+                // 1. Search for domain name in field domain map with version that matches
+                String domain = "";
+                boolean dFound = false;
+                for (String thisDomainName : field.getDomainMap().keySet())
+                {
+                    domain = thisDomainName;
+                    AmqpVersionSet versionSet = field.getDomainMap().get(domain);
+                    if (version == null || versionSet.contains(version))
+                    {
+                        if (codeTypeFlag)
+                        {
+                            domain = converter.getGeneratedType(domain, version);
+                        }
+                        dFound = true;
+                    }
+                }
+
+                // 2. Search for ordinal in field ordianl map with version that matches
+                int ordinal = -1;
+                boolean oFound = false;
+                for (Integer thisOrdinal : field.getOrdinalMap().keySet())
+                {
+                    ordinal = thisOrdinal;
+                    AmqpVersionSet versionSet = field.getOrdinalMap().get(ordinal);
+                    if (version == null || versionSet.contains(version))
+                    {
+                        oFound = true;
+                    }
+                }
+
+                if (dFound && oFound)
+                {
+                    String[] fieldDomainPair = {field.getName(), domain};
+                    ordinalFieldMap.put(ordinal, fieldDomainPair);
+                }
+            }
+        }
+        return ordinalFieldMap;
+    }
+
+    public boolean isDomainConsistent(Generator generator, AmqpVersionSet versionSet)
+            throws AmqpTypeMappingException
+    {
+        if (size() != 1) // Only one field for this ordinal
+        {
+            return false;
+        }
+        return _map.get(_map.firstKey()).isConsistent(generator);
+    }
+
+    public int getNumFields(AmqpVersion version)
+    {
+        int fCntr = 0;
+        for (AmqpField field : _map.values())
+        {
+
+            if (field.getVersionSet().contains(version))
+            {
+                fCntr++;
+            }
+        }
+        return fCntr;
+    }
+
+    public String parseFieldMap(CommandGenerateMethod commonGenerateMethod, MangledGenerateMethod mangledGenerateMethod,
+                                int indentSize, int tabSize, LanguageConverter converter)
+    {
+        String indent = Utils.createSpaces(indentSize);
+        String cr = Utils.LINE_SEPARATOR;
+        StringBuffer sb = new StringBuffer();
+
+        if (commonGenerateMethod == null)
+        {
+            // Generate warnings in code if required methods are null.
+            sb.append(indent + "/*********************************************************" + cr);
+            sb.append(indent + " * WARNING: Generated code could be missing." + cr);
+            sb.append(indent + " * In call to parseFieldMap(), generation method was null." + cr);
+            sb.append(indent + " * Check for NoSuchMethodException on startup." + cr);
+            sb.append(indent + " *********************************************************/" + cr);
+        }
+
+        Iterator<Entry<String, AmqpField>> itr = _map.entrySet().iterator();
+        while (itr.hasNext())
+        {
+            Entry<String, AmqpField> entry = itr.next();
+            String fieldName = entry.getKey();
+            AmqpField field = entry.getValue();
+            if (field.isCodeTypeConsistent(converter))
+            {
+                // All versions identical - Common declaration
+                String domainName = field.getDomainMap().firstKey();
+                AmqpVersionSet versionSet = field.getDomainMap().get(domainName);
+                String codeType = converter.getGeneratedType(domainName, versionSet.first());
+                if (commonGenerateMethod != null)
+                {
+                    sb.append(commonGenerateMethod.generate(codeType, field, versionSet,
+                                                            indentSize, tabSize, itr.hasNext()));
+                }
+            }
+            else if (mangledGenerateMethod != null) // Version-mangled
+            {
+                sb.append(mangledGenerateMethod.generate(field, indentSize, tabSize,
+                                                         itr.hasNext()));
+            }
+        }
+        return sb.toString();
+    }
+
+    public String parseFieldMapOrdinally(GenerateMethod generateMethod, BitFieldGenerateMethod bitGenerateMethod,
+                                         int indentSize, int tabSize, Generator codeGenerator)
+    {
+        String indent = Utils.createSpaces(indentSize);
+        String cr = Utils.LINE_SEPARATOR;
+        StringBuffer sb = new StringBuffer();
+
+        // Generate warnings in code if required methods are null.
+        if (generateMethod == null || bitGenerateMethod == null)
+        {
+            sb.append(indent + "/***********************************************" + cr);
+            sb.append(indent + " * WARNING: In call to parseFieldMapOrdinally():" + cr);
+            if (generateMethod == null)
+            {
+                sb.append(indent + " *  => generateMethod is null." + cr);
+            }
+            if (bitGenerateMethod == null)
+            {
+                sb.append(indent + " *  => bitGenerateMethod is null." + cr);
+            }
+            sb.append(indent + " * Generated code could be missing." + cr);
+            sb.append(indent + " * Check for NoSuchMethodException on startup." + cr);
+            sb.append(indent + " ***********************************************/" + cr);
+        }
+
+        /* We must process elements in ordinal order because adjacent booleans (bits)
+           * must be combined into a single byte (in groups of up to 8). Start with shared
+           * declarations until an ordinal divergence is found. (For most methods where
+           * there is no difference between versions, this will simplify the generated
+           * code. */
+
+        ArrayList<String> bitFieldList = new ArrayList<String>();
+        boolean ordinalDivergenceFlag = false;
+        int ordinal = 0;
+        while (ordinal < size() && !ordinalDivergenceFlag)
+        {
+            /* Since the getFieldMapOrdinal() function may map more than one Field to
+                * an ordinal, the number of ordinals may be less than the total number of
+                * fields in the fieldMap. Check for empty fieldmaps... */
+            AmqpFieldMap ordinalFieldMap = getFieldMapForOrdinal(ordinal);
+            if (ordinalFieldMap.size() > 0)
+            {
+                if (ordinalFieldMap.isDomainConsistent(codeGenerator, getVersionSet()))
+                {
+                    String fieldName = ordinalFieldMap.getFirstFieldName();
+                    String domain = ordinalFieldMap._map.get(fieldName).getDomainMap().firstKey();
+
+                    String domainType = codeGenerator.getDomainType(domain,
+                                                                    codeGenerator.getVersionSet().first());
+
+                    if (domainType.compareTo("bit") == 0)
+                    {
+                        bitFieldList.add(fieldName);
+                    }
+                    else if (bitFieldList.size() > 0)
+                    {
+                        // End of bit types - handle deferred bit type generation
+                        if (bitGenerateMethod != null)
+                        {
+                            sb.append(bitGenerateMethod.generate(bitFieldList, ordinal,
+                                                                 indentSize, tabSize));
+                        }
+                        bitFieldList.clear();
+                    }
+                    if (!ordinalDivergenceFlag)
+                    {
+                        // Defer generation of bit types until all adjacent bits have been
+                        // accounted for.
+                        if (bitFieldList.size() == 0 && generateMethod != null)
+                        {
+                            sb.append(generateMethod.generate(domainType, fieldName, ordinal,
+                                                              indentSize, tabSize));
+                        }
+                    }
+                    ordinal++;
+                }
+                else
+                {
+                    ordinalDivergenceFlag = true;
+                }
+            }
+        }
+
+        // Check if there is still more to do under a version-specific breakout
+        if (ordinalDivergenceFlag && ordinal < size())
+        {
+            // 1. Cycle through all versions in order, create outer if(version) structure
+            AmqpVersion[] versionArray = new AmqpVersion[getVersionSet().size()];
+            getVersionSet().toArray(versionArray);
+            for (int v = 0; v < versionArray.length; v++)
+            {
+                sb.append(indent);
+                if (v > 0)
+                {
+                    sb.append("else ");
+                }
+                sb.append("if (major == " + versionArray[v].getMajor() + " && minor == " +
+                          versionArray[v].getMinor() + ")" + cr);
+                sb.append(indent + "{" + cr);
+
+                // 2. Cycle though each ordinal from where we left off in the loop above.
+                ArrayList<String> bitFieldList2 = new ArrayList<String>(bitFieldList);
+                for (int o = ordinal; o < size(); o++)
+                {
+                    AmqpFieldMap ordinalFieldMap = getFieldMapForOrdinal(o);
+                    if (ordinalFieldMap.size() > 0)
+                    {
+                        // 3. Cycle through each of the fields that have this ordinal.
+                        Iterator<Map.Entry<String, AmqpField>> i = ordinalFieldMap._map.entrySet().iterator();
+                        while (i.hasNext())
+                        {
+
+                            Map.Entry<String, AmqpField> entry = i.next();
+                            AmqpField field = entry.getValue();
+                            String fieldName = entry.getKey();
+
+                            // 4. Some fields may have more than one ordinal - match by both
+                            //    ordinal and version.
+                            Iterator<Integer> j = field.getOrdinalMap().keySet().iterator();
+                            while (j.hasNext())
+                            {
+                                int thisOrdinal = j.next();
+                                AmqpVersionSet v1 = field.getOrdinalMap().get(thisOrdinal);
+                                if (thisOrdinal == o && v1.contains(versionArray[v]))
+                                {
+                                    // 5. Now get the domain for this version
+                                    int domainCntr = 0;
+                                    Iterator<String> k = field.getDomainMap().keySet().iterator();
+                                    while (k.hasNext())
+                                    {
+                                        // Mangle domain-divergent field names
+                                        String mangledFieldName = fieldName;
+                                        if (field.getDomainMap().size() > 1)
+                                        {
+                                            mangledFieldName += "_" + (domainCntr++);
+                                        }
+                                        String domainName = k.next();
+                                        AmqpVersionSet v2 = field.getDomainMap().get(domainName);
+                                        if (v2.contains(versionArray[v]))
+                                        {
+                                            // 6. (Finally!!) write the declaration
+                                            String domainType = codeGenerator.getDomainType(domainName,
+                                                                                            versionArray[v]);
+                                            if (domainType.compareTo("bit") == 0)
+                                            {
+                                                bitFieldList2.add(mangledFieldName);
+                                            }
+                                            else if (bitFieldList2.size() > 0)
+                                            {
+                                                // End of bit types - handle deferred bit type generation
+                                                if (bitGenerateMethod != null)
+                                                {
+                                                    sb.append(bitGenerateMethod.generate(
+                                                            bitFieldList2, o, indentSize + tabSize,
+                                                            tabSize));
+                                                }
+                                                bitFieldList2.clear();
+                                            }
+                                            // Defer generation of bit types until all adjacent bits have
+                                            // been accounted for.
+                                            if (bitFieldList2.size() == 0 && generateMethod != null)
+                                            {
+                                                sb.append(generateMethod.generate(domainType,
+                                                                                  mangledFieldName, o, indentSize + tabSize, tabSize));
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+                // Check for remaining deferred bits
+                if (bitFieldList2.size() > 0 && bitGenerateMethod != null)
+                {
+                    sb.append(bitGenerateMethod.generate(bitFieldList2, size(),
+                                                         indentSize + tabSize, tabSize));
+                }
+                sb.append(indent + "}" + cr);
+            }
+        }
+        // Check for remaining deferred bits
+        else if (bitFieldList.size() > 0 && bitGenerateMethod != null)
+        {
+            sb.append(bitGenerateMethod.generate(bitFieldList, size(),
+                                                 indentSize, tabSize));
+        }
+        return sb.toString();
+    }
+
+    private String getFirstFieldName()
+    {
+        return _map.firstKey();
+    }
+
+    public boolean isVersionConsistent(AmqpVersionSet globalVersionSet)
+    {
+        for (String thisFieldName : _map.keySet())
+        {
+            AmqpField field = _map.get(thisFieldName);
+            if (!field.isVersionConsistent(globalVersionSet))
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public AmqpVersionSet getVersionSet()
+    {
+        return _versionSet;
+    }
+
+    public Collection<AmqpField> values()
+    {
+        return _map.values();
+    }
+
+    public AmqpField get(String fieldName)
+    {
+        return _map.get(fieldName);
+    }
+
+    public void remove(String fieldName)
+    {
+        _map.remove(fieldName);
+    }
+
+    public Set<String> keySet()
+    {
+        return _map.keySet();
+    }
 }

Modified: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpFlagMap.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpFlagMap.java?view=diff&rev=526446&r1=526445&r2=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpFlagMap.java (original)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpFlagMap.java Sat Apr  7 09:01:43 2007
@@ -26,46 +26,52 @@
 @SuppressWarnings("serial")
 public class AmqpFlagMap extends TreeMap<Boolean, AmqpVersionSet> implements VersionConsistencyCheck
 {
-	public boolean isSet()
-	{
-		return containsKey(true);
-	}
-	
-	public String toString()
-	{
-		AmqpVersionSet versionSet = get(true);
-		if (versionSet != null)
-			return versionSet.toString();
-		return "";
-	}
-	
-	public boolean isVersionConsistent(AmqpVersionSet globalVersionSet)
-	{
-		if (size() != 1)
-			return false;
-		return get(firstKey()).equals(globalVersionSet);
-	}
-	
-	public boolean removeVersion(AmqpVersion version)
-	{
-		Boolean res = false;
-		ArrayList<Boolean> removeList = new ArrayList<Boolean>();
-		for (Boolean flag : keySet())
-		{
-			AmqpVersionSet versionSet = get(flag);
-			if (versionSet.contains(version))
-			{
-				versionSet.remove(version);
-				if (versionSet.isEmpty())
-					removeList.add(flag);
-				res = true;
-			}
-		}
-		// Get rid of flags no longer in use
-		for (Boolean flag : removeList)
-		{
-			remove(flag);
-		}
-		return res;
-	}
+    public boolean isSet()
+    {
+        return containsKey(true);
+    }
+
+    public String toString()
+    {
+        AmqpVersionSet versionSet = get(true);
+        if (versionSet != null)
+        {
+            return versionSet.toString();
+        }
+        return "";
+    }
+
+    public boolean isVersionConsistent(AmqpVersionSet globalVersionSet)
+    {
+        if (size() != 1)
+        {
+            return false;
+        }
+        return get(firstKey()).equals(globalVersionSet);
+    }
+
+    public boolean removeVersion(AmqpVersion version)
+    {
+        Boolean res = false;
+        ArrayList<Boolean> removeList = new ArrayList<Boolean>();
+        for (Boolean flag : keySet())
+        {
+            AmqpVersionSet versionSet = get(flag);
+            if (versionSet.contains(version))
+            {
+                versionSet.remove(version);
+                if (versionSet.isEmpty())
+                {
+                    removeList.add(flag);
+                }
+                res = true;
+            }
+        }
+        // Get rid of flags no longer in use
+        for (Boolean flag : removeList)
+        {
+            remove(flag);
+        }
+        return res;
+    }
 }

Modified: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethod.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethod.java?view=diff&rev=526446&r1=526445&r2=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethod.java (original)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethod.java Sat Apr  7 09:01:43 2007
@@ -20,183 +20,279 @@
  */
 package org.apache.qpid.gentools;
 
-import java.io.PrintStream;
-
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Collection;
+
 public class AmqpMethod implements Printable, NodeAware, VersionConsistencyCheck
 {
-	public LanguageConverter converter;
-	public AmqpVersionSet versionSet;
-	public AmqpFieldMap fieldMap;
-	public String name;
-	public AmqpOrdinalVersionMap indexMap;
-	public AmqpFlagMap clientMethodFlagMap; // Method called on client (<chassis name="server"> in XML)
-	public AmqpFlagMap serverMethodFlagMap; // Method called on server (<chassis name="client"> in XML)
-	
-	public AmqpMethod(String name, LanguageConverter converter)
-	{
-		this.name = name;
-		this.converter = converter;
-		versionSet = new AmqpVersionSet();
-		fieldMap = new AmqpFieldMap();
-		indexMap = new AmqpOrdinalVersionMap();
-		clientMethodFlagMap = new AmqpFlagMap();
-		serverMethodFlagMap = new AmqpFlagMap();
-	}
-
-	public boolean addFromNode(Node methodNode, int ordinal, AmqpVersion version)
-		throws AmqpParseException, AmqpTypeMappingException
-	{
-		versionSet.add(version);
-		boolean serverChassisFlag = false;
-		boolean clientChassisFlag = false;
-		int index = Utils.getNamedIntegerAttribute(methodNode, "index");
-		AmqpVersionSet indexVersionSet = indexMap.get(index);
-		if (indexVersionSet != null)
-			indexVersionSet.add(version);
-		else
-		{
-			indexVersionSet = new AmqpVersionSet();
-			indexVersionSet.add(version);
-			indexMap.put(index, indexVersionSet);
-		}
-		NodeList nList = methodNode.getChildNodes();
-		int fieldCntr = fieldMap.size();
-		for (int i=0; i<nList.getLength(); i++)
-		{
-			Node child = nList.item(i);
-			if (child.getNodeName().compareTo(Utils.ELEMENT_FIELD) == 0)
-			{
-				String fieldName = converter.prepareDomainName(Utils.getNamedAttribute(child,
-						Utils.ATTRIBUTE_NAME));
-				AmqpField thisField = fieldMap.get(fieldName);
-				if (thisField == null)
-				{
-					thisField = new AmqpField(fieldName, converter);
-					fieldMap.put(fieldName, thisField);
-				}
-				if (!thisField.addFromNode(child, fieldCntr++, version))
-				{
-					String className = converter.prepareClassName(Utils.getNamedAttribute(methodNode.getParentNode(),
-							Utils.ATTRIBUTE_NAME));
-					String methodName = converter.prepareMethodName(Utils.getNamedAttribute(methodNode,
-							Utils.ATTRIBUTE_NAME));
-					System.out.println("INFO: Generation supression tag found for field " +
-							className + "." + methodName + "." + fieldName + " - removing.");
-					thisField.removeVersion(version);
-					fieldMap.remove(fieldName);
-				}
-			}
-			else if (child.getNodeName().compareTo(Utils.ELEMENT_CHASSIS) == 0)
-			{
-				String chassisName = Utils.getNamedAttribute(child, Utils.ATTRIBUTE_NAME);
-				if (chassisName.compareTo("server") == 0)
-					serverChassisFlag = true;
-				else if (chassisName.compareTo("client") == 0)
-					clientChassisFlag = true;
-			}
-			else if (child.getNodeName().compareTo(Utils.ELEMENT_CODEGEN) == 0)
-			{
-				String value = Utils.getNamedAttribute(child, Utils.ATTRIBUTE_VALUE);
-				if (value.compareTo("no-gen") == 0)
-					return false;
-			}
-		}
-		processChassisFlags(serverChassisFlag, clientChassisFlag, version);
-		return true;
-	}
-	
-	public void removeVersion(AmqpVersion version)
-	{
-		clientMethodFlagMap.removeVersion(version);
-		serverMethodFlagMap.removeVersion(version);
-		indexMap.removeVersion(version);
-		fieldMap.removeVersion(version);
-		versionSet.remove(version);
-	}
-	
-	public void print(PrintStream out, int marginSize, int tabSize)
-	{
-		String margin = Utils.createSpaces(marginSize);
-		String tab = Utils.createSpaces(tabSize);
-		out.println(margin + "[M] " + name + " {" + (serverMethodFlagMap.isSet() ? "S " +
-			serverMethodFlagMap + (clientMethodFlagMap.isSet() ? ", " : "") : "") +
-			(clientMethodFlagMap.isSet() ? "C " + clientMethodFlagMap : "") + "}" + ": " +
-			versionSet);
-		
-		for (Integer thisIndex : indexMap.keySet())
-		{
-			AmqpVersionSet indexVersionSet = indexMap.get(thisIndex);
-			out.println(margin + tab + "[I] " + thisIndex + indexVersionSet);
-		}
-		
-		for (String thisFieldName : fieldMap.keySet())
-		{
-			AmqpField thisField = fieldMap.get(thisFieldName);
-			thisField.print(out, marginSize + tabSize, tabSize);
-		}
-	}
-	
-	protected void processChassisFlags(boolean serverFlag, boolean clientFlag, AmqpVersion version)
-	{
-		AmqpVersionSet versionSet = serverMethodFlagMap.get(serverFlag);
-		if (versionSet != null)
-			versionSet.add(version);
-		else
-		{
-			versionSet = new AmqpVersionSet();
-			versionSet.add(version);
-			serverMethodFlagMap.put(serverFlag, versionSet);
-		}
-		
-		versionSet = clientMethodFlagMap.get(clientFlag);
-		if (versionSet != null)
-			versionSet.add(version);
-		else
-		{
-			versionSet = new AmqpVersionSet();
-			versionSet.add(version);
-			clientMethodFlagMap.put(clientFlag, versionSet);
-		}		
-	}
-	
-	public AmqpOverloadedParameterMap getOverloadedParameterLists(AmqpVersionSet globalVersionSet,
-		Generator generator)
-		throws AmqpTypeMappingException
-	{
-		AmqpOverloadedParameterMap parameterVersionMap = new AmqpOverloadedParameterMap();
-		for (AmqpVersion thisVersion : globalVersionSet)
-		{
-			AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(thisVersion, true, generator);
-			AmqpVersionSet methodVersionSet = parameterVersionMap.get(ordinalFieldMap);
-			if (methodVersionSet == null)
-			{
-				methodVersionSet = new AmqpVersionSet();
-				methodVersionSet.add(thisVersion);
-				parameterVersionMap.put(ordinalFieldMap, methodVersionSet);
-			}
-			else
-			{
-				methodVersionSet.add(thisVersion);
-			}
-		}
-		return parameterVersionMap;
-	}
-		
-	public boolean isVersionConsistent(AmqpVersionSet globalVersionSet)
-	{
-		if (!versionSet.equals(globalVersionSet))
-			return false;
-		if (!clientMethodFlagMap.isVersionConsistent(globalVersionSet))
-			return false;
-		if (!serverMethodFlagMap.isVersionConsistent(globalVersionSet))
-			return false;
-		if (!indexMap.isVersionConsistent(globalVersionSet))
-			return false;
-		if (!fieldMap.isVersionConsistent(globalVersionSet))
-			return false;
-		return true;
-	}
+    private final AmqpVersionSet _versionSet = new AmqpVersionSet();
+    private final AmqpFieldMap _fieldMap = new AmqpFieldMap();
+
+    private final AmqpOrdinalVersionMap _indexMap = new AmqpOrdinalVersionMap();
+    private final AmqpFlagMap _clientMethodFlagMap = new AmqpFlagMap(); // Method called on client (<chassis name="server"> in XML)
+    private final AmqpFlagMap _serverMethodFlagMap = new AmqpFlagMap(); // Method called on server (<chassis name="client"> in XML)
+
+    private final Map<AmqpVersion, AmqpFieldMap> _versionToFieldsMap = new HashMap<AmqpVersion, AmqpFieldMap>();
+
+    private final String _name;
+    private final Generator _generator;
+
+
+    public AmqpMethod(String name, Generator generator)
+    {
+        _name = name;
+        _generator = generator;
+    }
+
+    public boolean addFromNode(Node methodNode, int ordinal, AmqpVersion version)
+            throws AmqpParseException, AmqpTypeMappingException
+    {
+        _versionSet.add(version);
+        boolean serverChassisFlag = false;
+        boolean clientChassisFlag = false;
+        int index = Utils.getNamedIntegerAttribute(methodNode, "index");
+        AmqpVersionSet indexVersionSet = _indexMap.get(index);
+        if (indexVersionSet != null)
+        {
+            indexVersionSet.add(version);
+        }
+        else
+        {
+            indexVersionSet = new AmqpVersionSet();
+            indexVersionSet.add(version);
+            _indexMap.put(index, indexVersionSet);
+        }
+        NodeList nList = methodNode.getChildNodes();
+        int fieldCntr = _fieldMap.size();
+        for (int i = 0; i < nList.getLength(); i++)
+        {
+            Node child = nList.item(i);
+            if (child.getNodeName().compareTo(Utils.ELEMENT_FIELD) == 0)
+            {
+                String fieldName = _generator.prepareDomainName(Utils.getNamedAttribute(child,
+                                                                                        Utils.ATTRIBUTE_NAME));
+                AmqpField thisField = _fieldMap.get(fieldName);
+                AmqpFieldMap versionSpecificFieldMap = _versionToFieldsMap.get(version);
+                if (versionSpecificFieldMap == null)
+                {
+                    versionSpecificFieldMap = new AmqpFieldMap();
+                    _versionToFieldsMap.put(version, versionSpecificFieldMap);
+                }
+
+
+                if (thisField == null)
+                {
+                    thisField = new AmqpField(fieldName, _generator);
+                    _fieldMap.add(fieldName, thisField);
+                }
+
+                AmqpField versionSpecificField = new AmqpField(fieldName, _generator);
+                versionSpecificFieldMap.add(fieldName, versionSpecificField);
+
+                versionSpecificField.addFromNode(child, fieldCntr, version);
+
+                if (!thisField.addFromNode(child, fieldCntr++, version))
+                {
+                    String className = _generator.prepareClassName(Utils.getNamedAttribute(methodNode.getParentNode(),
+                                                                                           Utils.ATTRIBUTE_NAME));
+                    String methodName = _generator.prepareMethodName(Utils.getNamedAttribute(methodNode,
+                                                                                             Utils.ATTRIBUTE_NAME));
+                    System.out.println("INFO: Generation supression tag found for field " +
+                                       className + "." + methodName + "." + fieldName + " - removing.");
+                    thisField.removeVersion(version);
+                    _fieldMap.remove(fieldName);
+                }
+            }
+            else if (child.getNodeName().compareTo(Utils.ELEMENT_CHASSIS) == 0)
+            {
+                String chassisName = Utils.getNamedAttribute(child, Utils.ATTRIBUTE_NAME);
+                if (chassisName.compareTo("server") == 0)
+                {
+                    serverChassisFlag = true;
+                }
+                else if (chassisName.compareTo("client") == 0)
+                {
+                    clientChassisFlag = true;
+                }
+            }
+            else if (child.getNodeName().compareTo(Utils.ELEMENT_CODEGEN) == 0)
+            {
+                String value = Utils.getNamedAttribute(child, Utils.ATTRIBUTE_VALUE);
+                if (value.compareTo("no-gen") == 0)
+                {
+                    return false;
+                }
+            }
+        }
+        processChassisFlags(serverChassisFlag, clientChassisFlag, version);
+        return true;
+    }
+
+    public void removeVersion(AmqpVersion version)
+    {
+        _clientMethodFlagMap.removeVersion(version);
+        _serverMethodFlagMap.removeVersion(version);
+        _indexMap.removeVersion(version);
+        _fieldMap.removeVersion(version);
+        _versionSet.remove(version);
+    }
+
+    public void print(PrintStream out, int marginSize, int tabSize)
+    {
+        String margin = Utils.createSpaces(marginSize);
+        String tab = Utils.createSpaces(tabSize);
+        out.println(margin + "[M] " + _name + " {" + (_serverMethodFlagMap.isSet() ? "S " +
+                                                                                     _serverMethodFlagMap + (
+                _clientMethodFlagMap.isSet() ? ", " : "") : "") +
+                                                                (_clientMethodFlagMap.isSet()
+                                                                 ? "C " + _clientMethodFlagMap : "") + "}" + ": " +
+                                                                                                     _versionSet);
+
+        for (Integer thisIndex : _indexMap.keySet())
+        {
+            AmqpVersionSet indexVersionSet = _indexMap.get(thisIndex);
+            out.println(margin + tab + "[I] " + thisIndex + indexVersionSet);
+        }
+
+        for (String thisFieldName : _fieldMap.keySet())
+        {
+            AmqpField thisField = _fieldMap.get(thisFieldName);
+            thisField.print(out, marginSize + tabSize, tabSize);
+        }
+    }
+
+    protected void processChassisFlags(boolean serverFlag, boolean clientFlag, AmqpVersion version)
+    {
+        AmqpVersionSet versionSet = _serverMethodFlagMap.get(serverFlag);
+        if (versionSet != null)
+        {
+            versionSet.add(version);
+        }
+        else
+        {
+            versionSet = new AmqpVersionSet();
+            versionSet.add(version);
+            _serverMethodFlagMap.put(serverFlag, versionSet);
+        }
+
+        versionSet = _clientMethodFlagMap.get(clientFlag);
+        if (versionSet != null)
+        {
+            versionSet.add(version);
+        }
+        else
+        {
+            versionSet = new AmqpVersionSet();
+            versionSet.add(version);
+            _clientMethodFlagMap.put(clientFlag, versionSet);
+        }
+    }
+
+    public AmqpOverloadedParameterMap getOverloadedParameterLists(AmqpVersionSet globalVersionSet,
+                                                                  Generator generator)
+            throws AmqpTypeMappingException
+    {
+        AmqpOverloadedParameterMap parameterVersionMap = new AmqpOverloadedParameterMap();
+        for (AmqpVersion thisVersion : globalVersionSet)
+        {
+            AmqpOrdinalFieldMap ordinalFieldMap = _fieldMap.getMapForVersion(thisVersion, true, generator);
+            AmqpVersionSet methodVersionSet = parameterVersionMap.get(ordinalFieldMap);
+            if (methodVersionSet == null)
+            {
+                methodVersionSet = new AmqpVersionSet();
+                methodVersionSet.add(thisVersion);
+                parameterVersionMap.put(ordinalFieldMap, methodVersionSet);
+            }
+            else
+            {
+                methodVersionSet.add(thisVersion);
+            }
+        }
+        return parameterVersionMap;
+    }
+
+    public boolean isVersionConsistent(AmqpVersionSet globalVersionSet)
+    {
+        if (!_versionSet.equals(globalVersionSet))
+        {
+            return false;
+        }
+        if (!_clientMethodFlagMap.isVersionConsistent(globalVersionSet))
+        {
+            return false;
+        }
+        if (!_serverMethodFlagMap.isVersionConsistent(globalVersionSet))
+        {
+            return false;
+        }
+        if (!_indexMap.isVersionConsistent(globalVersionSet))
+        {
+            return false;
+        }
+        if (!_fieldMap.isVersionConsistent(globalVersionSet))
+        {
+            return false;
+        }
+        return true;
+    }
+
+    public AmqpVersionSet getVersionSet()
+    {
+        return _versionSet;
+    }
+
+    public AmqpFieldMap getFieldMap()
+    {
+        return _fieldMap;
+    }
+
+    public AmqpOrdinalVersionMap getIndexMap()
+    {
+        return _indexMap;
+    }
+
+    public AmqpFlagMap getClientMethodFlagMap()
+    {
+        return _clientMethodFlagMap;
+    }
+
+    public AmqpFlagMap getServerMethodFlagMap()
+    {
+        return _serverMethodFlagMap;
+    }
+
+    public Map<AmqpVersion, AmqpFieldMap> getVersionToFieldsMap()
+    {
+        return _versionToFieldsMap;
+    }
+
+    public String getName()
+    {
+        return _name;
+    }
+
+    public LanguageConverter getGenerator()
+    {
+        return _generator;
+    }
+
+    public SingleVersionMethod asSingleVersionMethod(AmqpVersion version)
+    {
+        return new SingleVersionMethod(this, version, _generator);
+    }
+
+    public Collection<AmqpField> getFields()
+    {
+        return _fieldMap.values();
+    }
+
+    public boolean isCommon(AmqpField field)
+    {
+        return field.getVersionSet().equals(getVersionSet()) && field.isTypeAndNameConsistent(_generator);
+    }
 }

Modified: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethodMap.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethodMap.java?view=diff&rev=526446&r1=526445&r2=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethodMap.java (original)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethodMap.java Sat Apr  7 09:01:43 2007
@@ -25,12 +25,12 @@
 @SuppressWarnings("serial")
 public class AmqpMethodMap extends TreeMap<String, AmqpMethod>
 {
-	public void removeVersion(AmqpVersion version)
-	{
-		for (String methodName : keySet())
-		{
-			get(methodName).removeVersion(version);
-		}
-	}
+    public void removeVersion(AmqpVersion version)
+    {
+        for (String methodName : keySet())
+        {
+            get(methodName).removeVersion(version);
+        }
+    }
 
 }

Modified: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpModel.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpModel.java?view=diff&rev=526446&r1=526445&r2=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpModel.java (original)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpModel.java Sat Apr  7 09:01:43 2007
@@ -20,61 +20,106 @@
  */
 package org.apache.qpid.gentools;
 
-import java.io.PrintStream;
-
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.Map;
+
 public class AmqpModel implements Printable, NodeAware
 {
-	public LanguageConverter converter;
-	public AmqpClassMap classMap;
+    private final Generator _generator;
+    private final AmqpClassMap classMap = new AmqpClassMap();
+    private final AmqpVersionSet _versionSet = new AmqpVersionSet();
+
+    private final Map<AmqpVersion, AmqpClassMap> _versionToClassMapMap = new HashMap<AmqpVersion, AmqpClassMap>();
+
+    public AmqpModel(Generator generator)
+    {
+        _generator = generator;
+    }
+
+    public AmqpClassMap getAmqpClassMap(AmqpVersion version)
+    {
+        return _versionToClassMapMap.get(version);
+    }
+
+
+    public AmqpVersionSet getVersionSet()
+    {
+        return _versionSet;
+    }
+
+    public boolean addFromNode(Node n, int o, AmqpVersion version)
+            throws AmqpParseException, AmqpTypeMappingException
+    {
+        _versionSet.add(version);
+        NodeList nList = n.getChildNodes();
+
+        AmqpClassMap versionSpecificClassMap = _versionToClassMapMap.get(version);
+
+        if (versionSpecificClassMap == null)
+        {
+            versionSpecificClassMap = new AmqpClassMap();
+            _versionToClassMapMap.put(version, versionSpecificClassMap);
+        }
+
+        int eCntr = 0;
+        for (int i = 0; i < nList.getLength(); i++)
+        {
+            Node c = nList.item(i);
+            if (c.getNodeName().compareTo(Utils.ELEMENT_CLASS) == 0)
+            {
+                String className = _generator.prepareClassName(Utils.getNamedAttribute(c, Utils.ATTRIBUTE_NAME));
+                AmqpClass thisClass = classMap.get(className);
+                if (thisClass == null)
+                {
+                    thisClass = new AmqpClass(className, _generator);
+                    classMap.put(className, thisClass);
+                }
+
+                AmqpClass versionSpecificClass = new AmqpClass(className, _generator);
+                versionSpecificClassMap.put(className, versionSpecificClass);
+
+                versionSpecificClass.addFromNode(c, eCntr, version);
+
+                if (!thisClass.addFromNode(c, eCntr++, version))
+                {
+                    System.out.println("INFO: Generation supression tag found for class " + className + " - removing.");
+                    thisClass.removeVersion(version);
+                    classMap.remove(className);
+                }
+            }
+        }
+        return true;
+    }
+
+    public void print(PrintStream out, int marginSize, int tabSize)
+    {
+        out.println(Utils.createSpaces(marginSize) +
+                    "[C]=class; [M]=method; [F]=field; [D]=domain; [I]=index; [O]=ordinal" + Utils.LINE_SEPARATOR);
+        out.println(Utils.createSpaces(marginSize) + "Model:");
+
+        for (String thisClassName : classMap.keySet())
+        {
+            AmqpClass thisClass = classMap.get(thisClassName);
+            thisClass.print(out, marginSize + tabSize, tabSize);
+        }
+    }
+
+    public LanguageConverter getGenerator()
+    {
+        return _generator;
+    }
+
+    public AmqpClassMap getClassMap()
+    {
+        return classMap;
+    }
 
-	public AmqpModel(LanguageConverter converter)
-	{
-		this.converter = converter;
-		this.converter.setModel(this);
-		classMap = new AmqpClassMap();
-	}
-
-	public boolean addFromNode(Node n, int o, AmqpVersion v)
-		throws AmqpParseException, AmqpTypeMappingException
-	{
-		NodeList nList = n.getChildNodes();
-		int eCntr = 0;
-		for (int i=0; i<nList.getLength(); i++)
-		{
-			Node c = nList.item(i);
-			if (c.getNodeName().compareTo(Utils.ELEMENT_CLASS) == 0)
-			{
-				String className = converter.prepareClassName(Utils.getNamedAttribute(c, Utils.ATTRIBUTE_NAME));
-				AmqpClass thisClass = classMap.get(className);
-				if (thisClass == null)
-				{
-					thisClass = new AmqpClass(className, converter);
-					classMap.put(className, thisClass);
-				}
-				if (!thisClass.addFromNode(c, eCntr++, v))
-				{
-					System.out.println("INFO: Generation supression tag found for class " + className + " - removing.");
-					thisClass.removeVersion(v);
-					classMap.remove(className);
-				}
-			}
-		}
-		return true;
-	}
-	
-	public void print(PrintStream out, int marginSize, int tabSize)
-	{
-		out.println(Utils.createSpaces(marginSize) +
-			"[C]=class; [M]=method; [F]=field; [D]=domain; [I]=index; [O]=ordinal" + Utils.lineSeparator);
-		out.println(Utils.createSpaces(marginSize) + "Model:");
-
-		for (String thisClassName : classMap.keySet())
-		{
-			AmqpClass thisClass = classMap.get(thisClassName);
-			thisClass.print(out, marginSize + tabSize, tabSize);
-		}
-	}
+    public SingleVersionModel asSingleVersionModel()
+    {
+        return new SingleVersionModel(this, getVersionSet().first(), _generator);
+    }
 }

Modified: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java?view=diff&rev=526446&r1=526445&r2=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java (original)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java Sat Apr  7 09:01:43 2007
@@ -27,63 +27,70 @@
 @SuppressWarnings("serial")
 public class AmqpOrdinalFieldMap extends TreeMap<Integer, String[]> implements Comparable
 {
-	protected static final int FIELD_DOMAIN = 1;
-	protected boolean codeTypeFlag = false;
-	
-	public int compareTo(Object obj)
-	{
-		AmqpOrdinalFieldMap o = (AmqpOrdinalFieldMap)obj;
-		Set<Integer> thisKeySet = keySet();
-		Set<Integer> oKeySet = o.keySet();
-		if (!thisKeySet.equals(oKeySet)) // Not equal, but why?
-		{
-			// Size difference
-			int sizeDiff = thisKeySet.size() - oKeySet.size(); // -ve if this < other
-			if (sizeDiff != 0)
-				return sizeDiff;
-			// Conetent difference
-			Iterator<Integer> itr = thisKeySet.iterator();
-			Iterator<Integer> oItr = oKeySet.iterator();
-			while (itr.hasNext() && oItr.hasNext())
-			{
-				int diff = itr.next() - oItr.next(); // -ve if this < other
-				if (diff != 0)
-					return diff;
-			}
-			// We should never get here...
-			System.err.println("AmqpOrdinalFieldMap.compareTo(): " +
-				"WARNING - unable to find cause of keySet difference.");
-		}
-		// Keys are equal, now check the String[]s
-		Iterator<Integer> itr = thisKeySet.iterator();
-		Iterator<Integer> oItr = oKeySet.iterator();
-		while (itr.hasNext() && oItr.hasNext())
-		{
-			String[] thisPair = get(itr.next());
-			String[] oPair = o.get(oItr.next());
-			// Size difference
-			int sizeDiff = thisPair.length - oPair.length; // -ve if this < other
-			if (sizeDiff != 0)
-				return sizeDiff;
-			// Conetent difference
-			for (int i=0; i<thisPair.length; i++)
-			{
-				int diff = thisPair[i].compareTo(oPair[i]);
-				if (diff != 0)
-					return diff;
-			}
-		}
-		return 0;
-	}
-	
-	public String toString()
-	{
-		StringBuffer sb = new StringBuffer();
-		for (Integer thisOrdinal : keySet())
-		{
-			String[] pair = get(thisOrdinal);
-			sb.append("[" + thisOrdinal + "] " + pair[0] + " : " + pair[1] + Utils.lineSeparator);
-		}
-		return sb.toString();
-	}
+
+
+    public int compareTo(Object obj)
+    {
+        AmqpOrdinalFieldMap o = (AmqpOrdinalFieldMap) obj;
+        Set<Integer> thisKeySet = keySet();
+        Set<Integer> oKeySet = o.keySet();
+        if (!thisKeySet.equals(oKeySet)) // Not equal, but why?
+        {
+            // Size difference
+            int sizeDiff = thisKeySet.size() - oKeySet.size(); // -ve if this < other
+            if (sizeDiff != 0)
+            {
+                return sizeDiff;
+            }
+            // Conetent difference
+            Iterator<Integer> itr = thisKeySet.iterator();
+            Iterator<Integer> oItr = oKeySet.iterator();
+            while (itr.hasNext() && oItr.hasNext())
+            {
+                int diff = itr.next() - oItr.next(); // -ve if this < other
+                if (diff != 0)
+                {
+                    return diff;
+                }
+            }
+            // We should never get here...
+            System.err.println("AmqpOrdinalFieldMap.compareTo(): " +
+                               "WARNING - unable to find cause of keySet difference.");
+        }
+        // Keys are equal, now check the String[]s
+        Iterator<Integer> itr = thisKeySet.iterator();
+        Iterator<Integer> oItr = oKeySet.iterator();
+        while (itr.hasNext() && oItr.hasNext())
+        {
+            String[] thisPair = get(itr.next());
+            String[] oPair = o.get(oItr.next());
+            // Size difference
+            int sizeDiff = thisPair.length - oPair.length; // -ve if this < other
+            if (sizeDiff != 0)
+            {
+                return sizeDiff;
+            }
+            // Conetent difference
+            for (int i = 0; i < thisPair.length; i++)
+            {
+                int diff = thisPair[i].compareTo(oPair[i]);
+                if (diff != 0)
+                {
+                    return diff;
+                }
+            }
+        }
+        return 0;
+    }
+
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+        for (Integer thisOrdinal : keySet())
+        {
+            String[] pair = get(thisOrdinal);
+            sb.append("[" + thisOrdinal + "] " + pair[0] + " : " + pair[1] + Utils.LINE_SEPARATOR);
+        }
+        return sb.toString();
+    }
 }

Modified: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalVersionMap.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalVersionMap.java?view=diff&rev=526446&r1=526445&r2=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalVersionMap.java (original)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalVersionMap.java Sat Apr  7 09:01:43 2007
@@ -26,47 +26,51 @@
 @SuppressWarnings("serial")
 public class AmqpOrdinalVersionMap extends TreeMap<Integer, AmqpVersionSet> implements VersionConsistencyCheck
 {
-	public boolean isVersionConsistent(AmqpVersionSet globalVersionSet)
-	{
-		if (size() != 1)
-			return false;
-		return get(firstKey()).equals(globalVersionSet);
-	}
-    
+    public boolean isVersionConsistent(AmqpVersionSet globalVersionSet)
+    {
+        if (size() != 1)
+        {
+            return false;
+        }
+        return get(firstKey()).equals(globalVersionSet);
+    }
+
     public int getOrdinal(AmqpVersion version)
-    throws AmqpTypeMappingException
+            throws AmqpTypeMappingException
     {
-    	for (Integer thisOrdinal : keySet())
+        for (Integer thisOrdinal : keySet())
         {
             AmqpVersionSet versionSet = get(thisOrdinal);
             if (versionSet.contains(version))
+            {
                 return thisOrdinal;
+            }
         }
         throw new AmqpTypeMappingException("Unable to locate version " + version + " in ordianl version map.");
     }
-	
-	public boolean removeVersion(AmqpVersion version)
-	{
-		Boolean res = false;
-		ArrayList<Integer> removeList = new ArrayList<Integer>();
-		for (Integer ordinal : keySet())
-		{
-			AmqpVersionSet versionSet = get(ordinal);
-			if (versionSet.contains(version))
-			{
-				versionSet.remove(version);
-				if (versionSet.isEmpty())
-				{
-					removeList.add(ordinal);
-				}
-				res = true;
-			}
-		}
-		// Get rid of ordinals no longer in use
-		for (Integer ordinal : removeList)
-		{
-			remove(ordinal);
-		}
-		return res;
-	}
+
+    public boolean removeVersion(AmqpVersion version)
+    {
+        Boolean res = false;
+        ArrayList<Integer> removeList = new ArrayList<Integer>();
+        for (Integer ordinal : keySet())
+        {
+            AmqpVersionSet versionSet = get(ordinal);
+            if (versionSet.contains(version))
+            {
+                versionSet.remove(version);
+                if (versionSet.isEmpty())
+                {
+                    removeList.add(ordinal);
+                }
+                res = true;
+            }
+        }
+        // Get rid of ordinals no longer in use
+        for (Integer ordinal : removeList)
+        {
+            remove(ordinal);
+        }
+        return res;
+    }
 }

Modified: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpParseException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpParseException.java?view=diff&rev=526446&r1=526445&r2=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpParseException.java (original)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpParseException.java Sat Apr  7 09:01:43 2007
@@ -21,10 +21,10 @@
 package org.apache.qpid.gentools;
 
 @SuppressWarnings("serial")
-public class AmqpParseException extends Exception
+public class AmqpParseException extends RuntimeException
 {
-	public AmqpParseException(String msg)
-	{
-		super(msg);
-	}
+    public AmqpParseException(String msg)
+    {
+        super(msg);
+    }
 }

Modified: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpTemplateException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpTemplateException.java?view=diff&rev=526446&r1=526445&r2=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpTemplateException.java (original)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpTemplateException.java Sat Apr  7 09:01:43 2007
@@ -21,10 +21,10 @@
 package org.apache.qpid.gentools;
 
 @SuppressWarnings("serial")
-public class AmqpTemplateException extends Exception
+public class AmqpTemplateException extends RuntimeException
 {
-	public AmqpTemplateException(String msg)
-	{
-		super(msg);
-	}
+    public AmqpTemplateException(String msg)
+    {
+        super(msg);
+    }
 }

Modified: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpTypeMappingException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpTypeMappingException.java?view=diff&rev=526446&r1=526445&r2=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpTypeMappingException.java (original)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpTypeMappingException.java Sat Apr  7 09:01:43 2007
@@ -21,10 +21,10 @@
 package org.apache.qpid.gentools;
 
 @SuppressWarnings("serial")
-public class AmqpTypeMappingException extends Exception
+public class AmqpTypeMappingException extends RuntimeException
 {
-	public AmqpTypeMappingException(String msg)
-	{
-		super(msg);
-	}
+    public AmqpTypeMappingException(String msg)
+    {
+        super(msg);
+    }
 }

Modified: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersion.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersion.java?view=diff&rev=526446&r1=526445&r2=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersion.java (original)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersion.java Sat Apr  7 09:01:43 2007
@@ -22,47 +22,51 @@
 
 public class AmqpVersion implements Comparable<AmqpVersion>
 {
-	private int major;
-	private int minor;
-	
-	public AmqpVersion(int major, int minor)
-	{
-		this.major = major;
-		this.minor = minor;
-	}
-
-	public AmqpVersion(AmqpVersion version)
-	{
-		this.major = version.major;
-		this.minor = version.minor;
-	}
-	
-	public int getMajor()
-	{
-		return major;
-	}
-	
-	public int getMinor()
-	{
-		return minor;
-	}
-	
-	public int compareTo(AmqpVersion v)
-	{
-		if (major != v.major)
-			return major - v.major;
-		if (minor != v.minor)
-			return minor - v.minor;
-		return 0;
-	}
-	
-	public String namespace()
-	{
-		return "ver_" + major + "_" + minor;
-	}
-	
-	public String toString()
-	{
-		return major + "-" + minor;
-	}
+    private final int _major;
+    private final int _minor;
+
+    public AmqpVersion(int major, int minor)
+    {
+        _major = major;
+        _minor = minor;
+    }
+
+    public AmqpVersion(AmqpVersion version)
+    {
+        _major = version.getMajor();
+        _minor = version.getMinor();
+    }
+
+    public int getMajor()
+    {
+        return _major;
+    }
+
+    public int getMinor()
+    {
+        return _minor;
+    }
+
+    public int compareTo(AmqpVersion v)
+    {
+        if (_major != v.getMajor())
+        {
+            return _major - v.getMajor();
+        }
+        if (_minor != v.getMinor())
+        {
+            return _minor - v.getMinor();
+        }
+        return 0;
+    }
+
+    public String namespace()
+    {
+        return "ver_" + _major + "_" + _minor;
+    }
+
+    public String toString()
+    {
+        return _major + "-" + _minor;
+    }
 }

Modified: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersionSet.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersionSet.java?view=diff&rev=526446&r1=526445&r2=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersionSet.java (original)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersionSet.java Sat Apr  7 09:01:43 2007
@@ -21,7 +21,6 @@
 package org.apache.qpid.gentools;
 
 import java.io.PrintStream;
-//import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.TreeSet;
 
@@ -30,35 +29,39 @@
 {
     public AmqpVersionSet()
     {
-    	super();
+        super();
     }
-    
+
     public AmqpVersionSet(AmqpVersion version)
     {
-    	super();
+        super();
         add(version);
     }
-    
+
     public AmqpVersion find(AmqpVersion version)
     {
-    	for (AmqpVersion v : this)
-    	{
-    		if (v.compareTo(version) == 0)
-    			return v;
-    	}
-    	return null;
+        for (AmqpVersion v : this)
+        {
+            if (v.compareTo(version) == 0)
+            {
+                return v;
+            }
+        }
+        return null;
+    }
+
+    public void print(PrintStream out, int marginSize, int tabSize)
+    {
+        out.print(Utils.createSpaces(marginSize) + "Version Set: " + toString() + Utils.LINE_SEPARATOR);
     }
-    
-	public void print(PrintStream out, int marginSize, int tabSize)
-	{
-		out.print(Utils.createSpaces(marginSize) + "Version Set: " + toString() + Utils.lineSeparator);
-	}
-    
+
     public int compareTo(AmqpVersionSet other)
     {
         int res = size() - other.size();
         if (res != 0)
+        {
             return res;
+        }
         Iterator<AmqpVersion> vItr = iterator();
         Iterator<AmqpVersion> oItr = other.iterator();
         while (vItr.hasNext() && oItr.hasNext())
@@ -67,7 +70,9 @@
             AmqpVersion oVersion = oItr.next();
             res = version.compareTo(oVersion);
             if (res != 0)
+            {
                 return res;
+            }
         }
         return 0;
     }

Added: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/BitFieldGenerateMethod.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/BitFieldGenerateMethod.java?view=auto&rev=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/BitFieldGenerateMethod.java (added)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/BitFieldGenerateMethod.java Sat Apr  7 09:01:43 2007
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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 org.apache.qpid.gentools;
+
+
+import java.util.List;
+
+public interface BitFieldGenerateMethod
+{
+    String generate(List<String> bitFieldList, int ordinal, int indentSize, int tabSize);
+}

Added: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/CommandGenerateMethod.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/CommandGenerateMethod.java?view=auto&rev=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/CommandGenerateMethod.java (added)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/CommandGenerateMethod.java Sat Apr  7 09:01:43 2007
@@ -0,0 +1,26 @@
+/*
+ *
+ * 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 org.apache.qpid.gentools;
+
+public interface CommandGenerateMethod
+{
+    String generate(String codeType, AmqpField field, AmqpVersionSet versionSet, int indentSize, int tabSize, boolean notLast);
+}

Added: incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/ConsolidatedField.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/ConsolidatedField.java?view=auto&rev=526446
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/ConsolidatedField.java (added)
+++ incubator/qpid/trunk/qpid/gentools/src/org/apache/qpid/gentools/ConsolidatedField.java Sat Apr  7 09:01:43 2007
@@ -0,0 +1,100 @@
+package org.apache.qpid.gentools;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: U146758
+ * Date: 06-Mar-2007
+ * Time: 09:22:21
+ * To change this template use File | Settings | File Templates.
+ */
+public class ConsolidatedField
+{
+    private final String _name;
+    private final String _type;
+    private final List<String> _underlyingFields = new ArrayList<String>();
+    private final Generator _generator;
+    private boolean _isConsolidated;
+
+    public ConsolidatedField(Generator generator, String name, String type)
+    {
+        this(generator,name,type,name,false);
+    }
+
+    public ConsolidatedField(Generator generator, String name, String type, String firstField)
+    {
+           this(generator,name,type,firstField,true);
+    }
+
+    public ConsolidatedField(Generator generator, String name, String type, String firstField, boolean consolidated)
+    {
+
+        _generator = generator;
+        _name = name;
+        _type = type;
+        _isConsolidated = consolidated;
+        _underlyingFields.add(firstField);
+
+    }
+
+
+    public void setConsolidated(boolean consolidated)
+    {
+        _isConsolidated = consolidated;
+    }
+
+    public String getName()
+    {
+        return _name;
+    }
+
+    public String getType()
+    {
+        return _type;
+    }
+
+    public String getNativeType()
+    {
+        return _generator.getNativeType(_type);
+    }
+
+    public String getEncodingType()
+    {
+        return _generator.getEncodingType(_type);
+    }
+
+    public void add(String name)
+    {
+        _underlyingFields.add(name);
+    }
+
+    public Collection<String> getUnderlyingFields()
+    {
+        return Collections.unmodifiableCollection(_underlyingFields);
+    }
+
+    public int getPosition(String fieldName)
+    {
+        return _underlyingFields.indexOf(fieldName);
+    }
+
+    public boolean isConsolidated()
+    {
+        return _isConsolidated;
+    }
+
+    public boolean isFixedSize()
+    {
+        return _generator.isFixedSizeType( getType() );
+    }
+
+    public int getSize()
+    {
+        return _generator.getTypeSize( getType() );
+    }
+
+}



Mime
View raw message