17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 59a70fc3bSMark J. Nelson * Common Development and Distribution License (the "License"). 69a70fc3bSMark J. Nelson * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 227c478bd9Sstevel@tonic-gate * Copyright (c) 1999 by Sun Microsystems, Inc. 237c478bd9Sstevel@tonic-gate * All rights reserved. 247c478bd9Sstevel@tonic-gate * 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate // ServerAttribute.java: Attribute created on the server side only. 287c478bd9Sstevel@tonic-gate // Author: James Kempf 297c478bd9Sstevel@tonic-gate // Created On: Thu Apr 23 08:53:49 1998 307c478bd9Sstevel@tonic-gate // Last Modified By: James Kempf 317c478bd9Sstevel@tonic-gate // Last Modified On: Fri May 1 10:35:22 1998 327c478bd9Sstevel@tonic-gate // Update Count: 9 337c478bd9Sstevel@tonic-gate // 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate package com.sun.slp; 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate import java.util.*; 387c478bd9Sstevel@tonic-gate import java.io.*; 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /** 417c478bd9Sstevel@tonic-gate * The ServerAttribute class models attributes on the server side. 427c478bd9Sstevel@tonic-gate * The primary difference is that values substitute AttributeString 437c478bd9Sstevel@tonic-gate * objects for String objects, so attributes compare according to the 447c478bd9Sstevel@tonic-gate * rules of SLP matching rather than by string equality. Also, 457c478bd9Sstevel@tonic-gate * an AttributeString object for the id is included, for pattern 467c478bd9Sstevel@tonic-gate * matching against the id. 477c478bd9Sstevel@tonic-gate * 487c478bd9Sstevel@tonic-gate * @author James Kempf 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate class ServerAttribute extends ServiceLocationAttribute { 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate // The id as an attribute string. 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate AttributeString idPattern = null; 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate // Construct a new ServerAttribute object. Substitute AttributeString 587c478bd9Sstevel@tonic-gate // objects for strings. 597c478bd9Sstevel@tonic-gate ServerAttribute(String id_in, Vector values_in, Locale locale)607c478bd9Sstevel@tonic-gate ServerAttribute(String id_in, Vector values_in, Locale locale) 617c478bd9Sstevel@tonic-gate throws IllegalArgumentException { 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate super(id_in, values_in); 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate idPattern = new AttributeString(id, locale); 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate // Substitute for string values. 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate if (values != null) { 707c478bd9Sstevel@tonic-gate Object o = values.elementAt(0); 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate if (o instanceof String) { 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate int i, n = values.size(); 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate for (i = 0; i < n; i++) { 777c478bd9Sstevel@tonic-gate String s = (String)values.elementAt(i); 787c478bd9Sstevel@tonic-gate AttributeString as = new AttributeString(s, locale); 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate values.setElementAt(as, i); 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate } 837c478bd9Sstevel@tonic-gate } 847c478bd9Sstevel@tonic-gate } 857c478bd9Sstevel@tonic-gate } 86*55fea89dSDan Cross 877c478bd9Sstevel@tonic-gate // Construct a ServerAttribute object from a ServiceLocationAttribute 887c478bd9Sstevel@tonic-gate // object. 897c478bd9Sstevel@tonic-gate ServerAttribute(ServiceLocationAttribute attr, Locale locale)907c478bd9Sstevel@tonic-gate ServerAttribute(ServiceLocationAttribute attr, Locale locale) { 917c478bd9Sstevel@tonic-gate this(attr.id, attr.getValues(), locale); 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate } 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate // Get values by changing the attribute string objects into strings. 967c478bd9Sstevel@tonic-gate getValues()977c478bd9Sstevel@tonic-gate public Vector getValues() { 987c478bd9Sstevel@tonic-gate Vector v = super.getValues(); 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate if ((v != null) && 1017c478bd9Sstevel@tonic-gate (v.elementAt(0) instanceof AttributeString)) { 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate int i, n = v.size(); 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate for (i = 0; i < n; i++) { 1067c478bd9Sstevel@tonic-gate v.setElementAt(v.elementAt(i).toString(), i); 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate } 1097c478bd9Sstevel@tonic-gate } 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate return v; 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate } 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate } 116