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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. private String version;
  41. private Version(String version) {
  42. this.version = version;
  43. }
  44. /**
  45. * Given the PDF version as a String, returns the corresponding enumerated type. The
  46. * String should be in the format "1.x" for PDF v1.x.
  47. *
  48. * @param version a version number
  49. * @return the corresponding Version instance
  50. * @throws IllegalArgumentException if the argument does not correspond to any
  51. * existing PDF version
  52. */
  53. public static Version getValueOf(String version) {
  54. for (Version pdfVersion : Version.values()) {
  55. if (pdfVersion.toString().equals(version)) {
  56. return pdfVersion;
  57. }
  58. }
  59. throw new IllegalArgumentException("Invalid PDF version given: " + version);
  60. }
  61. @Override
  62. public String toString() {
  63. return version;
  64. }
  65. }