01: /*
02: * WbMediaSizeName.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.print;
13:
14: import javax.print.attribute.EnumSyntax;
15: import javax.print.attribute.standard.MediaSizeName;
16:
17: /**
18: *
19: * @author support@sql-workbench.net
20: */
21: public class WbMediaSizeName extends MediaSizeName {
22:
23: public WbMediaSizeName(int aValue) {
24: super (aValue);
25: }
26:
27: public String[] getStringTable() {
28: return super .getStringTable();
29: }
30:
31: public EnumSyntax[] getEnumValueTable() {
32: return super .getEnumValueTable();
33: }
34:
35: public static String getName(MediaSizeName aMedia) {
36: int value = aMedia.getValue();
37: WbMediaSizeName dummy = new WbMediaSizeName(0);
38: String[] names = dummy.getStringTable();
39: if (value >= 0 && value < names.length) {
40: return names[value];
41: }
42: return null;
43: }
44:
45: public static MediaSizeName getMediaSize(String aName) {
46: WbMediaSizeName dummy = new WbMediaSizeName(0);
47: //String[] names = dummy.getStringTable();
48: EnumSyntax[] values = dummy.getEnumValueTable();
49:
50: for (int i = 0; i < values.length; i++) {
51: MediaSizeName entry = (MediaSizeName) values[i];
52: if (entry.getName().equals(aName)) {
53: return entry;
54: }
55: }
56: return null;
57: }
58: }
|