Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/awt/X11/XCreateWindowParams.java
32288 views
/*1* Copyright (c) 2003, 2004, 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.awt.X11;2627import java.util.HashMap;28import java.util.Iterator;29import java.util.Map;3031public class XCreateWindowParams extends HashMap {32public XCreateWindowParams() {33}34public XCreateWindowParams(Object[] map) {35init(map);36}37private void init(Object[] map) {38if (map.length % 2 != 0) {39throw new IllegalArgumentException("Map size should be devisible by two");40}41for (int i = 0; i < map.length; i += 2) {42put(map[i], map[i+1]);43}44}4546public XCreateWindowParams putIfNull(Object key, Object value) {47if (!containsKey(key)) {48put(key, value);49}50return this;51}52public XCreateWindowParams putIfNull(Object key, int value) {53if (!containsKey(key)) {54put(key, Integer.valueOf(value));55}56return this;57}58public XCreateWindowParams putIfNull(Object key, long value) {59if (!containsKey(key)) {60put(key, Long.valueOf(value));61}62return this;63}6465public XCreateWindowParams add(Object key, Object value) {66put(key, value);67return this;68}69public XCreateWindowParams add(Object key, int value) {70put(key, Integer.valueOf(value));71return this;72}73public XCreateWindowParams add(Object key, long value) {74put(key, Long.valueOf(value));75return this;76}77public XCreateWindowParams delete(Object key) {78remove(key);79return this;80}81public String toString() {82StringBuffer buf = new StringBuffer();83Iterator eIter = entrySet().iterator();84while (eIter.hasNext()) {85Map.Entry entry = (Map.Entry)eIter.next();86buf.append(entry.getKey() + ": " + entry.getValue() + "\n");87}88return buf.toString();89}9091}929394