2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 1999 by Sun Microsystems, Inc. 2N/A * All rights reserved. 2N/A// Author: James Kempf, Erik Guttman 2N/A * The ServiceURL object models the SLP service URL. Both service: URLs 2N/A * and regular URLs are handled by this class. 2N/A * @author James Kempf, Erik Guttman 2N/A // Recognized transports. 2N/A * Indicates that no port information is required or was returned 2N/A * for this service URL. 2N/A * No life time parameter is given. 2N/A * Default lifetime, 3 hours. 2N/A * Maximum lifetime, approximately 18 hours. 2N/A * Reregister periodically. 2N/A // Maximum port size. 2N/A * Construct a service URL object. 2N/A * @param URL The service URL as a string. 2N/A * @param iLifetime The service advertisement lifetime. 2N/A * @exception IllegalArgumentException Thrown if parse 2N/A * errors occur in the 2N/A // ------------------------------------------------------------------ 2N/A // ------------------------------------------------------------------ 2N/A * @return The service type name. 2N/A * Set service type and naming authority if this is not a service: URL. 2N/A * @param type The new ServiceType object. 2N/A * @exception IllegalArgumentException If the service type name or 2N/A * naming authority name is invalid. 2N/A * @return The machine name or IP address. 2N/A * @return The port number, if any. 2N/A * @return The URL path description, if any. 2N/A * @return The service advertisement lifetime. 2N/A * Formats the service URL into standard URL form. 2N/A * @return Formatted string with the service URL. 2N/A // Return permanent status. 2N/A // Check URL characters for correctness. 2N/A // allowed by RFC1738 2N/A if (c ==
'/' || c ==
':' || c ==
'-' || c ==
':' ||
2N/A c ==
'.' || c ==
'%' || c ==
'_' || c ==
'\'' ||
2N/A c ==
'*' || c ==
'(' || c ==
')' || c ==
'$' ||
2N/A c ==
'!' || c ==
',' || c ==
'+' || c ==
'\\') {
2N/A // reserved by RFC1738, and thus allowed, pg. 20 2N/A if (c ==
';' || c ==
'@' || c ==
'?' || c ==
'&' || c ==
'=') {
2N/A // Parse the incoming service URL specification. 2N/A // This loop is a kludgy way to break out of the parse so 2N/A // we only throw at one location in the code. 2N/A // First token must be service type name. 2N/A // Check for colon terminator, not part of service 2N/A // Create service type, remove trailing colon. 2N/A // Separator between service type name and transport. 2N/A // Check for abstract type or alternate transport. 2N/A // If this is an abstract type, then we could have 2N/A // something like: service:file-printer:file:/foo/bar. 2N/A // This is OK. Also, if this is a non-service: URL, 2N/A // We only recognize IPX and Appletalk at this point. 2N/A // Abstract type is OK. We must check here because 2N/A // Check for separator between transport and host. 2N/A // Not abstract type, no alternate transport. Get host. 2N/A return;
// we're done! 2N/A // Need to check for port number if this is an IP transport. 2N/A // after this point we have to check if there is a token 2N/A // remaining before we read it: It is legal to stop at any 2N/A // point now. Before all the tokens were required, so 2N/A // missing any was an error. 2N/A // minimal url service:t:// a 2N/A return;
// we're done! 2N/A // there is a URL path 2N/A // URLPath is all remaining tokens 2N/A }
while (
false);
// done with parse. 2N/A // The only way to get here is if there was an error in the