42 |
import java.util.StringTokenizer; |
import java.util.StringTokenizer; |
43 |
|
|
44 |
import gnu.classpath.tools.gjdoc.TemporaryStore; |
import gnu.classpath.tools.gjdoc.TemporaryStore; |
45 |
|
import gnu.classpath.tools.gjdoc.GjdocPackageDoc; |
46 |
|
|
47 |
import gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTranslet; |
import gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTranslet; |
48 |
|
|
67 |
public void printNotice(String ignore) {} |
public void printNotice(String ignore) {} |
68 |
} |
} |
69 |
|
|
|
/** |
|
|
* Used for writing error messages to <code>System.err</code>. |
|
|
*/ |
|
|
private static class BackupErrorReporter implements DocErrorReporter { |
|
|
public void printError(String msg) { |
|
|
System.err.println("ERROR: " + msg); |
|
|
} |
|
|
public void printWarning(String msg) { |
|
|
System.err.println("WARNING: " + msg); |
|
|
} |
|
|
public void printNotice(String msg) { |
|
|
System.err.println(msg); |
|
|
} |
|
|
} |
|
|
|
|
70 |
/* |
/* |
71 |
* Taglet context constants. |
* Taglet context constants. |
72 |
*/ |
*/ |
78 |
private static final int CONTEXT_TYPE = 6; |
private static final int CONTEXT_TYPE = 6; |
79 |
|
|
80 |
/** |
/** |
|
* Errors and warnings will be printed using this after |
|
|
* <code>rootDoc</code> has been garbage collected. |
|
|
*/ |
|
|
private DocErrorReporter reporter = new BackupErrorReporter(); |
|
|
|
|
|
/** |
|
81 |
* All XML output will go to this stream. |
* All XML output will go to this stream. |
82 |
*/ |
*/ |
83 |
private PrintWriter out; |
private PrintWriter out; |
316 |
protected void outputSuperInterfacesRec(int level, ClassDoc classDoc) { |
protected void outputSuperInterfacesRec(int level, ClassDoc classDoc) { |
317 |
if (null!=classDoc) { |
if (null!=classDoc) { |
318 |
ClassDoc[] interfaces = classDoc.interfaces(); |
ClassDoc[] interfaces = classDoc.interfaces(); |
319 |
for (int i=0, ilim=interfaces.length; i<ilim; ++i) { |
if (null != interfaces) { |
320 |
outputType(level, "superimplements", interfaces[i]); |
for (int i=0, ilim=interfaces.length; i<ilim; ++i) { |
321 |
} |
outputType(level, "superimplements", interfaces[i]); |
322 |
|
} |
323 |
|
} |
324 |
outputSuperInterfacesRec(level, classDoc.superclass()); |
outputSuperInterfacesRec(level, classDoc.superclass()); |
325 |
} |
} |
326 |
} |
} |
529 |
|
|
530 |
for (int i=0, ilim=tags.length; i<ilim; ++i) { |
for (int i=0, ilim=tags.length; i<ilim; ++i) { |
531 |
Tag tag = tags[i]; |
Tag tag = tags[i]; |
532 |
|
|
533 |
if (!"Text".equals(tag.name())) { |
if (!"Text".equals(tag.name())) { |
534 |
printOpenTag(0 /* don't introduce additional whitespace */, |
printOpenTag(0 /* don't introduce additional whitespace */, |
535 |
"tag kind=\""+tag.kind()+"\" name=\""+tag.name()+"\"", false); |
"tag kind=\""+tag.kind()+"\" name=\""+tag.name()+"\"", false); |
540 |
outputType(level+1, "exception", throwsTag.exception()); |
outputType(level+1, "exception", throwsTag.exception()); |
541 |
} |
} |
542 |
else { |
else { |
543 |
StringBuffer sb = new StringBuffer("In ThrowsTag: Exception "); |
StringBuffer sb = new StringBuffer("Exception "); |
544 |
sb.append(throwsTag.exceptionName()); |
sb.append(throwsTag.exceptionName()); |
545 |
sb.append(" not found in "); |
sb.append(" not found in "); |
546 |
if (currentExecMember instanceof MethodDoc) { |
if (currentExecMember instanceof MethodDoc) { |
675 |
|
|
676 |
this.rootDoc = _rootDoc; |
this.rootDoc = _rootDoc; |
677 |
_rootDoc = null; |
_rootDoc = null; |
678 |
|
|
679 |
boolean xmlOnly = false; |
boolean xmlOnly = false; |
680 |
|
|
681 |
try { |
try { |
1088 |
File tempDtdDirectory = new File(xmlTargetDirectory, "dtd"); |
File tempDtdDirectory = new File(xmlTargetDirectory, "dtd"); |
1089 |
File tempDtdEntDirectory = new File(tempDtdDirectory, "ent"); |
File tempDtdEntDirectory = new File(tempDtdDirectory, "ent"); |
1090 |
|
|
1091 |
if (tempDtdDirectory.mkdir() && tempDtdEntDirectory.mkdir()) { |
if ((tempDtdDirectory.exists() || tempDtdDirectory.mkdir()) |
1092 |
|
&& (tempDtdEntDirectory.exists() || tempDtdEntDirectory.mkdir())) { |
1093 |
for (int i = 0; i < resources.length; ++ i) { |
for (int i = 0; i < resources.length; ++ i) { |
1094 |
copyResourceToFile("/dtd/" + resources[i], |
copyResourceToFile("/dtd/" + resources[i], |
1095 |
new File(tempDtdDirectory, resources[i])); |
new File(tempDtdDirectory, resources[i])); |
1100 |
return false; |
return false; |
1101 |
} |
} |
1102 |
|
|
1103 |
|
// Copy package data-dir directory |
1104 |
|
|
1105 |
|
PackageDoc[] packages = rootDoc.specifiedPackages(); |
1106 |
|
for (int i=0, ilim=packages.length; i<ilim; ++i) { |
1107 |
|
PackageDoc c = packages[i]; |
1108 |
|
if (c instanceof GjdocPackageDoc) { |
1109 |
|
copyPackageDataDir((GjdocPackageDoc)c); |
1110 |
|
} |
1111 |
|
} |
1112 |
|
|
1113 |
// All information has been output. Apply stylesheet if given. |
// All information has been output. Apply stylesheet if given. |
1114 |
|
|
1115 |
gnu.classpath.tools.gjdoc.Main.releaseRootDoc(); |
gnu.classpath.tools.gjdoc.Main.releaseRootDoc(); |
1116 |
this.rootDoc = null; |
|
1117 |
this.currentClass = null; |
this.currentClass = null; |
1118 |
this.currentMember = null; |
this.currentMember = null; |
1119 |
this.currentExecMember = null; |
this.currentExecMember = null; |
1120 |
|
|
1121 |
System.gc(); |
System.gc(); |
1122 |
|
|
1123 |
// From this point we are only operating on files, so we don't |
// From this point we are only operating on files, so we don't |
1124 |
// need this anymore and can free up some memory |
// need this anymore and can free up some memory |
1125 |
|
|
1133 |
|
|
1134 |
target.getDocTranslet().apply(xmlTargetDirectory, |
target.getDocTranslet().apply(xmlTargetDirectory, |
1135 |
target.getTargetDirectory(), |
target.getTargetDirectory(), |
1136 |
reporter); |
rootDoc); |
1137 |
} |
} |
1138 |
|
|
1139 |
// Done |
// Done |
1426 |
if (null != rootDoc) { |
if (null != rootDoc) { |
1427 |
rootDoc.printError(error); |
rootDoc.printError(error); |
1428 |
} |
} |
|
/* |
|
|
else if (null != reporter) { |
|
|
reporter.printError(error); |
|
|
} |
|
|
*/ |
|
1429 |
else { |
else { |
1430 |
System.err.println("ERROR: "+error); |
System.err.println("ERROR: "+error); |
1431 |
} |
} |
1435 |
if (null != rootDoc) { |
if (null != rootDoc) { |
1436 |
rootDoc.printWarning(warning); |
rootDoc.printWarning(warning); |
1437 |
} |
} |
|
/* |
|
|
else if (null != reporter) { |
|
|
reporter.printWarning(warning); |
|
|
} |
|
|
*/ |
|
1438 |
else { |
else { |
1439 |
System.err.println("WARNING: "+warning); |
System.err.println("WARNING: "+warning); |
1440 |
} |
} |
1444 |
if (null != rootDoc) { |
if (null != rootDoc) { |
1445 |
rootDoc.printNotice(notice); |
rootDoc.printNotice(notice); |
1446 |
} |
} |
|
/* |
|
|
else if (null != reporter) { |
|
|
reporter.printNotice(notice); |
|
|
} |
|
|
*/ |
|
1447 |
else { |
else { |
1448 |
System.err.println(notice); |
System.err.println(notice); |
1449 |
} |
} |
1450 |
} |
} |
1451 |
|
|
1452 |
|
/** |
1453 |
|
* Copy the contents of the input directory to the output |
1454 |
|
* directory. The output directory must exist. |
1455 |
|
*/ |
1456 |
|
private void copyPackageDataDir(GjdocPackageDoc packageDoc) throws IOException { |
1457 |
|
File docFilesSourceDirectory |
1458 |
|
= new File(packageDoc.packageDirectory(), "doc-files"); |
1459 |
|
File docFilesTargetDirectory |
1460 |
|
= new File(this.targetDirectory, |
1461 |
|
packageDoc.name().replace('.', File.separatorChar)); |
1462 |
|
if (docFilesSourceDirectory.exists()) { |
1463 |
|
printNotice("Copying files from " + docFilesSourceDirectory); |
1464 |
|
copyDirectory(docFilesSourceDirectory, docFilesTargetDirectory); |
1465 |
|
} |
1466 |
|
} |
1467 |
|
|
1468 |
|
/** |
1469 |
|
* Recursively copy the contents of the input directory to the |
1470 |
|
* output directory. The output directory must exist. |
1471 |
|
*/ |
1472 |
|
private static void copyDirectory(File sourceDir, File targetDir) throws IOException { |
1473 |
|
if (!targetDir.exists() && !targetDir.mkdirs()) { |
1474 |
|
throw new IOException("Cannot create directory " + targetDir); |
1475 |
|
} |
1476 |
|
|
1477 |
|
File[] sourceFiles = sourceDir.listFiles(); |
1478 |
|
for (int i=0; i<sourceFiles.length; ++i) { |
1479 |
|
if (sourceFiles[i].isDirectory()) { |
1480 |
|
File targetSubDir = new File(targetDir, |
1481 |
|
sourceFiles[i].getName()); |
1482 |
|
if (targetSubDir.exists() || targetSubDir.mkdir()) { |
1483 |
|
copyDirectory(sourceFiles[i], targetSubDir); |
1484 |
|
} |
1485 |
|
else { |
1486 |
|
throw new IOException("Cannot create directory " + targetSubDir); |
1487 |
|
} |
1488 |
|
} |
1489 |
|
else { |
1490 |
|
copyFile(sourceFiles[i], new File(targetDir, sourceFiles[i].getName())); |
1491 |
|
} |
1492 |
|
} |
1493 |
|
} |
1494 |
|
|
1495 |
|
/** |
1496 |
|
* Copy the contents of the input file to the output file. The |
1497 |
|
* output file's parent directory must exist. |
1498 |
|
*/ |
1499 |
|
private static void copyFile(File sourceFile, File targetFile) throws IOException { |
1500 |
|
|
1501 |
|
InputStream in = new FileInputStream(sourceFile); |
1502 |
|
OutputStream out = new FileOutputStream(targetFile); |
1503 |
|
int nread; |
1504 |
|
byte[] buf = new byte[512]; |
1505 |
|
while ((nread = in.read(buf)) >= 0) { |
1506 |
|
out.write(buf, 0, nread); |
1507 |
|
} |
1508 |
|
in.close(); |
1509 |
|
out.close(); |
1510 |
|
} |
1511 |
} |
} |