felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mccu...@apache.org
Subject svn commit: r1350613 [14/14] - in /felix/trunk/bundleplugin/src/main/java/aQute: bnd/annotation/ bnd/annotation/component/ bnd/annotation/metatype/ bnd/build/ bnd/compatibility/ bnd/component/ bnd/differ/ bnd/help/ bnd/make/ bnd/make/calltree/ bnd/make...
Date Fri, 15 Jun 2012 13:28:02 GMT
Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/gzip/GZipUtils.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/gzip/GZipUtils.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/gzip/GZipUtils.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/gzip/GZipUtils.java Fri Jun 15 13:27:53 2012
@@ -1,13 +1,10 @@
 package aQute.libg.gzip;
 
-import java.io.BufferedInputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.GZIPInputStream;
+import java.io.*;
+import java.util.zip.*;
 
 public class GZipUtils {
-	
+
 	/**
 	 * Determines whether the specified stream contains gzipped data, by
 	 * checking for the GZIP magic number, and returns a stream capable of
@@ -21,11 +18,11 @@ public class GZipUtils {
 			buffered = stream;
 		else
 			buffered = new BufferedInputStream(stream);
-		
+
 		buffered.mark(2);
 		int magic = readUShort(buffered);
 		buffered.reset();
-		
+
 		InputStream result;
 		if (magic == GZIPInputStream.GZIP_MAGIC)
 			result = new GZIPInputStream(buffered);
@@ -34,27 +31,27 @@ public class GZipUtils {
 		return result;
 	}
 
-    /*
-     * Reads unsigned short in Intel byte order.
-     */
+	/*
+	 * Reads unsigned short in Intel byte order.
+	 */
 	private static int readUShort(InputStream in) throws IOException {
 		int b = readUByte(in);
 		return (readUByte(in) << 8) | b;
 	}
-    
-    /*
-     * Reads unsigned byte.
-     */
-    private static int readUByte(InputStream in) throws IOException {
-	int b = in.read();
-	if (b == -1) {
-	    throw new EOFException();
+
+	/*
+	 * Reads unsigned byte.
+	 */
+	private static int readUByte(InputStream in) throws IOException {
+		int b = in.read();
+		if (b == -1) {
+			throw new EOFException();
+		}
+		if (b < -1 || b > 255) {
+			// Report on this.in, not argument in; see read{Header, Trailer}.
+			throw new IOException(in.getClass().getName() + ".read() returned value out of range -1..255: " + b);
+		}
+		return b;
 	}
-        if (b < -1 || b > 255) {
-            // Report on this.in, not argument in; see read{Header, Trailer}.
-            throw new IOException(in.getClass().getName() + ".read() returned value out of range -1..255: " + b);
-        }
-	return b;
-    }
 
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/header/Attrs.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/header/Attrs.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/header/Attrs.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/header/Attrs.java Fri Jun 15 13:27:53 2012
@@ -6,9 +6,10 @@ import java.util.regex.*;
 import aQute.lib.collections.*;
 import aQute.libg.version.*;
 
-public class Attrs implements Map<String, String> {
+public class Attrs implements Map<String,String> {
 	public enum Type {
-		STRING(null), LONG(null), VERSION(null), DOUBLE(null), STRINGS(STRING), LONGS(LONG), VERSIONS(VERSION), DOUBLES(DOUBLE);
+		STRING(null), LONG(null), VERSION(null), DOUBLE(null), STRINGS(STRING), LONGS(LONG), VERSIONS(VERSION), DOUBLES(
+				DOUBLE);
 
 		Type	sub;
 
@@ -33,14 +34,15 @@ public class Attrs implements Map<String
 	 * ’List<’ scalar ’>’
 	 * </pre>
 	 */
-	static String					EXTENDED	= "[\\-0-9a-zA-Z\\._]+";
-	static String					SCALAR		= "String|Version|Long|Double";
-	static String					LIST		= "List\\s*<\\s*(" + SCALAR + ")\\s*>";
-	public static final Pattern		TYPED		= Pattern.compile("\\s*(" + EXTENDED + ")\\s*:\\s*("+ SCALAR + "|" + LIST + ")\\s*");
-
-	private LinkedHashMap<String, String>	map;
-	private Map<String, Type>		types;
-	static Map<String, String>		EMPTY		= Collections.emptyMap();
+	static String							EXTENDED	= "[\\-0-9a-zA-Z\\._]+";
+	static String							SCALAR		= "String|Version|Long|Double";
+	static String							LIST		= "List\\s*<\\s*(" + SCALAR + ")\\s*>";
+	public static final Pattern				TYPED		= Pattern.compile("\\s*(" + EXTENDED + ")\\s*:\\s*(" + SCALAR
+																+ "|" + LIST + ")\\s*");
+
+	private LinkedHashMap<String,String>	map;
+	private Map<String,Type>				types;
+	static Map<String,String>				EMPTY		= Collections.emptyMap();
 
 	public Attrs(Attrs... attrs) {
 		for (Attrs a : attrs) {
@@ -62,7 +64,8 @@ public class Attrs implements Map<String
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public boolean containsKey(Object name) {
+	@Deprecated
+	public boolean containsKey(Object name) {
 		assert name instanceof String;
 		if (map == null)
 			return false;
@@ -78,7 +81,8 @@ public class Attrs implements Map<String
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public boolean containsValue(Object value) {
+	@Deprecated
+	public boolean containsValue(Object value) {
 		assert value instanceof String;
 		if (map == null)
 			return false;
@@ -86,7 +90,7 @@ public class Attrs implements Map<String
 		return map.containsValue((String) value);
 	}
 
-	public Set<java.util.Map.Entry<String, String>> entrySet() {
+	public Set<java.util.Map.Entry<String,String>> entrySet() {
 		if (map == null)
 			return EMPTY.entrySet();
 
@@ -94,7 +98,8 @@ public class Attrs implements Map<String
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public String get(Object key) {
+	@Deprecated
+	public String get(Object key) {
 		assert key instanceof String;
 		if (map == null)
 			return null;
@@ -129,7 +134,7 @@ public class Attrs implements Map<String
 
 	public String put(String key, String value) {
 		if (map == null)
-			map = new LinkedHashMap<String, String>();
+			map = new LinkedHashMap<String,String>();
 
 		Matcher m = TYPED.matcher(key);
 		if (m.matches()) {
@@ -137,28 +142,28 @@ public class Attrs implements Map<String
 			String type = m.group(2);
 			Type t = Type.STRING;
 
-			if ( type.startsWith("List")) {
+			if (type.startsWith("List")) {
 				type = m.group(3);
-				if ( "String".equals(type))
+				if ("String".equals(type))
 					t = Type.STRINGS;
-				else if ( "Long".equals(type))
+				else if ("Long".equals(type))
 					t = Type.LONGS;
-				else if ( "Double".equals(type))
+				else if ("Double".equals(type))
 					t = Type.DOUBLES;
-				else if ( "Version".equals(type))
-					t = Type.VERSIONS;				
+				else if ("Version".equals(type))
+					t = Type.VERSIONS;
 			} else {
-				if ( "String".equals(type))
+				if ("String".equals(type))
 					t = Type.STRING;
-				else if ( "Long".equals(type))
+				else if ("Long".equals(type))
 					t = Type.LONG;
-				else if ( "Double".equals(type))
+				else if ("Double".equals(type))
 					t = Type.DOUBLE;
-				else if ( "Version".equals(type))
+				else if ("Version".equals(type))
 					t = Type.VERSION;
 			}
 			if (types == null)
-				types = new LinkedHashMap<String, Type>();
+				types = new LinkedHashMap<String,Type>();
 			types.put(key, t);
 
 			// TODO verify value?
@@ -176,13 +181,14 @@ public class Attrs implements Map<String
 		return t;
 	}
 
-	public void putAll(Map<? extends String, ? extends String> map) {
-		for (Map.Entry<? extends String, ? extends String> e : map.entrySet())
+	public void putAll(Map< ? extends String, ? extends String> map) {
+		for (Map.Entry< ? extends String, ? extends String> e : map.entrySet())
 			put(e.getKey(), e.getValue());
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public String remove(Object var0) {
+	@Deprecated
+	public String remove(Object var0) {
 		assert var0 instanceof String;
 		if (map == null)
 			return null;
@@ -221,7 +227,7 @@ public class Attrs implements Map<String
 
 	public void append(StringBuilder sb) {
 		String del = "";
-		for (Map.Entry<String, String> e : entrySet()) {
+		for (Map.Entry<String,String> e : entrySet()) {
 			sb.append(del);
 			sb.append(e.getKey());
 			sb.append("=");
@@ -230,11 +236,13 @@ public class Attrs implements Map<String
 		}
 	}
 
-	@Deprecated public boolean equals(Object other) {
+	@Deprecated
+	public boolean equals(Object other) {
 		return super.equals(other);
 	}
 
-	@Deprecated public int hashCode() {
+	@Deprecated
+	public int hashCode() {
 		return super.hashCode();
 	}
 
@@ -275,12 +283,12 @@ public class Attrs implements Map<String
 	private Object convert(Type t, String s) {
 		if (t.sub == null) {
 			switch (t) {
-			case STRING:
-				return s;
-			case LONG:
-				return Long.parseLong(s.trim());
-			case VERSION:
-				return Version.parseVersion(s);
+				case STRING :
+					return s;
+				case LONG :
+					return Long.parseLong(s.trim());
+				case VERSION :
+					return Version.parseVersion(s);
 			}
 			return null;
 		}

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/header/OSGiHeader.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/header/OSGiHeader.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/header/OSGiHeader.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/header/OSGiHeader.java Fri Jun 15 13:27:53 2012
@@ -15,9 +15,8 @@ public class OSGiHeader {
 	/**
 	 * Standard OSGi header parser. This parser can handle the format clauses
 	 * ::= clause ( ',' clause ) + clause ::= name ( ';' name ) (';' key '='
-	 * value )
-	 * 
-	 * This is mapped to a Map { name => Map { attr|directive => value } }
+	 * value ) This is mapped to a Map { name => Map { attr|directive => value }
+	 * }
 	 * 
 	 * @param value
 	 *            A string
@@ -56,10 +55,8 @@ public class OSGiHeader {
 					if ((del = qt.getSeparator()) != '=') {
 						if (hadAttribute)
 							if (logger != null) {
-								logger.error("Header contains name field after attribute or directive: "
-										+ adname
-										+ " from "
-										+ value
+								logger.error("Header contains name field after attribute or directive: " + adname
+										+ " from " + value
 										+ ". Name fields must be consecutive, separated by a ';' like a;b;c;x=3;y=4");
 							}
 						if (adname != null && adname.length() > 0)
@@ -68,8 +65,7 @@ public class OSGiHeader {
 						String advalue = qt.nextToken();
 						if (clause.containsKey(adname)) {
 							if (logger != null && logger.isPedantic())
-								logger.warning("Duplicate attribute/directive name " + adname
-										+ " in " + value
+								logger.warning("Duplicate attribute/directive name " + adname + " in " + value
 										+ ". This attribute/directive will be ignored");
 						}
 						if (advalue == null) {

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/header/Parameters.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/header/Parameters.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/header/Parameters.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/header/Parameters.java Fri Jun 15 13:27:53 2012
@@ -5,13 +5,12 @@ import java.util.*;
 import aQute.lib.collections.*;
 import aQute.libg.reporter.*;
 
-public class Parameters implements Map<String, Attrs> {
-	private LinkedHashMap<String, Attrs>	map;
-	static Map<String, Attrs>				EMPTY	= Collections.emptyMap();
-	String									error;
+public class Parameters implements Map<String,Attrs> {
+	private LinkedHashMap<String,Attrs>	map;
+	static Map<String,Attrs>			EMPTY	= Collections.emptyMap();
+	String								error;
 
-	public Parameters() {
-	}
+	public Parameters() {}
 
 	public Parameters(String header) {
 		OSGiHeader.parseHeader(header, null, this);
@@ -33,7 +32,8 @@ public class Parameters implements Map<S
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public boolean containsKey(Object name) {
+	@Deprecated
+	public boolean containsKey(Object name) {
 		assert name instanceof String;
 		if (map == null)
 			return false;
@@ -49,7 +49,8 @@ public class Parameters implements Map<S
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public boolean containsValue(Object value) {
+	@Deprecated
+	public boolean containsValue(Object value) {
 		assert value instanceof Attrs;
 		if (map == null)
 			return false;
@@ -57,7 +58,7 @@ public class Parameters implements Map<S
 		return map.containsValue((Attrs) value);
 	}
 
-	public Set<java.util.Map.Entry<String, Attrs>> entrySet() {
+	public Set<java.util.Map.Entry<String,Attrs>> entrySet() {
 		if (map == null)
 			return EMPTY.entrySet();
 
@@ -65,7 +66,8 @@ public class Parameters implements Map<S
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public Attrs get(Object key) {
+	@Deprecated
+	public Attrs get(Object key) {
 		assert key instanceof String;
 		if (map == null)
 			return null;
@@ -96,28 +98,30 @@ public class Parameters implements Map<S
 		assert value != null;
 
 		if (map == null)
-			map = new LinkedHashMap<String, Attrs>();
+			map = new LinkedHashMap<String,Attrs>();
 
 		return map.put(key, value);
 	}
 
-	public void putAll(Map<? extends String, ? extends Attrs> map) {
+	public void putAll(Map< ? extends String, ? extends Attrs> map) {
 		if (this.map == null) {
 			if (map.isEmpty())
 				return;
-			this.map = new LinkedHashMap<String, Attrs>();
+			this.map = new LinkedHashMap<String,Attrs>();
 		}
 		this.map.putAll(map);
 	}
+
 	public void putAllIfAbsent(Map<String, ? extends Attrs> map) {
-		for(Map.Entry<String, ? extends Attrs> entry : map.entrySet() ) {
-			if ( !containsKey(entry.getKey()))
+		for (Map.Entry<String, ? extends Attrs> entry : map.entrySet()) {
+			if (!containsKey(entry.getKey()))
 				put(entry.getKey(), entry.getValue());
 		}
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public Attrs remove(Object var0) {
+	@Deprecated
+	public Attrs remove(Object var0) {
 		assert var0 instanceof String;
 		if (map == null)
 			return null;
@@ -152,7 +156,7 @@ public class Parameters implements Map<S
 
 	public void append(StringBuilder sb) {
 		String del = "";
-		for (Map.Entry<String, Attrs> s : entrySet()) {
+		for (Map.Entry<String,Attrs> s : entrySet()) {
 			sb.append(del);
 			sb.append(s.getKey());
 			if (!s.getValue().isEmpty()) {
@@ -168,12 +172,11 @@ public class Parameters implements Map<S
 	public boolean equals(Object other) {
 		return super.equals(other);
 	}
-	
+
 	@Deprecated
 	public int hashCode() {
 		return super.hashCode();
 	}
-	
 
 	public boolean isEqual(Parameters other) {
 		if (this == other)
@@ -197,7 +200,7 @@ public class Parameters implements Map<S
 		return true;
 	}
 
-	public Map<String,? extends Map<String,String>> asMapMap() {
+	public Map<String, ? extends Map<String,String>> asMapMap() {
 		return this;
 	}
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/log/Logger.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/log/Logger.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/log/Logger.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/log/Logger.java Fri Jun 15 13:27:53 2012
@@ -2,15 +2,18 @@ package aQute.libg.log;
 
 import java.util.*;
 
-
 public interface Logger {
-	void error(String s, Object ... args);
-	void warning(String s, Object ... args);
-	void progress(String s, Object ... args);
-	
+	void error(String s, Object... args);
+
+	void warning(String s, Object... args);
+
+	void progress(String s, Object... args);
+
 	List<String> getWarnings();
+
 	List<String> getErrors();
+
 	List<String> getProgress();
-	
+
 	boolean isPedantic();
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/map/MAP.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/map/MAP.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/map/MAP.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/map/MAP.java Fri Jun 15 13:27:53 2012
@@ -3,42 +3,40 @@ package aQute.libg.map;
 import java.util.*;
 
 /**
- * Easy way to build a map:
- * 
- * 	Map<String,Integer> s = MAP.$("a",2).$("b",3);
- *
+ * Easy way to build a map: Map<String,Integer> s = MAP.$("a",2).$("b",3);
  */
 public class MAP {
 
-	static public class MAPX<K, V> extends LinkedHashMap<K, V> {
+	static public class MAPX<K, V> extends LinkedHashMap<K,V> {
 		private static final long	serialVersionUID	= 1L;
-		public MAPX<K, V> $(K key, V value) {
+
+		public MAPX<K,V> $(K key, V value) {
 			put(key, value);
 			return this;
 		}
 
-		public MAPX<K, V> $(Map<K,V> all) {
+		public MAPX<K,V> $(Map<K,V> all) {
 			putAll(all);
 			return this;
 		}
+
 		public Hashtable<K,V> asHashtable() {
 			return new Hashtable<K,V>(this);
 		}
 	}
 
-	public static <Kx, Vx> MAPX<Kx, Vx> $(Kx key, Vx value) {
-		MAPX<Kx, Vx> map = new MAPX<Kx, Vx>();
+	public static <Kx, Vx> MAPX<Kx,Vx> $(Kx key, Vx value) {
+		MAPX<Kx,Vx> map = new MAPX<Kx,Vx>();
 		map.put(key, value);
 		return map;
 	}
-	
-	
-	public <K,V> Map<K,V> dictionary(Dictionary<K,V> dict ) {
-		Map<K,V> map = new LinkedHashMap<K, V>();
-		for ( Enumeration<K> e = dict.keys(); e.hasMoreElements(); ) {
+
+	public <K, V> Map<K,V> dictionary(Dictionary<K,V> dict) {
+		Map<K,V> map = new LinkedHashMap<K,V>();
+		for (Enumeration<K> e = dict.keys(); e.hasMoreElements();) {
 			K k = e.nextElement();
 			V v = dict.get(k);
-			map.put(k,v);
+			map.put(k, v);
 		}
 		return map;
 	}

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/qtokens/QuotedTokenizer.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/qtokens/QuotedTokenizer.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/qtokens/QuotedTokenizer.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/qtokens/QuotedTokenizer.java Fri Jun 15 13:27:53 2012
@@ -13,40 +13,41 @@ public class QuotedTokenizer {
 	String	peek;
 	char	separator;
 
-	public QuotedTokenizer(String string, String separators, boolean returnTokens ) {
-		if ( string == null )
+	public QuotedTokenizer(String string, String separators, boolean returnTokens) {
+		if (string == null)
 			throw new IllegalArgumentException("string argument must be not null");
 		this.string = string;
 		this.separators = separators;
 		this.returnTokens = returnTokens;
 	}
+
 	public QuotedTokenizer(String string, String separators) {
-		this(string,separators,false);
+		this(string, separators, false);
 	}
 
 	public String nextToken(String separators) {
 		separator = 0;
-		if ( peek != null ) {
+		if (peek != null) {
 			String tmp = peek;
 			peek = null;
 			return tmp;
 		}
-		
-		if ( index == string.length())
+
+		if (index == string.length())
 			return null;
-		
+
 		StringBuilder sb = new StringBuilder();
 
 		while (index < string.length()) {
 			char c = string.charAt(index++);
 
-			if ( Character.isWhitespace(c)) {
-				if ( index == string.length())
+			if (Character.isWhitespace(c)) {
+				if (index == string.length())
 					break;
 				sb.append(c);
 				continue;
 			}
-			
+
 			if (separators.indexOf(c) >= 0) {
 				if (returnTokens)
 					peek = Character.toString(c);
@@ -66,7 +67,7 @@ public class QuotedTokenizer {
 			}
 		}
 		String result = sb.toString().trim();
-		if ( result.length()==0 && index==string.length())
+		if (result.length() == 0 && index == string.length())
 			return null;
 		return result;
 	}
@@ -81,8 +82,7 @@ public class QuotedTokenizer {
 			c = string.charAt(index++);
 			if (c == quote)
 				break;
-			if (c == '\\' && index < string.length()
-					&& string.charAt(index + 1) == quote)
+			if (c == '\\' && index < string.length() && string.charAt(index + 1) == quote)
 				c = string.charAt(index++);
 			sb.append(c);
 		}
@@ -92,22 +92,24 @@ public class QuotedTokenizer {
 		return getTokens(0);
 	}
 
-	private String [] getTokens(int cnt){
+	private String[] getTokens(int cnt) {
 		String token = nextToken();
-		if ( token == null ) 
+		if (token == null)
 			return new String[cnt];
-		
-		String result[] = getTokens(cnt+1);
-		result[cnt]=token;
+
+		String result[] = getTokens(cnt + 1);
+		result[cnt] = token;
 		return result;
 	}
 
-	public char getSeparator() { return separator; }
-	
+	public char getSeparator() {
+		return separator;
+	}
+
 	public List<String> getTokenSet() {
 		List<String> list = Create.list();
 		String token = nextToken();
-		while ( token != null ) {
+		while (token != null) {
 			list.add(token);
 			token = nextToken();
 		}

Added: felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Message.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Message.java?rev=1350613&view=auto
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Message.java (added)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Message.java Fri Jun 15 13:27:53 2012
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) OSGi Alliance (2012). All Rights Reserved.
+ * 
+ * Licensed 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 aQute.libg.reporter;
+
+public @interface Message {
+	String value();
+}

Propchange: felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Message.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Message.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Messages.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Messages.java?rev=1350613&view=auto
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Messages.java (added)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Messages.java Fri Jun 15 13:27:53 2012
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) OSGi Alliance (2012). All Rights Reserved.
+ * 
+ * Licensed 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 aQute.libg.reporter;
+
+import java.io.*;
+
+public interface Messages {
+	static public class ERROR {}
+
+	static public class WARNING {}
+
+	ERROR NoSuchFile_(File f);
+
+	ERROR Unexpected_Error_(String context, Exception e);
+
+}

Propchange: felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Messages.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Messages.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Reporter.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Reporter.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Reporter.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/Reporter.java Fri Jun 15 13:27:53 2012
@@ -2,14 +2,20 @@ package aQute.libg.reporter;
 
 import java.util.*;
 
-
 public interface Reporter {
-	void error(String s, Object ... args);
-	void warning(String s, Object ... args);
-	void progress(String s, Object ... args);
-	void trace(String s, Object ... args);
+	void error(String s, Object... args);
+
+	void warning(String s, Object... args);
+
+	void progress(String s, Object... args);
+
+	void trace(String s, Object... args);
+
 	List<String> getWarnings();
+
 	List<String> getErrors();
-	
+
 	boolean isPedantic();
+	
+	boolean isExceptions();
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java Fri Jun 15 13:27:53 2012
@@ -8,7 +8,6 @@ import aQute.libg.generics.*;
 
 /**
  * Mainly used for testing where reporters are needed.
- * 
  */
 public class ReporterAdapter implements Reporter {
 	final List<String>	errors		= new ArrayList<String>();
@@ -74,7 +73,7 @@ public class ReporterAdapter implements 
 		errors.add(e);
 		trace("ERROR: %s", e);
 		if (isExceptions() || isTrace())
-			if ( t instanceof InvocationTargetException )
+			if (t instanceof InvocationTargetException)
 				t.getCause().printStackTrace(System.err);
 			else
 				t.printStackTrace(System.err);
@@ -89,14 +88,14 @@ public class ReporterAdapter implements 
 	public void progress(String s, Object... args) {
 		if (out != null) {
 			out.format(s, args);
-			if ( !s.endsWith("\n"))
+			if (!s.endsWith("\n"))
 				out.format("\n");
 		}
 	}
 
 	public void trace(String s, Object... args) {
 		if (trace && out != null) {
-			out.format("# "+s+"\n", args);
+			out.format("# " + s + "\n", args);
 			out.flush();
 		}
 	}
@@ -172,8 +171,8 @@ public class ReporterAdapter implements 
 	void report(String title, Collection<String> list, Formatter f) {
 		if (list.isEmpty())
 			return;
-		f.format(title + (list.size() > 1 ? "s" : "")+"\n");
-		int n=0;
+		f.format(title + (list.size() > 1 ? "s" : "") + "\n");
+		int n = 0;
 		for (String s : list) {
 			f.format("%3s. %s\n", n++, s);
 		}

Added: felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterMessages.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterMessages.java?rev=1350613&view=auto
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterMessages.java (added)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterMessages.java Fri Jun 15 13:27:53 2012
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) OSGi Alliance (2012). All Rights Reserved.
+ * 
+ * Licensed 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 aQute.libg.reporter;
+
+import java.lang.reflect.*;
+import java.util.*;
+
+import aQute.libg.reporter.Messages.ERROR;
+import aQute.libg.reporter.Messages.WARNING;
+
+public class ReporterMessages {
+
+	@SuppressWarnings("unchecked")
+	public static <T> T base(final Reporter reporter, Class<T> messages) {
+		return (T) Proxy.newProxyInstance(messages.getClassLoader(), new Class[] {
+			messages
+		}, new InvocationHandler() {
+
+			public Object invoke(Object target, Method method, Object[] args) throws Throwable {
+				if (reporter.isExceptions()) {
+					for (Object o : args) {
+						if (o instanceof Throwable)
+							((Throwable) o).printStackTrace();
+					}
+				}
+				String format;
+				Message d = method.getAnnotation(Message.class);
+				if (d == null) {
+					String name = method.getName();
+					StringBuilder sb = new StringBuilder();
+					sb.append(name.charAt(0));
+					for (int i = 1; i < name.length(); i++) {
+						char c = name.charAt(i);
+						switch (c) {
+							case '_' :
+								sb.append(" %s, ");
+								break;
+
+							default :
+								if (Character.isUpperCase(c)) {
+									sb.append(" ");
+									c = Character.toLowerCase(c);
+								}
+								sb.append(c);
+						}
+					}
+					format = sb.toString();
+				} else
+					format = d.value();
+
+				try {
+					if (method.getReturnType() == ERROR.class) {
+						reporter.error(format, args);
+					} else if (method.getReturnType() == WARNING.class) {
+						reporter.warning(format, args);
+					} else
+						reporter.trace(format, args);
+				}
+				catch (IllegalFormatException e) {
+					reporter.error("Formatter failed: %s %s %s", method.getName(), format, Arrays.toString(args));
+				}
+				return null;
+			}
+		});
+	}
+}

Propchange: felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterMessages.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterMessages.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/ContentFilter.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/ContentFilter.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/ContentFilter.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/ContentFilter.java Fri Jun 15 13:27:53 2012
@@ -1,8 +1,9 @@
 package aQute.libg.sax;
 
-import org.xml.sax.ContentHandler;
+import org.xml.sax.*;
 
 public interface ContentFilter extends ContentHandler {
 	void setParent(ContentHandler parent);
+
 	ContentHandler getParent();
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/ContentFilterImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/ContentFilterImpl.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/ContentFilterImpl.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/ContentFilterImpl.java Fri Jun 15 13:27:53 2012
@@ -1,17 +1,14 @@
 package aQute.libg.sax;
 
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
+import org.xml.sax.*;
 
 public class ContentFilterImpl implements ContentFilter {
 
-	private ContentHandler parent;
+	private ContentHandler	parent;
 
 	public void setParent(ContentHandler parent) {
 		this.parent = parent;
-		
+
 	}
 
 	public ContentHandler getParent() {
@@ -30,8 +27,7 @@ public class ContentFilterImpl implement
 		parent.endDocument();
 	}
 
-	public void startPrefixMapping(String prefix, String uri)
-			throws SAXException {
+	public void startPrefixMapping(String prefix, String uri) throws SAXException {
 		parent.startPrefixMapping(prefix, uri);
 	}
 
@@ -39,28 +35,23 @@ public class ContentFilterImpl implement
 		parent.endPrefixMapping(prefix);
 	}
 
-	public void startElement(String uri, String localName, String qName,
-			Attributes atts) throws SAXException {
+	public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
 		parent.startElement(uri, localName, qName, atts);
 	}
 
-	public void endElement(String uri, String localName, String qName)
-			throws SAXException {
+	public void endElement(String uri, String localName, String qName) throws SAXException {
 		parent.endElement(uri, localName, qName);
 	}
 
-	public void characters(char[] ch, int start, int length)
-			throws SAXException {
+	public void characters(char[] ch, int start, int length) throws SAXException {
 		parent.characters(ch, start, length);
 	}
 
-	public void ignorableWhitespace(char[] ch, int start, int length)
-			throws SAXException {
+	public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
 		parent.ignorableWhitespace(ch, start, length);
 	}
 
-	public void processingInstruction(String target, String data)
-			throws SAXException {
+	public void processingInstruction(String target, String data) throws SAXException {
 		parent.processingInstruction(target, data);
 	}
 

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/SAXElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/SAXElement.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/SAXElement.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/SAXElement.java Fri Jun 15 13:27:53 2012
@@ -1,16 +1,15 @@
 package aQute.libg.sax;
 
-import org.xml.sax.Attributes;
+import org.xml.sax.*;
 
 public class SAXElement {
 
-	private final String uri;
-	private final String localName;
-	private final String qName;
-	private final Attributes atts;
+	private final String		uri;
+	private final String		localName;
+	private final String		qName;
+	private final Attributes	atts;
 
-	public SAXElement(String uri, String localName, String qName,
-			Attributes atts) {
+	public SAXElement(String uri, String localName, String qName, Attributes atts) {
 		this.uri = uri;
 		this.localName = localName;
 		this.qName = qName;

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/SAXUtil.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/SAXUtil.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/SAXUtil.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/SAXUtil.java Fri Jun 15 13:27:53 2012
@@ -1,29 +1,28 @@
 package aQute.libg.sax;
 
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.Result;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.parsers.*;
+import javax.xml.transform.*;
+import javax.xml.transform.sax.*;
 
-import org.xml.sax.ContentHandler;
-import org.xml.sax.XMLReader;
+import org.xml.sax.*;
 
 public class SAXUtil {
-	
+
 	public static XMLReader buildPipeline(Result output, ContentFilter... filters) throws Exception {
 		SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
 		TransformerHandler handler = factory.newTransformerHandler();
 		handler.setResult(output);
-		
+
 		ContentHandler last = handler;
-		if (filters != null) for (ContentFilter filter : filters) {
-			filter.setParent(last);
-			last = filter;
-		}
+		if (filters != null)
+			for (ContentFilter filter : filters) {
+				filter.setParent(last);
+				last = filter;
+			}
 		XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
 		reader.setContentHandler(last);
-		
+
 		return reader;
 	}
-	
+
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/filters/ElementSelectionFilter.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/filters/ElementSelectionFilter.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/filters/ElementSelectionFilter.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/filters/ElementSelectionFilter.java Fri Jun 15 13:27:53 2012
@@ -1,17 +1,16 @@
 package aQute.libg.sax.filters;
 
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
+import org.xml.sax.*;
 
-import aQute.libg.sax.ContentFilterImpl;
+import aQute.libg.sax.*;
+
+public abstract class ElementSelectionFilter extends ContentFilterImpl {
+
+	int	depth		= 0;
+	int	hiddenDepth	= -1;
 
-public abstract class ElementSelectionFilter extends ContentFilterImpl{
-	
-	int depth = 0;
-	int hiddenDepth = -1;
-	
 	protected abstract boolean select(int depth, String uri, String localName, String qName, Attributes attribs);
-	
+
 	@Override
 	public final void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
 		if (hiddenDepth < 0) {
@@ -21,29 +20,31 @@ public abstract class ElementSelectionFi
 			else
 				hiddenDepth = 0;
 		} else {
-			hiddenDepth ++;
+			hiddenDepth++;
 		}
 		depth++;
 	}
-	
+
 	@Override
 	public final void endElement(String uri, String localName, String qName) throws SAXException {
 		if (hiddenDepth < 0) {
 			super.endElement(uri, localName, qName);
 		} else {
-			hiddenDepth --;
+			hiddenDepth--;
 		}
-		depth --;
+		depth--;
 	}
-	
+
 	@Override
 	public void characters(char[] ch, int start, int length) throws SAXException {
-		if (hiddenDepth < 0) super.characters(ch, start, length);
+		if (hiddenDepth < 0)
+			super.characters(ch, start, length);
 	}
-	
+
 	@Override
 	public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
-		if (hiddenDepth < 0) super.ignorableWhitespace(ch, start, length);
+		if (hiddenDepth < 0)
+			super.ignorableWhitespace(ch, start, length);
 	}
-	
+
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/filters/MergeContentFilter.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/filters/MergeContentFilter.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/filters/MergeContentFilter.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/sax/filters/MergeContentFilter.java Fri Jun 15 13:27:53 2012
@@ -1,28 +1,26 @@
 package aQute.libg.sax.filters;
 
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
 
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
+import org.xml.sax.*;
 
-import aQute.libg.sax.ContentFilterImpl;
-import aQute.libg.sax.SAXElement;
+import aQute.libg.sax.*;
 
 public class MergeContentFilter extends ContentFilterImpl {
 
-	private int elementDepth = 0;
-	
-	private final List<SAXElement> rootElements = new LinkedList<SAXElement>();
-	
+	private int						elementDepth	= 0;
+
+	private final List<SAXElement>	rootElements	= new LinkedList<SAXElement>();
+
 	@Override
 	public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
 		if (elementDepth++ == 0) {
 			if (rootElements.isEmpty())
 				super.startElement(uri, localName, qName, atts);
 			else if (!rootElements.get(0).getqName().equals(qName))
-				throw new SAXException(String.format("Documents have inconsistent root element names: first was %s, current is %s.", rootElements.get(0).getqName(), qName));
+				throw new SAXException(String.format(
+						"Documents have inconsistent root element names: first was %s, current is %s.", rootElements
+								.get(0).getqName(), qName));
 			rootElements.add(new SAXElement(uri, localName, qName, atts));
 		} else {
 			super.startElement(uri, localName, qName, atts);
@@ -35,13 +33,13 @@ public class MergeContentFilter extends 
 			super.endElement(uri, localName, qName);
 		}
 	}
-	
+
 	@Override
 	public void processingInstruction(String target, String data) throws SAXException {
 		if (rootElements.isEmpty())
 			super.processingInstruction(target, data);
 	}
-	
+
 	public void closeRootAndDocument() throws SAXException {
 		if (!rootElements.isEmpty()) {
 			SAXElement root = rootElements.get(0);
@@ -49,7 +47,7 @@ public class MergeContentFilter extends 
 		}
 		super.endDocument();
 	}
-	
+
 	public List<SAXElement> getRootElements() {
 		return Collections.unmodifiableList(rootElements);
 	}

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/sed/Replacer.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/sed/Replacer.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/sed/Replacer.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/sed/Replacer.java Fri Jun 15 13:27:53 2012
@@ -1,5 +1,5 @@
 package aQute.libg.sed;
 
 public interface Replacer {
-    String process(String line);
+	String process(String line);
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/sed/Sed.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/sed/Sed.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/sed/Sed.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/sed/Sed.java Fri Jun 15 13:27:53 2012
@@ -4,96 +4,98 @@ import java.io.*;
 import java.util.*;
 import java.util.regex.*;
 
+import aQute.lib.io.IO;
+
 public class Sed {
-    final File                 file;
-    final Replacer             macro;
-    File                       output;
-    boolean backup = true;
-
-    final Map<Pattern, String> replacements = new LinkedHashMap<Pattern, String>();
-
-    public Sed(Replacer macro, File file) {
-        assert file.isFile();
-        this.file = file;
-        this.macro = macro;
-    }
-    
-    public Sed(File file) {
-        assert file.isFile();
-        this.file = file;
-        this.macro = null;
-    }
-
-    public void setOutput(File f) {
-        output = f;
-    }
-
-    public void replace(String pattern, String replacement) {
-        replacements.put(Pattern.compile(pattern), replacement);
-    }
-
-    public int doIt() throws IOException {
-    	int actions = 0;
-        BufferedReader brdr = new BufferedReader(new InputStreamReader( new FileInputStream(file),"UTF-8"));
-        File out;
-        if (output != null)
-            out = output;
-        else
-            out = new File(file.getAbsolutePath() + ".tmp");
-        PrintWriter pw = new PrintWriter(new OutputStreamWriter( new FileOutputStream(out),"UTF-8"));
-        try {
-            String line;
-            while ((line = brdr.readLine()) != null) {
-                for (Pattern p : replacements.keySet()) {
-                    String replace = replacements.get(p);
-                    Matcher m = p.matcher(line);
-
-                    StringBuffer sb = new StringBuffer();
-                    while (m.find()) {
-                        String tmp = setReferences(m, replace);
-                        if ( macro != null)
-                        	tmp = Matcher.quoteReplacement(macro.process(tmp));
-                        m.appendReplacement(sb, tmp);
-                        actions++;
-                    }
-                    m.appendTail(sb);
-
-                    line = sb.toString();
-                }
-                pw.println(line);
-            }
-            pw.close();
-            if (output == null) {
-            	if ( backup ) {
-                    File bak = new File(file.getAbsolutePath() + ".bak");
-            		file.renameTo(bak);
-            	}
-                out.renameTo(file);
-            }
+	final File					file;
+	final Replacer				macro;
+	File						output;
+	boolean						backup			= true;
+
+	final Map<Pattern,String>	replacements	= new LinkedHashMap<Pattern,String>();
+
+	public Sed(Replacer macro, File file) {
+		assert file.isFile();
+		this.file = file;
+		this.macro = macro;
+	}
+
+	public Sed(File file) {
+		assert file.isFile();
+		this.file = file;
+		this.macro = null;
+	}
+
+	public void setOutput(File f) {
+		output = f;
+	}
+
+	public void replace(String pattern, String replacement) {
+		replacements.put(Pattern.compile(pattern), replacement);
+	}
+
+	public int doIt() throws IOException {
+		int actions = 0;
+		BufferedReader brdr = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
+		File out;
+		if (output != null)
+			out = output;
+		else
+			out = new File(file.getAbsolutePath() + ".tmp");
+		PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(out), "UTF-8"));
+		try {
+			String line;
+			while ((line = brdr.readLine()) != null) {
+				for (Pattern p : replacements.keySet()) {
+					String replace = replacements.get(p);
+					Matcher m = p.matcher(line);
+
+					StringBuffer sb = new StringBuffer();
+					while (m.find()) {
+						String tmp = setReferences(m, replace);
+						if (macro != null)
+							tmp = Matcher.quoteReplacement(macro.process(tmp));
+						m.appendReplacement(sb, tmp);
+						actions++;
+					}
+					m.appendTail(sb);
+
+					line = sb.toString();
+				}
+				pw.println(line);
+			}
         } finally {
-            brdr.close();
-            pw.close();
-        }
-        return actions;
-    }
-
-    private String setReferences(Matcher m, String replace) {
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < replace.length(); i++) {
-            char c = replace.charAt(i);
-            if (c == '$' && i < replace.length() - 1
-                    && Character.isDigit(replace.charAt(i + 1))) {
-                int n = replace.charAt(i + 1) - '0';
-                if ( n <= m.groupCount() )
-                    sb.append(m.group(n));
-                i++;
-            } else
-                sb.append(c);
+        	brdr.close();
+			pw.close();
         }
-        return sb.toString();
-    }
-
-    public void setBackup(boolean b) {
-    	this.backup=b;
-    }
+        
+		if (output == null) {
+			if (backup) {
+				File bak = new File(file.getAbsolutePath() + ".bak");
+				IO.rename(file, bak);
+			}
+			IO.rename(out, file);
+		}
+        
+		return actions;
+	}
+    
+	private String setReferences(Matcher m, String replace) {
+		StringBuilder sb = new StringBuilder();
+		for (int i = 0; i < replace.length(); i++) {
+			char c = replace.charAt(i);
+			if (c == '$' && i < replace.length() - 1 && Character.isDigit(replace.charAt(i + 1))) {
+				int n = replace.charAt(i + 1) - '0';
+				if (n <= m.groupCount())
+					sb.append(m.group(n));
+				i++;
+			} else
+				sb.append(c);
+		}
+		return sb.toString();
+	}
+
+	public void setBackup(boolean b) {
+		this.backup = b;
+	}
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/tarjan/Tarjan.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/tarjan/Tarjan.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/tarjan/Tarjan.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/tarjan/Tarjan.java Fri Jun 15 13:27:53 2012
@@ -15,43 +15,42 @@ public class Tarjan<T> {
 		public Node(T name) {
 			this.name = name;
 		}
-		
+
 		public String toString() {
 			return name + "{" + index + "," + low + "}";
 		}
 	}
 
-	private int				index	= 0;
-	private List<Node>		stack	= new ArrayList<Node>();
+	private int			index	= 0;
+	private List<Node>	stack	= new ArrayList<Node>();
 	private Set<Set<T>>	scc		= new HashSet<Set<T>>();
-	private Node			root	= new Node(null);
+	private Node		root	= new Node(null);
 
-	
-//	   public ArrayList<ArrayList<Node>> tarjan(Node v, AdjacencyList list){
-//	       v.index = index;
-//	       v.lowlink = index;
-//	       index++;
-//	       stack.add(0, v);
-//	       for(Edge e : list.getAdjacent(v)){
-//	           Node n = e.to;
-//	           if(n.index == -1){
-//	               tarjan(n, list);
-//	               v.lowlink = Math.min(v.lowlink, n.lowlink);
-//	           }else if(stack.contains(n)){
-//	               v.lowlink = Math.min(v.lowlink, n.index);
-//	           }
-//	       }
-//	       if(v.lowlink == v.index){
-//	           Node n;
-//	           ArrayList<Node> component = new ArrayList<Node>();
-//	           do{
-//	               n = stack.remove(0);
-//	               component.add(n);
-//	           }while(n != v);
-//	           SCC.add(component);
-//	       }
-//	       return SCC;
-//	   }
+	// public ArrayList<ArrayList<Node>> tarjan(Node v, AdjacencyList list){
+	// v.index = index;
+	// v.lowlink = index;
+	// index++;
+	// stack.add(0, v);
+	// for(Edge e : list.getAdjacent(v)){
+	// Node n = e.to;
+	// if(n.index == -1){
+	// tarjan(n, list);
+	// v.lowlink = Math.min(v.lowlink, n.lowlink);
+	// }else if(stack.contains(n)){
+	// v.lowlink = Math.min(v.lowlink, n.index);
+	// }
+	// }
+	// if(v.lowlink == v.index){
+	// Node n;
+	// ArrayList<Node> component = new ArrayList<Node>();
+	// do{
+	// n = stack.remove(0);
+	// component.add(n);
+	// }while(n != v);
+	// SCC.add(component);
+	// }
+	// return SCC;
+	// }
 
 	void tarjan(Node v) {
 		v.index = index;
@@ -68,7 +67,7 @@ public class Tarjan<T> {
 			}
 		}
 
-		if (v!=root && v.low == v.index) {
+		if (v != root && v.low == v.index) {
 			Set<T> component = new HashSet<T>();
 			Node n;
 			do {
@@ -80,7 +79,7 @@ public class Tarjan<T> {
 	}
 
 	Set<Set<T>> getResult(Map<T, ? extends Collection<T>> graph) {
-		Map<T, Node> index = new HashMap<T, Node>();
+		Map<T,Node> index = new HashMap<T,Node>();
 
 		for (Map.Entry<T, ? extends Collection<T>> entry : graph.entrySet()) {
 			Node node = getNode(index, entry.getKey());
@@ -92,7 +91,7 @@ public class Tarjan<T> {
 		return scc;
 	}
 
-	private Node getNode(Map<T, Node> index, T key) {
+	private Node getNode(Map<T,Node> index, T key) {
 		Node node = index.get(key);
 		if (node == null) {
 			node = new Node(key);
@@ -101,7 +100,7 @@ public class Tarjan<T> {
 		return node;
 	}
 
-	public static <T> Collection<? extends Collection<T>> tarjan(Map<T, ? extends Collection<T>> graph) {
+	public static <T> Collection< ? extends Collection<T>> tarjan(Map<T, ? extends Collection<T>> graph) {
 		Tarjan<T> tarjan = new Tarjan<T>();
 		return tarjan.getResult(graph);
 	}

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/tuple/Pair.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/tuple/Pair.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/tuple/Pair.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/tuple/Pair.java Fri Jun 15 13:27:53 2012
@@ -1,9 +1,9 @@
 package aQute.libg.tuple;
 
-public class Pair<A,B> {
-	final public A a;
-	final public B b;
-	
+public class Pair<A, B> {
+	final public A	a;
+	final public B	b;
+
 	public Pair(A a, B b) {
 		this.a = a;
 		this.b = b;

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/version/Version.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/version/Version.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/version/Version.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/version/Version.java Fri Jun 15 13:27:53 2012
@@ -3,150 +3,148 @@ package aQute.libg.version;
 import java.util.regex.*;
 
 public class Version implements Comparable<Version> {
-    final int                   major;
-    final int                   minor;
-    final int                   micro;
-    final String                qualifier;
-    public final static String  VERSION_STRING = "(\\d+)(\\.(\\d+)(\\.(\\d+)(\\.([-_\\da-zA-Z]+))?)?)?";
-    public final static Pattern VERSION        = Pattern
-                                                       .compile(VERSION_STRING);
-    public final static Version LOWEST         = new Version();
-    public final static Version HIGHEST        = new Version(Integer.MAX_VALUE,
-                                                       Integer.MAX_VALUE,
-                                                       Integer.MAX_VALUE,
-                                                       "\uFFFF");
-
-    public static final Version	emptyVersion	= LOWEST;
-    public static final Version	ONE	= new Version(1,0,0);
-
-    public Version() {
-        this(0);
-    }
-
-    public Version(int major, int minor, int micro, String qualifier) {
-        this.major = major;
-        this.minor = minor;
-        this.micro = micro;
-        this.qualifier = qualifier;
-    }
-
-    public Version(int major, int minor, int micro) {
-        this(major, minor, micro, null);
-    }
-
-    public Version(int major, int minor) {
-        this(major, minor, 0, null);
-    }
-
-    public Version(int major) {
-        this(major, 0, 0, null);
-    }
-
-    public Version(String version) {
-    	version = version.trim();
-        Matcher m = VERSION.matcher(version);
-        if (!m.matches())
-            throw new IllegalArgumentException("Invalid syntax for version: "
-                    + version);
-
-        major = Integer.parseInt(m.group(1));
-        if (m.group(3) != null)
-            minor = Integer.parseInt(m.group(3));
-        else
-            minor = 0;
-
-        if (m.group(5) != null)
-            micro = Integer.parseInt(m.group(5));
-        else
-            micro = 0;
-
-        qualifier = m.group(7);
-    }
-
-    public int getMajor() {
-        return major;
-    }
-
-    public int getMinor() {
-        return minor;
-    }
-
-    public int getMicro() {
-        return micro;
-    }
-
-    public String getQualifier() {
-        return qualifier;
-    }
-
-    public int compareTo(Version other) {
-        if (other == this)
-            return 0;
-
-        Version o = other;
-        if (major != o.major)
-            return major - o.major;
-
-        if (minor != o.minor)
-            return minor - o.minor;
-
-        if (micro != o.micro)
-            return micro - o.micro;
-
-        int c = 0;
-        if (qualifier != null)
-            c = 1;
-        if (o.qualifier != null)
-            c += 2;
-
-        switch (c) {
-        case 0:
-            return 0;
-        case 1:
-            return 1;
-        case 2:
-            return -1;
-        }
-        return qualifier.compareTo(o.qualifier);
-    }
-
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(major);
-        sb.append(".");
-        sb.append(minor);
-        sb.append(".");
-        sb.append(micro);
-        if (qualifier != null) {
-            sb.append(".");
-            sb.append(qualifier);
-        }
-        return sb.toString();
-    }
-
-    public boolean equals(Object ot) {
-        if ( ! (ot instanceof Version))
-            return false;
-        
-        return compareTo((Version)ot) == 0;
-    }
-
-    public int hashCode() {
-        return major * 97 ^ minor * 13 ^ micro
-                + (qualifier == null ? 97 : qualifier.hashCode());
-    }
-
-    public int get(int i) {
-        switch(i) {
-        case 0 : return major;
-        case 1 : return minor;
-        case 2 : return micro;
-        default:
-            throw new IllegalArgumentException("Version can only get 0 (major), 1 (minor), or 2 (micro)");
-        }
-    }
-    
-    public static Version parseVersion(String version) {
+	final int					major;
+	final int					minor;
+	final int					micro;
+	final String				qualifier;
+	public final static String	VERSION_STRING	= "(\\d+)(\\.(\\d+)(\\.(\\d+)(\\.([-_\\da-zA-Z]+))?)?)?";
+	public final static Pattern	VERSION			= Pattern.compile(VERSION_STRING);
+	public final static Version	LOWEST			= new Version();
+	public final static Version	HIGHEST			= new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE,
+														"\uFFFF");
+
+	public static final Version	emptyVersion	= LOWEST;
+	public static final Version	ONE				= new Version(1, 0, 0);
+
+	public Version() {
+		this(0);
+	}
+
+	public Version(int major, int minor, int micro, String qualifier) {
+		this.major = major;
+		this.minor = minor;
+		this.micro = micro;
+		this.qualifier = qualifier;
+	}
+
+	public Version(int major, int minor, int micro) {
+		this(major, minor, micro, null);
+	}
+
+	public Version(int major, int minor) {
+		this(major, minor, 0, null);
+	}
+
+	public Version(int major) {
+		this(major, 0, 0, null);
+	}
+
+	public Version(String version) {
+		version = version.trim();
+		Matcher m = VERSION.matcher(version);
+		if (!m.matches())
+			throw new IllegalArgumentException("Invalid syntax for version: " + version);
+
+		major = Integer.parseInt(m.group(1));
+		if (m.group(3) != null)
+			minor = Integer.parseInt(m.group(3));
+		else
+			minor = 0;
+
+		if (m.group(5) != null)
+			micro = Integer.parseInt(m.group(5));
+		else
+			micro = 0;
+
+		qualifier = m.group(7);
+	}
+
+	public int getMajor() {
+		return major;
+	}
+
+	public int getMinor() {
+		return minor;
+	}
+
+	public int getMicro() {
+		return micro;
+	}
+
+	public String getQualifier() {
+		return qualifier;
+	}
+
+	public int compareTo(Version other) {
+		if (other == this)
+			return 0;
+
+		Version o = other;
+		if (major != o.major)
+			return major - o.major;
+
+		if (minor != o.minor)
+			return minor - o.minor;
+
+		if (micro != o.micro)
+			return micro - o.micro;
+
+		int c = 0;
+		if (qualifier != null)
+			c = 1;
+		if (o.qualifier != null)
+			c += 2;
+
+		switch (c) {
+			case 0 :
+				return 0;
+			case 1 :
+				return 1;
+			case 2 :
+				return -1;
+		}
+		return qualifier.compareTo(o.qualifier);
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append(major);
+		sb.append(".");
+		sb.append(minor);
+		sb.append(".");
+		sb.append(micro);
+		if (qualifier != null) {
+			sb.append(".");
+			sb.append(qualifier);
+		}
+		return sb.toString();
+	}
+
+	public boolean equals(Object ot) {
+		if (!(ot instanceof Version))
+			return false;
+
+		return compareTo((Version) ot) == 0;
+	}
+
+	public int hashCode() {
+		return major * 97 ^ minor * 13 ^ micro + (qualifier == null ? 97 : qualifier.hashCode());
+	}
+
+	public int get(int i) {
+		switch (i) {
+			case 0 :
+				return major;
+			case 1 :
+				return minor;
+			case 2 :
+				return micro;
+			default :
+				throw new IllegalArgumentException("Version can only get 0 (major), 1 (minor), or 2 (micro)");
+		}
+	}
+
+	public static Version parseVersion(String version) {
 		if (version == null) {
 			return LOWEST;
 		}
@@ -158,9 +156,9 @@ public class Version implements Comparab
 
 		return new Version(version);
 
-    }
-    
-    public Version getWithoutQualifier() {
-    	return new Version(major,minor,micro);
-    }
+	}
+
+	public Version getWithoutQualifier() {
+		return new Version(major, minor, micro);
+	}
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/version/VersionRange.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/version/VersionRange.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/version/VersionRange.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/version/VersionRange.java Fri Jun 15 13:27:53 2012
@@ -9,9 +9,8 @@ public class VersionRange {
 	char			start	= '[';
 	char			end		= ']';
 
-	static Pattern	RANGE	= Pattern.compile("(\\(|\\[)\\s*(" +
-									Version.VERSION_STRING + ")\\s*,\\s*(" +
-									Version.VERSION_STRING + ")\\s*(\\)|\\])");
+	static Pattern	RANGE	= Pattern.compile("(\\(|\\[)\\s*(" + Version.VERSION_STRING + ")\\s*,\\s*("
+									+ Version.VERSION_STRING + ")\\s*(\\)|\\])");
 
 	public VersionRange(String string) {
 		string = string.trim();
@@ -24,9 +23,7 @@ public class VersionRange {
 			high = new Version(v2);
 			end = m.group(18).charAt(0);
 			if (low.compareTo(high) > 0)
-				throw new IllegalArgumentException(
-						"Low Range is higher than High Range: " + low + "-" +
-								high);
+				throw new IllegalArgumentException("Low Range is higher than High Range: " + low + "-" + high);
 
 		} else
 			high = low = new Version(string);
@@ -66,8 +63,8 @@ public class VersionRange {
 	}
 
 	public boolean includes(Version v) {
-		if ( !isRange() ) {
-			return low.compareTo(v) <=0;
+		if (!isRange()) {
+			return low.compareTo(v) <= 0;
 		}
 		if (includeLow()) {
 			if (v.compareTo(low) < 0)
@@ -80,17 +77,17 @@ public class VersionRange {
 				return false;
 		} else if (v.compareTo(high) >= 0)
 			return false;
-		
+
 		return true;
 	}
-	
-	public Iterable<Version> filter( final Iterable<Version> versions) {
+
+	public Iterable<Version> filter(final Iterable<Version> versions) {
 		List<Version> list = new ArrayList<Version>();
-		for ( Version v : versions) {
-			if ( includes(v))
+		for (Version v : versions) {
+			if (includes(v))
 				list.add(v);
 		}
 		return list;
 	}
-	
+
 }
\ No newline at end of file

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/xslt/Transform.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/xslt/Transform.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/xslt/Transform.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/xslt/Transform.java Fri Jun 15 13:27:53 2012
@@ -9,36 +9,35 @@ import javax.xml.transform.*;
 import javax.xml.transform.stream.*;
 
 public class Transform {
-    static TransformerFactory transformerFactory = TransformerFactory
-                                                         .newInstance();
+	static TransformerFactory	transformerFactory	= TransformerFactory.newInstance();
 
-    static Map<URL, Templates> cache          = new ConcurrentHashMap<URL, Templates>();
+	static Map<URL,Templates>	cache				= new ConcurrentHashMap<URL,Templates>();
 
-    public static void transform(TransformerFactory transformerFactory, URL xslt, InputStream in, OutputStream out)
-            throws Exception {
-        if ( xslt == null ) 
-            throw new IllegalArgumentException("No source template specified");
-        
-        Templates templates = cache.get(xslt);
-        if (templates == null) {
-            InputStream xsltIn = xslt.openStream();
-            try {
-                templates = transformerFactory
-                        .newTemplates(new StreamSource(xsltIn));
-
-                cache.put(xslt, templates);
-            } finally {
-                in.close();
-            }
-        }
-        Result xmlResult = new StreamResult(out);
-        Source xmlSource = new StreamSource(in);
-        Transformer t = templates.newTransformer();
-        t.transform(xmlSource, xmlResult);
-        out.flush();
-    }
-
-    public static void transform(URL xslt, InputStream in, OutputStream out) throws Exception {
-        transform(transformerFactory,xslt, in, out);
-    }
+	public static void transform(TransformerFactory transformerFactory, URL xslt, InputStream in, OutputStream out)
+			throws Exception {
+		if (xslt == null)
+			throw new IllegalArgumentException("No source template specified");
+
+		Templates templates = cache.get(xslt);
+		if (templates == null) {
+			InputStream xsltIn = xslt.openStream();
+			try {
+				templates = transformerFactory.newTemplates(new StreamSource(xsltIn));
+
+				cache.put(xslt, templates);
+			}
+			finally {
+				in.close();
+			}
+		}
+		Result xmlResult = new StreamResult(out);
+		Source xmlSource = new StreamSource(in);
+		Transformer t = templates.newTransformer();
+		t.transform(xmlSource, xmlResult);
+		out.flush();
+	}
+
+	public static void transform(URL xslt, InputStream in, OutputStream out) throws Exception {
+		transform(transformerFactory, xslt, in, out);
+	}
 }



Mime
View raw message