From 7e94b283b4b60d85c6fc7b108d886327e7e94280 Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Sun, 30 May 2004 06:20:44 +0000 Subject: [PATCH] Added getInitialValue() and constructor with initial value git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197664 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/fo/properties/Country.java | 24 ++++++++++++++++++- .../apache/fop/fo/properties/Language.java | 24 ++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/fop/fo/properties/Country.java b/src/java/org/apache/fop/fo/properties/Country.java index c69f1831a..b1f6ab726 100644 --- a/src/java/org/apache/fop/fo/properties/Country.java +++ b/src/java/org/apache/fop/fo/properties/Country.java @@ -20,6 +20,13 @@ */ package org.apache.fop.fo.properties; +import java.util.Locale; + +import org.apache.fop.datatypes.CountryType; +import org.apache.fop.datatypes.PropertyValue; +import org.apache.fop.fo.PropNames; +import org.apache.fop.fo.expr.PropertyException; + public class Country extends Property { public static final int dataTypes = COUNTRY_T | NONE | INHERIT; @@ -34,7 +41,7 @@ public class Country extends Property { return traitMapping; } - public static final int initialValueType = NONE_IT; + public static final int initialValueType = COUNTRY_IT; public int getInitialValueType() { return initialValueType; @@ -46,5 +53,20 @@ public class Country extends Property { return inherited; } + private CountryType initialValue; + + public PropertyValue getInitialValue(int propindex) + throws PropertyException { + if (propindex != PropNames.COUNTRY) { + throw new PropertyException( + "Called in Country with property other than 'country'"); + } + return initialValue; + } + + public Country() throws PropertyException { + initialValue = new CountryType( + PropNames.COUNTRY, Locale.getDefault().getCountry()); + } } diff --git a/src/java/org/apache/fop/fo/properties/Language.java b/src/java/org/apache/fop/fo/properties/Language.java index 63d3659ad..a996c5fbb 100644 --- a/src/java/org/apache/fop/fo/properties/Language.java +++ b/src/java/org/apache/fop/fo/properties/Language.java @@ -20,6 +20,13 @@ */ package org.apache.fop.fo.properties; +import java.util.Locale; + +import org.apache.fop.datatypes.LanguageType; +import org.apache.fop.datatypes.PropertyValue; +import org.apache.fop.fo.PropNames; +import org.apache.fop.fo.expr.PropertyException; + public class Language extends Property { public static final int dataTypes = LANGUAGE_T | NONE | INHERIT; @@ -34,7 +41,7 @@ public class Language extends Property { return traitMapping; } - public static final int initialValueType = NONE_IT; + public static final int initialValueType = LANGUAGE_IT; public int getInitialValueType() { return initialValueType; @@ -45,6 +52,21 @@ public class Language extends Property { public int getInherited() { return inherited; } + private LanguageType initialValue; + + public PropertyValue getInitialValue(int propindex) + throws PropertyException { + if (propindex != PropNames.COUNTRY) { + throw new PropertyException( + "Called in Language with property other than 'language'"); + } + return initialValue; + } + + public Language() throws PropertyException { + initialValue = new LanguageType( + PropNames.COUNTRY, Locale.getDefault().getLanguage()); + } } -- 2.39.5