You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CountryType.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * $Id$
  3. *
  4. *
  5. * Copyright 1999-2003 The Apache Software Foundation.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. *
  20. * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
  21. * @version $Revision$ $Name$
  22. */
  23. package org.apache.fop.datatypes;
  24. import org.apache.fop.fo.PropNames;
  25. import org.apache.fop.fo.expr.PropertyException;
  26. import org.apache.fop.fo.properties.Property;
  27. /**
  28. * A class for <tt>country</tt> specifiers.
  29. */
  30. public class CountryType extends NCName {
  31. private static final String tag = "$Name$";
  32. private static final String revision = "$Revision$";
  33. public CountryType(int property, String countryCode)
  34. throws PropertyException
  35. {
  36. super(property, countryCode, PropertyValue.COUNTRY);
  37. // Validate the code
  38. String code;
  39. if ((code = CountryLanguageScript.canonicalCountryCode(countryCode))
  40. == null)
  41. throw new PropertyException
  42. ("Invalid country code: " + countryCode);
  43. setString(code);
  44. }
  45. public CountryType(String propertyName, String countryCode)
  46. throws PropertyException
  47. {
  48. this(PropNames.getPropertyIndex(propertyName), countryCode);
  49. }
  50. /**
  51. * @return the <tt>String</tt> country code.
  52. */
  53. public String getCountry() {
  54. return string;
  55. }
  56. /**
  57. * Validate the <i>CountryType</i> against the associated property.
  58. */
  59. public void validate() throws PropertyException {
  60. super.validate(Property.COUNTRY_T);
  61. }
  62. }