openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwsut...@apache.org
Subject svn commit: r1182512 - in /openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence: meta/AnnotationProcessor6.java util/SourceCode.java
Date Wed, 12 Oct 2011 18:28:27 GMT
Author: kwsutter
Date: Wed Oct 12 18:28:26 2011
New Revision: 1182512

URL: http://svn.apache.org/viewvc?rev=1182512&view=rev
Log:
OPENJPA-2044.  Updating the processing for the openjpa.header parameter on the AnnotationProcessor6
code.  Not only to read the actual data (vs a String representation of the URL stream), but
also to make it more flexible on the number of lines contained in the designated header file.

Modified:
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/util/SourceCode.java

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java?rev=1182512&r1=1182511&r2=1182512&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
Wed Oct 12 18:28:26 2011
@@ -21,12 +21,15 @@ package org.apache.openjpa.persistence.m
 import static javax.lang.model.SourceVersion.RELEASE_6;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.PrintWriter;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.Scanner;
 import java.util.Set;
 
 import javax.annotation.Generated;
@@ -107,7 +110,7 @@ public class AnnotationProcessor6 extend
     private MetaDataFactory factory;
     private int generatedSourceVersion = 6;
     private CompileTimeLogger logger;
-    private String header;
+    private List<String> header = new ArrayList<String>();
     private boolean active;
     private static Localizer _loc =  Localizer.forPackage(AnnotationProcessor6.class);
 
@@ -302,8 +305,8 @@ public class AnnotationProcessor6 extend
     }
     
     private void comment(SourceCode source) {
-        if (header != null)
-            source.addComment(false, header);
+        if (header.size() != 0)
+            source.addComment(false, header.toArray(new String[header.size()]));
         String defaultHeader = _loc.get("mmg-tool-sign").getMessage();
         source.addComment(false, defaultHeader);
     }
@@ -347,11 +350,15 @@ public class AnnotationProcessor6 extend
             return;
         }
         if ("ASL".equalsIgnoreCase(headerOption)) {
-            header = _loc.get("mmg-asl-header").getMessage();
+            header.add(_loc.get("mmg-asl-header").getMessage());
         } else {
             try {
                 URL url = new URL(headerOption);
-                header = url.getContent().toString();
+                InputStream is = url.openStream();
+                Scanner s = new Scanner(is);
+                while (s.hasNextLine()) {
+                    header.add(s.nextLine());
+                }
             } catch (Throwable t) {
                 
             }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/util/SourceCode.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/util/SourceCode.java?rev=1182512&r1=1182511&r2=1182512&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/util/SourceCode.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/util/SourceCode.java
Wed Oct 12 18:28:26 2011
@@ -141,14 +141,20 @@ public class SourceCode {
 	public SourceCode addComment(boolean inline, String... lines) {
 	    if (lines == null)
 	        return this;
-	    if (lines.length == 1 && lines[0].length() > 120)
-	        return addComment(inline, wrap(lines[0], 120-4));
 		if (comments == null) 
 		    comments = new ArrayList<Comment>();
 		Comment comment = new Comment();
 		comments.add(comment);
 		comment.makeInline(inline);
-		for (String line:lines) comment.append(line);
+		for (String line:lines) {
+		    // Handle long header comment lines...
+		    if (line.length() > 120-4) {
+		        String[] wrappedLines = wrap(line, 120-4);
+		        for (String w:wrappedLines) comment.append(w);
+		    } else {
+	            comment.append(line);
+		    }
+		}
 		return this;
 	}
 	
@@ -746,8 +752,8 @@ public class SourceCode {
 					if (i == 0) {
 						out.println("/** ");
 						tab(out, tab);
-					} 
-					out.println(" *  " + l);
+					}
+                    out.println(" *  " + l);
 					i++;
 				}
 				tab(out, tab);



Mime
View raw message