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.

PDFAMode.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.pdf;
  19. /** Enum class for PDF/A modes. */
  20. public final class PDFAMode {
  21. /** PDF/A disabled */
  22. public static final PDFAMode DISABLED = new PDFAMode("PDF/A disabled");
  23. /** PDF/A-1a enabled */
  24. public static final PDFAMode PDFA_1A = new PDFAMode("PDF/A-1a");
  25. /** PDF/A-1b enabled */
  26. public static final PDFAMode PDFA_1B = new PDFAMode("PDF/A-1b");
  27. private String name;
  28. /**
  29. * Constructor to add a new named item.
  30. * @param name Name of the item.
  31. */
  32. private PDFAMode(String name) {
  33. this.name = name;
  34. }
  35. /** @return the name of the enum */
  36. public String getName() {
  37. return this.name;
  38. }
  39. /**
  40. * Indicates whether this mode obeys the restrictions established by PDF/A-1a.
  41. * @return true if this mode obeys the restrictions established by PDF/A-1a.
  42. */
  43. public boolean isPDFA1LevelA() {
  44. return (this != DISABLED);
  45. }
  46. /**
  47. * Indicates whether this mode obeys the restrictions established by PDF/A-1b.
  48. * @return true if this mode obeys the restrictions established by PDF/A-1b.
  49. */
  50. public boolean isPDFA1LevelB() {
  51. return (this != DISABLED);
  52. //PDF/A-1a is a superset of PDF/A-1b!
  53. }
  54. /**
  55. * Returns the mode enum object given a String.
  56. * @param s the string
  57. * @return the PDFAMode enum object (DISABLED will be returned if no match is found)
  58. */
  59. public static PDFAMode valueOf(String s) {
  60. if (PDFA_1A.getName().equalsIgnoreCase(s)) {
  61. return PDFA_1A;
  62. } else if (PDFA_1B.getName().equalsIgnoreCase(s)) {
  63. return PDFA_1B;
  64. } else {
  65. return DISABLED;
  66. }
  67. }
  68. /** {@inheritDoc} */
  69. public String toString() {
  70. return name;
  71. }
  72. }