Path: blob/master/src/java.desktop/share/classes/sun/print/CustomMediaTray.java
41153 views
/*1* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.print;2627import java.io.Serial;28import java.util.ArrayList;2930import javax.print.attribute.EnumSyntax;31import javax.print.attribute.standard.Media;32import javax.print.attribute.standard.MediaTray;3334public class CustomMediaTray extends MediaTray {35private static ArrayList<String> customStringTable = new ArrayList<>();36private static ArrayList<MediaTray> customEnumTable = new ArrayList<>();37private String choiceName;3839private CustomMediaTray(int x) {40super(x);4142}4344private static synchronized int nextValue(String name) {45customStringTable.add(name);46return (customStringTable.size()-1);47}484950public CustomMediaTray(String name, String choice) {51super(nextValue(name));52choiceName = choice;53customEnumTable.add(this);54}5556/**57* Use serialVersionUID from JDK 1.5 for interoperability.58*/59@Serial60private static final long serialVersionUID = 1019451298193987013L;616263/**64* Returns the command string for this media tray.65*/66public String getChoiceName() {67return choiceName;68}697071/**72* Returns the string table for super class MediaTray.73*/74public Media[] getSuperEnumTable() {75return (Media[])super.getEnumValueTable();76}777879/**80* Returns the string table for class CustomMediaTray.81*/82protected String[] getStringTable() {83String[] nameTable = new String[customStringTable.size()];84return customStringTable.toArray(nameTable);85}8687/**88* Returns the enumeration value table for class CustomMediaTray.89*/90protected EnumSyntax[] getEnumValueTable() {91MediaTray[] enumTable = new MediaTray[customEnumTable.size()];92return customEnumTable.toArray(enumTable);93}9495}969798