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.

PDFUAMode.java 2.2KB

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.pdf;
  19. /** Enum class for PDF/UA modes. */
  20. public enum PDFUAMode {
  21. /** PDF/UA disabled. */
  22. DISABLED("PDF/UA disabled"),
  23. /** PDF/UA-1 enabled. */
  24. PDFUA_1(1);
  25. private final String name;
  26. private final int part;
  27. /**
  28. * Constructor to add a new named item.
  29. * @param name Name of the item.
  30. */
  31. private PDFUAMode(String name) {
  32. this.name = name;
  33. this.part = 0;
  34. }
  35. private PDFUAMode(int part) {
  36. this.name = "PDF/UA-" + part;
  37. this.part = part;
  38. }
  39. /** @return the name of the enum */
  40. public String getName() {
  41. return this.name;
  42. }
  43. public int getPart() {
  44. return part;
  45. }
  46. /**
  47. * Returns {@code true} if this enum corresponds to one of the available PDF/A modes.
  48. *
  49. * @return {@code true} if this is not DISABLED
  50. */
  51. public boolean isEnabled() {
  52. return this != DISABLED;
  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 PDFUAMode getValueOf(String s) {
  60. for (PDFUAMode mode : values()) {
  61. if (mode.name.equalsIgnoreCase(s)) {
  62. return mode;
  63. }
  64. }
  65. return DISABLED;
  66. }
  67. /** {@inheritDoc} */
  68. public String toString() {
  69. return name;
  70. }
  71. }