1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * ident "%Z%%M% %I% %E% SMI" 24 * 25 * Copyright (c) 2000 by Sun Microsystems, Inc. 26 * All rights reserved. 27 */ 28 29/* 30 * Copyright (C) 1996 Active Software, Inc. 31 * All rights reserved. 32 * 33 * @(#) OpArrayConverter.java 1.6 - last change made 07/25/97 34 */ 35 36package sunsoft.jws.visual.rt.type; 37 38import java.util.Enumeration; 39 40/** 41 * Converts an array of Op to a string and back again. 42 * 43 * @see Op 44 * @version 1.6, 07/25/97 45 */ 46public class OpArrayConverter extends Converter { 47 48 public void convertToString(Object obj, StringBuffer buf) { 49 if (obj == null) { 50 buf.append(/* NOI18N */"null"); 51 return; 52 } 53 54 Op op[] = (Op[])obj; 55 56 buf.append(/* NOI18N */"{"); 57 newline(buf); 58 incrIndent(); 59 60 for (int i = 0; i < op.length; i++) { 61 indent(buf); 62 if (op[i] != null) 63 op[i].convertToString(op[i], buf); 64 newline(buf); 65 } 66 67 decrIndent(); 68 indent(buf); 69 buf.append(/* NOI18N */"}"); 70 } 71 72 public Object convertFromString(String s) { 73 if (s == null) 74 return null; 75 76 ListParser parser = new ListParser(s); 77 Enumeration e = parser.elements(); 78 Op ops[] = new Op[parser.size()]; 79 int i = 0; 80 81 while (e.hasMoreElements()) { 82 ops[i] = new Op(); 83 ops[i].convertFromString((String)e.nextElement(), ops[i]); 84 i++; 85 } 86 87 return ops; 88 } 89 90 /** 91 * Returns true if this type should be displayed in an editor. 92 * 93 * For the attribute editor, a return value of false means that the 94 * the textfield will be hidden. 95 * 96 * @return false 97 */ 98 public boolean viewableAsString() { 99 return (false); 100 } 101} 102