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.

CommonAccessibility.java 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.fo.properties;
  19. import org.apache.fop.fo.Constants;
  20. import org.apache.fop.fo.PropertyList;
  21. import org.apache.fop.fo.expr.PropertyException;
  22. /**
  23. * The "role" and "source-document" properties, see Section 7.5 of the XSL-FO 1.1
  24. * Recommendation.
  25. */
  26. public final class CommonAccessibility {
  27. private static final CommonAccessibility DEFAULT_INSTANCE = new CommonAccessibility(null, null);
  28. private final String sourceDocument;
  29. private final String role;
  30. private CommonAccessibility(String sourceDocument, String role) {
  31. this.sourceDocument = sourceDocument;
  32. this.role = role;
  33. }
  34. /**
  35. * Returns an instance that matches the values (if any) in the given property list.
  36. *
  37. * @param propertyList a list from which to retrieve the accessibility properties
  38. * @return the corresponding instance
  39. * @throws PropertyException if a problem occurs while retrieving the properties
  40. */
  41. public static CommonAccessibility getInstance(PropertyList propertyList)
  42. throws PropertyException {
  43. String sourceDocument = propertyList.get(Constants.PR_SOURCE_DOCUMENT).getString();
  44. if ("none".equals(sourceDocument)) {
  45. sourceDocument = null;
  46. }
  47. String role = propertyList.get(Constants.PR_ROLE).getString();
  48. if ("none".equals(role)) {
  49. role = null;
  50. }
  51. if (sourceDocument == null && role == null) {
  52. return DEFAULT_INSTANCE;
  53. } else {
  54. return new CommonAccessibility(sourceDocument, role);
  55. }
  56. }
  57. /**
  58. * Returns the value of the source-document property.
  59. *
  60. * @return the source document, or null if the property was set to "none"
  61. */
  62. public String getSourceDocument() {
  63. return sourceDocument;
  64. }
  65. /**
  66. * Returns the value of the role property.
  67. *
  68. * @return the role, or null if the property was set to "none"
  69. */
  70. public String getRole() {
  71. return role;
  72. }
  73. }