All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.odftoolkit.odfdom.dom.OdfSchemaConstraint Maven / Gradle / Ivy

Go to download

ODFDOM is an OpenDocument Format (ODF) framework. Its purpose is to provide an easy common way to create, access and manipulate ODF files, without requiring detailed knowledge of the ODF specification. It is designed to provide the ODF developer community with an easy lightwork programming API portable to any object-oriented language. The current reference implementation is written in Java.

There is a newer version: 0.8.11-incubating
Show newest version
/************************************************************************
 *
 * 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 http://www.apache.org/licenses/LICENSE-2.0. You can also
 * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
 * 
 * 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.odfdom.dom;

import org.odftoolkit.odfdom.pkg.ValidationConstraint;

/**
 * This class is used for validation of the ODF Document.
 * It contains the constraint messages are taken from the OASIS ODF 1.2 part 1, the XML Schema specification.
 * These messages are used by the ValidationException for ODF validation.
 * The validation is enabled, when an ErrorHandler was provided to the OdfPackage.
 */
public enum OdfSchemaConstraint implements ValidationConstraint {

	// NOTE FOLLOWING CODE CONVENTION:
	// The first parameter is ALWAYS the source path, followed by a missing space. The OdfValidationException will take care of adjusting.
	/** A ODF mimetype is invalid for the ODF XML Schema document. */
	DOCUMENT_WITHOUT_ODF_MIMETYPE("The ODF mimetype '%2$s' is invalid for the ODF XML Schema document%1$s!"),
	/** At least \'content.xml' or 'styles.xml' have to be contained in the ODF XML Schema package.*/
	DOCUMENT_WITHOUT_CONTENT_NOR_STYLES_XML("At least 'content.xml' or 'styles.xml' have to be contained in the ODF XML Schema package%1$s!"),
	/** The 'mimetype' file have to be contained in the ODF XML Schema package.*/
	PACKAGE_SHALL_CONTAIN_MIMETYPE("The 'mimetype' file have to be contained in the ODF XML Schema package%1$s!");

	private final String mMessage;

	/**
	 * Creates a ODF Document constraint
	 * @param message of the constraint */
	OdfSchemaConstraint(String message) {
		mMessage = message;
	}

	/**
	 * Creates a localized description of a Constraint.
	 * Subclasses may override this method in order to produce a
	 * locale-specific message.  For subclasses that do not override this
	 * method, the default implementation returns the same result as
	 * getMessage().
	 *
	 * @return  The localized description of this constraint. */
	public String getLocalizedMessage() {
//    FUTURE FEATUE: LOCALIZATION:
//    =============================
//    There should be a property files e.g. OdfPackageConstraint_de_DE.properties Sourcecode:
//    PACKAGE_SHALL_BE_ZIP=%s muß eine ZIP Datei sein, wie in [ZIP] definiert. Alle Dateien innerhalbe des ZIPS müssen entwder unkomprimiert (STORED) oder komprimiert sein (DEFLATED) und den DEFLATE aloritmus verwenden.
//    PACKAGE_SHALL_CONTAIN_MANIFEST=.....
//    ResourceBundle bundle = ResourceBundle.getBundle(OdfPackageConstraint.class.getName());
//    return bundle.getString(this.name());
		return mMessage;
	}

	/**
	 * Returns the detail message string of this Constraint.
	 *
	 * @return  the detail message string of this Constraint instance
	 *          (which may be null).
	 */
	public String getMessage() {
		return mMessage;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy