mirror of
https://github.com/apache/openjpa.git
synced 2025-03-07 00:49:39 +00:00
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.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1182512 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b5859a740b
commit
c7c8eb2fc1
@ -21,12 +21,15 @@ package org.apache.openjpa.persistence.meta;
|
||||
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 extends AbstractProcessor {
|
||||
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 extends AbstractProcessor {
|
||||
}
|
||||
|
||||
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 extends AbstractProcessor {
|
||||
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) {
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user