Package org.eclipse.xtext.util
Class MergeableManifest2
- java.lang.Object
-
- org.eclipse.xtext.util.MergeableManifest2
-
- All Implemented Interfaces:
java.lang.Cloneable
public class MergeableManifest2 extends java.lang.Object implements java.lang.CloneableFunctionality to read and write Manifest files. Guarantees that modifying does not destroy the order of the elements to ensure minimal diffs for load/save cycles. Re-implementation fromMergeableManifestbut without reflection. Reflection causes warnings that it might get be removed in future versions. Hence we implement the functionality with all the inherited one by ourself.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classMergeableManifest2.AttributesA map that updates the "modified" state of the owningMergeableManifest2.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBUNDLE_ACTIVATORstatic java.lang.StringBUNDLE_REQUIREDEXECUTIONENVIRONMENTstatic java.lang.StringBUNDLE_SYMBOLIC_NAMEstatic java.lang.StringEXPORT_PACKAGEstatic java.lang.StringIMPORT_PACKAGEstatic java.lang.StringMANIFEST_VERSIONstatic java.lang.StringREQUIRE_BUNDLEstatic java.lang.StringSIGNATURE_VERSION
-
Constructor Summary
Constructors Constructor Description MergeableManifest2(java.io.InputStream stream)Create a new manifest from the given stream.MergeableManifest2(java.io.InputStream stream, java.lang.String name)Create a new manifest from the given stream and with the given name.MergeableManifest2(MergeableManifest2 toCopy)Create a copy from the given one.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExportedPackages(java.lang.String... exportedPackages)Add the list with given bundles to the "Export-Package" main attribute.voidaddExportedPackages(java.util.Set<java.lang.String> exportedPackages)Add the set with given bundles to the "Export-Package" main attribute.voidaddImportedPackages(java.lang.String... importedPackages)Add the list with given bundles to the "Import-Package" main attribute.voidaddImportedPackages(java.util.Set<java.lang.String> importedPackages)Add the set with given bundles to the "Import-Package" main attribute.voidaddRequiredBundles(java.lang.String... requiredBundles)Add the list with given bundles to the "Require-Bundle" main attribute.voidaddRequiredBundles(java.util.Set<java.lang.String> requiredBundles)Add the set with given bundles to the "Require-Bundle" main attribute.voidclear()Remove all main entries and all section entries.MergeableManifest2clone()booleanequals(java.lang.Object obj)MergeableManifest2.AttributesgetAttributes(java.lang.String name)java.lang.StringgetBREE()java.lang.StringgetBundleActivator()java.util.Map<java.lang.String,MergeableManifest2.Attributes>getEntries()MergeableManifest2.AttributesgetMainAttributes()inthashCode()booleanisModified()static java.lang.Stringmake512Safe(java.lang.StringBuffer input, java.lang.String newline)Return a string that ensures that no line is longer then 512 characters and lines are broken according to manifest specification.voidsetBREE(java.lang.String bree)Set the main attribute "Bundle-RequiredExecutionEnvironment" to the given value.voidsetBundleActivator(java.lang.String bundleActivator)Set the main attribute "Bundle-Activator" to the given value.voidsetLineDelimiter(java.lang.String lineDelimeter)Set the line delimiter to a specific value.voidwrite(java.io.OutputStream stream)Write the contents to the manifest to the given stream.
-
-
-
Field Detail
-
MANIFEST_VERSION
public static final java.lang.String MANIFEST_VERSION
- See Also:
- Constant Field Values
-
SIGNATURE_VERSION
public static final java.lang.String SIGNATURE_VERSION
- See Also:
- Constant Field Values
-
REQUIRE_BUNDLE
public static final java.lang.String REQUIRE_BUNDLE
- See Also:
- Constant Field Values
-
BUNDLE_SYMBOLIC_NAME
public static final java.lang.String BUNDLE_SYMBOLIC_NAME
- See Also:
- Constant Field Values
-
EXPORT_PACKAGE
public static final java.lang.String EXPORT_PACKAGE
- See Also:
- Constant Field Values
-
IMPORT_PACKAGE
public static final java.lang.String IMPORT_PACKAGE
- See Also:
- Constant Field Values
-
BUNDLE_REQUIREDEXECUTIONENVIRONMENT
public static final java.lang.String BUNDLE_REQUIREDEXECUTIONENVIRONMENT
- See Also:
- Constant Field Values
-
BUNDLE_ACTIVATOR
public static final java.lang.String BUNDLE_ACTIVATOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MergeableManifest2
public MergeableManifest2(java.io.InputStream stream, java.lang.String name) throws java.io.IOExceptionCreate a new manifest from the given stream and with the given name. As the stream is created by the caller the caller is also responsible for closing it.- Parameters:
stream- The stream to read the manifest content from.name- The name of the manifest, written to "Bundle-SymbolicName".- Throws:
java.io.IOException
-
MergeableManifest2
public MergeableManifest2(java.io.InputStream stream) throws java.io.IOExceptionCreate a new manifest from the given stream. As the stream is created by the caller the caller is also responsible for closing it.- Parameters:
stream- The stream to read the manifest content from.- Throws:
java.io.IOException
-
MergeableManifest2
public MergeableManifest2(MergeableManifest2 toCopy)
Create a copy from the given one.- Parameters:
toCopy- The original manifest to copy.
-
-
Method Detail
-
getMainAttributes
public MergeableManifest2.Attributes getMainAttributes()
- Returns:
- the attributes read from the header. Does not include the entries that are started with "Name: [...]" line.
-
getAttributes
public MergeableManifest2.Attributes getAttributes(java.lang.String name)
- Returns:
- the attribute section that has been started with the name from the "Name: [...]" line.
-
getEntries
public java.util.Map<java.lang.String,MergeableManifest2.Attributes> getEntries()
- Returns:
- all entries started with "Name: [...]" line but not the main attributes.
-
isModified
public boolean isModified()
- Returns:
- true in case any modification has been applied to the manifest since it was read.
-
clear
public void clear()
Remove all main entries and all section entries.
-
addRequiredBundles
public void addRequiredBundles(java.util.Set<java.lang.String> requiredBundles)
Add the set with given bundles to the "Require-Bundle" main attribute.- Parameters:
requiredBundles- The set with all bundles to add.
-
addRequiredBundles
public void addRequiredBundles(java.lang.String... requiredBundles)
Add the list with given bundles to the "Require-Bundle" main attribute.- Parameters:
requiredBundles- The list of all bundles to add.
-
addImportedPackages
public void addImportedPackages(java.util.Set<java.lang.String> importedPackages)
Add the set with given bundles to the "Import-Package" main attribute.- Parameters:
importedPackages- The set of all packages to add.
-
addImportedPackages
public void addImportedPackages(java.lang.String... importedPackages)
Add the list with given bundles to the "Import-Package" main attribute.- Parameters:
importedPackages- The list of all packages to add.
-
addExportedPackages
public void addExportedPackages(java.util.Set<java.lang.String> exportedPackages)
Add the set with given bundles to the "Export-Package" main attribute.- Parameters:
exportedPackages- The set of all packages to add.
-
addExportedPackages
public void addExportedPackages(java.lang.String... exportedPackages)
Add the list with given bundles to the "Export-Package" main attribute.- Parameters:
exportedPackages- The list of all packages to add.
-
setBREE
public void setBREE(java.lang.String bree)
Set the main attribute "Bundle-RequiredExecutionEnvironment" to the given value.- Parameters:
bree- The new value
-
getBREE
public java.lang.String getBREE()
- Returns:
- the value of the main attribute "Bundle-RequiredExecutionEnvironment".
-
setBundleActivator
public void setBundleActivator(java.lang.String bundleActivator)
Set the main attribute "Bundle-Activator" to the given value.- Parameters:
bundleActivator- The new value
-
getBundleActivator
public java.lang.String getBundleActivator()
- Returns:
- the value of the main attribute "Bundle-Activator".
-
setLineDelimiter
public void setLineDelimiter(java.lang.String lineDelimeter)
Set the line delimiter to a specific value. Is only used for writing, NOT for reading!- Parameters:
lineDelimeter- typically either "\n" or "\r\n".
-
write
public void write(java.io.OutputStream stream) throws java.io.IOExceptionWrite the contents to the manifest to the given stream. As the stream is created by the caller the caller is also responsible for closing it.- Parameters:
stream- the stream to write the output to.- Throws:
java.io.IOException
-
clone
public MergeableManifest2 clone() throws java.lang.CloneNotSupportedException
- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
make512Safe
public static java.lang.String make512Safe(java.lang.StringBuffer input, java.lang.String newline)Return a string that ensures that no line is longer then 512 characters and lines are broken according to manifest specification.- Parameters:
input- The buffer containing the content that should be made safenewline- The string to use to create newlines (usually "\n" or "\r\n")- Returns:
- The string with no longer lines then 512, ready to be read again
by
MergeableManifest2.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-