Fields Summary |
---|
public static final String | ATTRIBUTE_MANIFEST_VERSIONThe standard manifest version header |
public static final String | ATTRIBUTE_SIGNATURE_VERSIONThe standard Signature Version header |
public static final String | ATTRIBUTE_NAMEThe Name Attribute is the first in a named section |
public static final String | ATTRIBUTE_FROMThe From Header is disallowed in a Manifest |
public static final String | ATTRIBUTE_CLASSPATHThe Class-Path Header is special - it can be duplicated |
public static final String | DEFAULT_MANIFEST_VERSIONDefault Manifest version if one is not specified |
public static final int | MAX_LINE_LENGTHThe max length of a line in a Manifest |
public static final int | MAX_SECTION_LENGTHMax length of a line section which is continued. Need to allow
for the CRLF. |
public static final String | EOLThe End-Of-Line marker in manifests |
public static final String | ERROR_FROM_FORBIDDENError for attributes |
public static final String | JAR_ENCODINGEncoding to be used for JAR files. |
private String | manifestVersionThe version of this manifest |
private Section | mainSectionThe main section of this manifest |
private Hashtable | sectionsThe named sections of this manifest |
private Vector | sectionIndexIndex of sections - used to retain order of sections in manifest |
Methods Summary |
---|
public void | addConfiguredAttribute(org.apache.tools.ant.taskdefs.Manifest$Attribute attribute)Add an attribute to the manifest - it is added to the main section.
if (attribute.getKey() == null || attribute.getValue() == null) {
throw new BuildException("Attributes must have name and value");
}
if (attribute.getKey().equalsIgnoreCase(ATTRIBUTE_MANIFEST_VERSION)) {
manifestVersion = attribute.getValue();
} else {
mainSection.addConfiguredAttribute(attribute);
}
|
public void | addConfiguredSection(org.apache.tools.ant.taskdefs.Manifest$Section section)Add a section to the manifest
String sectionName = section.getName();
if (sectionName == null) {
throw new BuildException("Sections must have a name");
}
sections.put(sectionName, section);
if (!sectionIndex.contains(sectionName)) {
sectionIndex.addElement(sectionName);
}
|
public boolean | equals(java.lang.Object rhs)
if (rhs == null || rhs.getClass() != getClass()) {
return false;
}
if (rhs == this) {
return true;
}
Manifest rhsManifest = (Manifest) rhs;
if (manifestVersion == null) {
if (rhsManifest.manifestVersion != null) {
return false;
}
} else if (!manifestVersion.equals(rhsManifest.manifestVersion)) {
return false;
}
if (!mainSection.equals(rhsManifest.mainSection)) {
return false;
}
return sections.equals(rhsManifest.sections);
|
public static org.apache.tools.ant.taskdefs.Manifest | getDefaultManifest()Construct a manifest from Ant's default manifest file.
InputStream in = null;
InputStreamReader insr = null;
try {
String defManifest = "/org/apache/tools/ant/defaultManifest.mf";
in = Manifest.class.getResourceAsStream(defManifest);
if (in == null) {
throw new BuildException("Could not find default manifest: "
+ defManifest);
}
try {
insr = new InputStreamReader(in, "UTF-8");
Manifest defaultManifest = new Manifest(insr);
Attribute createdBy = new Attribute("Created-By",
System.getProperty("java.vm.version") + " ("
+ System.getProperty("java.vm.vendor") + ")");
defaultManifest.getMainSection().storeAttribute(createdBy);
return defaultManifest;
} catch (UnsupportedEncodingException e) {
insr = new InputStreamReader(in);
return new Manifest(insr);
}
} catch (ManifestException e) {
throw new BuildException("Default manifest is invalid !!", e);
} catch (IOException e) {
throw new BuildException("Unable to read default manifest", e);
} finally {
FileUtils.close(insr);
FileUtils.close(in);
}
|
public org.apache.tools.ant.taskdefs.Manifest$Section | getMainSection()Get the main section of the manifest
return mainSection;
|
public java.lang.String | getManifestVersion()Get the version of the manifest
return manifestVersion;
|
public org.apache.tools.ant.taskdefs.Manifest$Section | getSection(java.lang.String name)Get a particular section from the manifest
return (Section) sections.get(name);
|
public java.util.Enumeration | getSectionNames()Get the section names in this manifest.
return sectionIndex.elements();
|
public java.util.Enumeration | getWarnings()Get the warnings for this manifest.
Vector warnings = new Vector();
Enumeration warnEnum = mainSection.getWarnings();
while (warnEnum.hasMoreElements()) {
warnings.addElement(warnEnum.nextElement());
}
// create a vector and add in the warnings for all the sections
Enumeration e = sections.elements();
while (e.hasMoreElements()) {
Section section = (Section) e.nextElement();
Enumeration e2 = section.getWarnings();
while (e2.hasMoreElements()) {
warnings.addElement(e2.nextElement());
}
}
return warnings.elements();
|
public int | hashCode()
int hashCode = 0;
if (manifestVersion != null) {
hashCode += manifestVersion.hashCode();
}
hashCode += mainSection.hashCode();
hashCode += sections.hashCode();
return hashCode;
|
public void | merge(org.apache.tools.ant.taskdefs.Manifest other)Merge the contents of the given manifest into this manifest
merge(other, false);
|
public void | merge(org.apache.tools.ant.taskdefs.Manifest other, boolean overwriteMain)Merge the contents of the given manifest into this manifest
if (other != null) {
if (overwriteMain) {
mainSection = (Section) other.mainSection.clone();
} else {
mainSection.merge(other.mainSection);
}
if (other.manifestVersion != null) {
manifestVersion = other.manifestVersion;
}
Enumeration e = other.getSectionNames();
while (e.hasMoreElements()) {
String sectionName = (String) e.nextElement();
Section ourSection = (Section) sections.get(sectionName);
Section otherSection
= (Section) other.sections.get(sectionName);
if (ourSection == null) {
if (otherSection != null) {
addConfiguredSection((Section) otherSection.clone());
}
} else {
ourSection.merge(otherSection);
}
}
}
|
public java.lang.String | toString()Convert the manifest to its string representation
StringWriter sw = new StringWriter();
try {
write(new PrintWriter(sw));
} catch (IOException e) {
return null;
}
return sw.toString();
|
public void | write(java.io.PrintWriter writer)Write the manifest out to a print writer.
writer.print(ATTRIBUTE_MANIFEST_VERSION + ": " + manifestVersion + EOL);
String signatureVersion
= mainSection.getAttributeValue(ATTRIBUTE_SIGNATURE_VERSION);
if (signatureVersion != null) {
writer.print(ATTRIBUTE_SIGNATURE_VERSION + ": "
+ signatureVersion + EOL);
mainSection.removeAttribute(ATTRIBUTE_SIGNATURE_VERSION);
}
mainSection.write(writer);
// add it back
if (signatureVersion != null) {
try {
Attribute svAttr = new Attribute(ATTRIBUTE_SIGNATURE_VERSION,
signatureVersion);
mainSection.addConfiguredAttribute(svAttr);
} catch (ManifestException e) {
// shouldn't happen - ignore
}
}
Enumeration e = sectionIndex.elements();
while (e.hasMoreElements()) {
String sectionName = (String) e.nextElement();
Section section = getSection(sectionName);
section.write(writer);
}
|