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.

Version.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. /**
  20. * A version of PDF. Values are ordered such that compareTo() gives sensible
  21. * results (e.g., {@code V1_4.compareTo(V1_5) < 0}).
  22. */
  23. public enum Version {
  24. /** PDF v1 */
  25. V1_0("1.0"),
  26. /** PDF v1.1 */
  27. V1_1("1.1"),
  28. /** PDF v1.2 */
  29. V1_2("1.2"),
  30. /** PDF v1.3 */
  31. V1_3("1.3"),
  32. /** PDF v1.4 */
  33. V1_4("1.4"),
  34. /** PDF v1.5 */
  35. V1_5("1.5"),
  36. /** PDF v1.6 */
  37. V1_6("1.6"),
  38. /** PDF v1.7 */
  39. V1_7("1.7"),
  40. /** PDF v2.0 */
  41. V2_0("2.0");
  42. private String version;
  43. private Version(String version) {
  44. this.version = version;
  45. }
  46. /**
  47. * Given the PDF version as a String, returns the corresponding enumerated type. The
  48. * String should be in the format "1.x" for PDF v1.x.
  49. *
  50. * @param version a version number
  51. * @return the corresponding Version instance
  52. * @throws IllegalArgumentException if the argument does not correspond to any
  53. * existing PDF version
  54. */
  55. public static Version getValueOf(String version) {
  56. for (Version pdfVersion : Version.values()) {
  57. if (pdfVersion.toString().equals(version)) {
  58. return pdfVersion;
  59. }
  60. }
  61. throw new IllegalArgumentException("Invalid PDF version given: " + version);
  62. }
  63. @Override
  64. public String toString() {
  65. return version;
  66. }
  67. }