CupsMediaMapping.java 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* CupsMediaMapping.java --
  2. Copyright (C) 2006 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package gnu.javax.print;
  32. import java.util.Collections;
  33. import java.util.HashMap;
  34. import java.util.Map;
  35. import javax.print.attribute.standard.MediaSizeName;
  36. /**
  37. * Provides the currently known mappings of the media attribute
  38. * values of the CUPS printing system to the IPP standard values.
  39. * <p>
  40. * The mapping is used to build up print service specific mappings
  41. * for use of media attribute translation between Java JPS API and
  42. * CUPS.
  43. * </p>
  44. *
  45. * @author Wolfgang Baer (WBaer@gmx.de)
  46. */
  47. public class CupsMediaMapping
  48. {
  49. // the mapping map
  50. private static final HashMap ippByCups = new HashMap();
  51. /**
  52. * Initialize currently known mappings.
  53. */
  54. static
  55. {
  56. ippByCups.put("Postcard", MediaSizeName.JAPANESE_POSTCARD);
  57. ippByCups.put("Statement", MediaSizeName.INVOICE);
  58. ippByCups.put("Letter", MediaSizeName.NA_LETTER);
  59. ippByCups.put("Executive", MediaSizeName.EXECUTIVE);
  60. ippByCups.put("Legal", MediaSizeName.NA_LEGAL);
  61. ippByCups.put("A0", MediaSizeName.ISO_A0);
  62. ippByCups.put("A1", MediaSizeName.ISO_A1);
  63. ippByCups.put("A2", MediaSizeName.ISO_A2);
  64. ippByCups.put("A3", MediaSizeName.ISO_A3);
  65. ippByCups.put("A4", MediaSizeName.ISO_A4);
  66. ippByCups.put("A5", MediaSizeName.ISO_A5);
  67. ippByCups.put("A6", MediaSizeName.ISO_A6);
  68. ippByCups.put("A7", MediaSizeName.ISO_A7);
  69. ippByCups.put("A8", MediaSizeName.ISO_A8);
  70. ippByCups.put("A9", MediaSizeName.ISO_A9);
  71. ippByCups.put("A10", MediaSizeName.ISO_A10);
  72. ippByCups.put("B0", MediaSizeName.JIS_B0);
  73. ippByCups.put("B1", MediaSizeName.JIS_B1);
  74. ippByCups.put("B2", MediaSizeName.JIS_B2);
  75. ippByCups.put("B3", MediaSizeName.JIS_B3);
  76. ippByCups.put("B4", MediaSizeName.JIS_B4);
  77. ippByCups.put("B5", MediaSizeName.JIS_B5);
  78. ippByCups.put("B6", MediaSizeName.JIS_B6);
  79. ippByCups.put("B7", MediaSizeName.JIS_B7);
  80. ippByCups.put("B8", MediaSizeName.JIS_B8);
  81. ippByCups.put("B9", MediaSizeName.JIS_B9);
  82. ippByCups.put("B10", MediaSizeName.JIS_B10);
  83. ippByCups.put("ISOB0", MediaSizeName.ISO_B0);
  84. ippByCups.put("ISOB1", MediaSizeName.ISO_B1);
  85. ippByCups.put("ISOB2", MediaSizeName.ISO_B2);
  86. ippByCups.put("ISOB3", MediaSizeName.ISO_B3);
  87. ippByCups.put("ISOB4", MediaSizeName.ISO_B4);
  88. ippByCups.put("ISOB5", MediaSizeName.ISO_B5);
  89. ippByCups.put("ISOB6", MediaSizeName.ISO_B6);
  90. ippByCups.put("ISOB7", MediaSizeName.ISO_B7);
  91. ippByCups.put("ISOB8", MediaSizeName.ISO_B8);
  92. ippByCups.put("ISOB9", MediaSizeName.ISO_B9);
  93. ippByCups.put("ISOB10", MediaSizeName.ISO_B10);
  94. ippByCups.put("EnvISOB0", MediaSizeName.ISO_B0);
  95. ippByCups.put("EnvISOB1", MediaSizeName.ISO_B1);
  96. ippByCups.put("EnvISOB2", MediaSizeName.ISO_B2);
  97. ippByCups.put("EnvISOB3", MediaSizeName.ISO_B3);
  98. ippByCups.put("EnvISOB4", MediaSizeName.ISO_B4);
  99. ippByCups.put("EnvISOB5", MediaSizeName.ISO_B5);
  100. ippByCups.put("EnvISOB6", MediaSizeName.ISO_B6);
  101. ippByCups.put("EnvISOB7", MediaSizeName.ISO_B7);
  102. ippByCups.put("EnvISOB8", MediaSizeName.ISO_B8);
  103. ippByCups.put("EnvISOB9", MediaSizeName.ISO_B9);
  104. ippByCups.put("EnvISOB10", MediaSizeName.ISO_B10);
  105. ippByCups.put("C0", MediaSizeName.ISO_C0);
  106. ippByCups.put("C1", MediaSizeName.ISO_C1);
  107. ippByCups.put("C2", MediaSizeName.ISO_C2);
  108. ippByCups.put("C3", MediaSizeName.ISO_C3);
  109. ippByCups.put("C4", MediaSizeName.ISO_C4);
  110. ippByCups.put("C5", MediaSizeName.ISO_C5);
  111. ippByCups.put("C6", MediaSizeName.ISO_C6);
  112. ippByCups.put("EnvPersonal", MediaSizeName.PERSONAL_ENVELOPE);
  113. ippByCups.put("EnvMonarch", MediaSizeName.MONARCH_ENVELOPE);
  114. ippByCups.put("Monarch", MediaSizeName.MONARCH_ENVELOPE);
  115. ippByCups.put("Env9", MediaSizeName.NA_NUMBER_9_ENVELOPE);
  116. ippByCups.put("Env10", MediaSizeName.NA_NUMBER_10_ENVELOPE);
  117. ippByCups.put("Env11", MediaSizeName.NA_NUMBER_11_ENVELOPE);
  118. ippByCups.put("Env12", MediaSizeName.NA_NUMBER_12_ENVELOPE);
  119. ippByCups.put("Env14", MediaSizeName.NA_NUMBER_14_ENVELOPE);
  120. ippByCups.put("c8x10", MediaSizeName.NA_8X10);
  121. ippByCups.put("EnvDL", MediaSizeName.ISO_DESIGNATED_LONG);
  122. ippByCups.put("DL", MediaSizeName.ISO_DESIGNATED_LONG);
  123. ippByCups.put("EnvC0", MediaSizeName.ISO_C0);
  124. ippByCups.put("EnvC1", MediaSizeName.ISO_C1);
  125. ippByCups.put("EnvC2", MediaSizeName.ISO_C2);
  126. ippByCups.put("EnvC3", MediaSizeName.ISO_C3);
  127. ippByCups.put("EnvC4", MediaSizeName.ISO_C4);
  128. ippByCups.put("EnvC5", MediaSizeName.ISO_C5);
  129. ippByCups.put("EnvC6", MediaSizeName.ISO_C6);
  130. }
  131. /**
  132. * Returns the IPP media name of the given cups name.
  133. *
  134. * @param cupsName the name in cups
  135. * @return The IPP name if a mapping is known, <code>null</code> otherwise.
  136. */
  137. public static final String getIppName(String cupsName)
  138. {
  139. return (String) ippByCups.get(cupsName);
  140. }
  141. /**
  142. * Returns the mapping map for iteration.
  143. *
  144. * @return The mapping map as unmodifiable map.
  145. */
  146. public static final Map getMappingMap()
  147. {
  148. return Collections.unmodifiableMap(ippByCups);
  149. }
  150. private CupsMediaMapping()
  151. {
  152. // not to be instantiated
  153. }
  154. }