Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER Copyright 2011 IBM. 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.simple.common.field;
 
This is a tool class to help the user creating all kinds of fields as needed.

 
 public class Fields {

Create an automatically update date field for the specific OdfElement, which displays current date.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created date field.
 
 	public static DateField createDateField(OdfElement odfElement) {
 		DateField dateField = new DateField(odfElement);
 		dateField.setFixed(false);
 		return dateField;
 	}

Create a fixed date field for the specific OdfElement, which displays the field created date.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created date field.
 
 	public static DateField createFixedDateField(OdfElement odfElement) {
 		return new DateField(odfElement);
 	}

Create an automatically update time field for the specific OdfElement, which displays current time.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created time field.
 
 	public static TimeField createTimeField(OdfElement odfElement) {
 		TimeField timeField = new TimeField(odfElement);
 		timeField.setFixed(false);
 		return timeField;
 	}

Create a fixed time field for the specific OdfElement, which displays the field created time.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created time field.
 
 	public static TimeField createFixedTimeField(OdfElement odfElement) {
 		return new TimeField(odfElement);
 	}

Create a page number field for the specific OdfElement, which displays previous page number.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created page number field.
 
 	public static PageNumberField createPreviousPageNumberField(OdfElement odfElement) {
 		PageNumberField pageNumberField = new PageNumberField(odfElement);
 		return pageNumberField;
	}

Create a page number field for the specific OdfElement, which displays current page number.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created page number field.
		return new PageNumberField(odfElement);
	}

Create a page number field for the specific OdfElement, which displays next page number.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created page number field.
	public static PageNumberField createNextPageNumberField(OdfElement odfElement) {
		PageNumberField pageNumberField = new PageNumberField(odfElement);
		return pageNumberField;
	}

Create a page count field for the specific OdfElement, which displays page total count of this document.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created page count field.
	public static PageCountField createPageCountField(OdfElement odfElement) {
		return new PageCountField(odfElement);
	}

Create a title field for the specific OdfElement, which displays title data of this document.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created title field.
	public static TitleField createTitleField(OdfElement odfElement) {
		return new TitleField(odfElement);
	}

Create a subject field for the specific OdfElement, which displays the subject data of this document.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created author field.
	public static SubjectField createSubjectField(OdfElement odfElement) {
		return new SubjectField(odfElement);
	}

Create an author field for the specific OdfElement, which displays author full name of this document.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created author field.
	public static AuthorField createAuthorNameField(OdfElement odfElement) {
		return new AuthorField(odfElementfalse);
	}

Create an author field for the specific OdfElement, which displays the initials of the author of this document.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created author field.
	public static AuthorField createAuthorInitialsField(OdfElement odfElement) {
		return new AuthorField(odfElementtrue);
	}

Create a chapter field for the specific OdfElement.

Parameters:
odfElement the OdfElement which owns this field.
Returns:
the created chapter field.
	public static ChapterField createChapterField(OdfElement odfElement) {
		return new ChapterField(odfElement);
	}

Create a ReferenceField for the specific OdfElement.

Parameters:
odfElement the OdfElement which owns this field.
referenceName the reference field name.
Returns:
the created reference field.
	public static ReferenceField createReferenceField(OdfElement odfElementString referenceName) {
		return new ReferenceField(odfElementreferenceName);
	}

Declare a simple variable field. Simple variables, can take different values at different positions throughout a document.

Simple variables can be used to display different text in recurring elements, such as headers or footers.

Parameters:
container the container which this variable field is contained.
name the name of this variable field.
Returns:
the created variable field.
	public static VariableField createSimpleVariableField(VariableContainer containerString name) {
		return new VariableField(containername.);
	}

Declare a user variable field. User variables have the same value throughout a document. If a user variable is set anywhere within the document, all fields in the document that display the user variable have the same value.

Parameters:
container the container which this variable field is contained.
name the name of this variable field.
value the initial value of this variable field.
Returns:
the created variable field.
	public static VariableField createUserVariableField(VariableContainer containerString nameString value) {
		VariableField field = new VariableField(containername.);
		field.updateField(value, (OdfElementnull);
		return field;
	}

Declare a condition field, which specifies a condition for display of one text string or another. If the condition is true, one of the text strings is displayed. If the condition is false, the other text string is displayed.

Parameters:
odfElement the OdfElement which owns this field.
condition the condition that determines which of the two text strings is displayed.
trueText the text string to display if a condition is true.
falseText the text string to display if a condition is false.
Returns:
the created condition field.
	public static ConditionField createConditionField(OdfElement odfElementString conditionString trueText,
			String falseText) {
		return new ConditionField(odfElementconditiontrueTextfalseTextfalse);
	}

Declare a hidden text field, which hides the text it contains when a specified condition is true.

Parameters:
odfElement the OdfElement which owns this field.
condition the condition that determines whether the text string is displayed or not.
text the text string to display.
Returns:
the created condition field.
	public static ConditionField createHiddenTextField(OdfElement odfElementString conditionString text) {
		return new ConditionField(odfElementconditionnulltexttrue);
	}
	// private constructor, cannot instantiate.
	private Fields() {
	};
New to GrepCode? Check out our FAQ X