Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at You can also obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 package org.odftoolkit.simple;
Provides meta data about the Simple ODF library as build date, version number. Its main() method is the start method of the library, enabling the access of version methods from command line: "java -jar simple-odf.jar".
 public class JarManifest {
 	private static final String CURRENT_CLASS_RESOURCE_PATH = "org/odftoolkit/simple/JarManifest.class";
 	private static final String MANIFEST_JAR_PATH = "META-INF/MANIFEST.MF";
 	private static String SIMPLE_ODF_NAME;
 	private static String SIMPLE_ODF_VERSION;
 	private static String SIMPLE_ODF_WEBSITE;
 	private static String SIMPLE_ODF_BUILD_BY;
 	private static String SIMPLE_ODF_BUILD_DATE;
 	static {
 		try {
 			Manifest manifest = new Manifest(getManifestAsStream());
 			Attributes attr = manifest.getEntries().get("SIMPLE-ODF");
 			 = attr.getValue("SIMPLE-ODF-Name");
 			 = attr.getValue("SIMPLE-ODF-Version");
 			 = attr.getValue("SIMPLE-ODF-Website");
 			 = attr.getValue("SIMPLE-ODF-Built-By");
 			 = attr.getValue("SIMPLE-ODF-Built-Date");
 			 = attr.getValue("SIMPLE-ODF-Supported-ODF-Version");
 		} catch (Exception e) {
 	private static InputStream getManifestAsStream() {
 		String versionRef = JarManifest.class.getClassLoader().getResource(
 		String manifestRef = versionRef.substring(0, versionRef
 		URL manifestURL = null;
 		InputStream in = null;
 		try {
 			manifestURL = new URL(manifestRef);
 		} catch (MalformedURLException ex) {
 		try {
 			in = manifestURL.openStream();
 		} catch (IOException ex) {
 		return in;
 	private JarManifest() {

The main method is meant to be called when the JAR is being executed, e.g. "java -jar simple-odf.jar" and provides version information: simple-odf 0.3 (build 20110201-1729) from supporting ODF 1.2 Allowing version access from the JAR without the need to unzip the JAR nor naming the JAR (requiring the change of class path for every version due to JAR naming change).
	public static void main(String[] argsthrows IOException {
getSimpleOdfBuildDate() + ')' + "\nfrom "
getSimpleOdfWebsite() + " supporting ODF "

Return the name of Simple ODF;

the Simple ODF library name
	public static String getSimpleOdfName() {

Returns the Simple ODF library title

A string containing both the name and the version of the Simple ODF library.
	public static String getSimpleOdfTitle() {
		return getSimpleOdfName() + ' ' + getSimpleOdfVersion();

Return the version of the Simple ODF library (ie. simple-odf.jar)

the Simple ODF library version
	public static String getSimpleOdfVersion() {

Return the website of the Simple ODF library (ie. simple-odf.jar)

the Simple ODF library website
	public static String getSimpleOdfWebsite() {

Return the name of the one building the Simple ODF library (ie. simple-odf.jar)

the name of the Simple ODF library builder

Return the date when Simple ODF had been build

the date of the build
	public static String getSimpleOdfBuildDate() {

Returns the version of the OpenDocument specification covered by the Simple ODF library (ie. simple-odf.jar)

the supported ODF version number
New to GrepCode? Check out our FAQ X