/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1999 by Sun Microsystems, Inc.
* All rights reserved.
*
*/
// ServiceType.java: Model a service type.
// Author: James Kempf
// Created On: Thu Apr 9 09:23:18 1998
// Last Modified By: James Kempf
// Last Modified On: Mon Oct 19 15:43:18 1998
// Update Count: 33
//
/**
* The ServiceType class conceals the complex details of whether a
* service type name is a simple URL scheme identifier, a service:
* type, an abstract type or protocol type.
*
* @author James Kempf
*/
// For removing IANA.
/**
* Create a service type object from the type name. The name may
* take the form of any valid SLP service type name.
*
* @param t The type name.
* @return The ServiceType object.
* @exception IllegalArgumentException If the name is syntactically
* incorrect.
*/
parse(t);
}
/**
* Return true if type name was from a service: URL.
*
* @return True if type name came from service: URL.
*/
public boolean isServiceURL() {
return isServiceURL;
}
/**
* Return true if type name is for an abstract type.
*
* @return True if type name is for an abstract type.
*/
public boolean isAbstractType() {
}
/**
* Return true if naming authority is default.
*
* @return True if naming authority is default.
*/
public boolean isNADefault() {
}
/**
* Return the concrete service type name without naming authority.
*
* @return concrete type name.
*/
return type2;
}
/**
* Return the principle type name, which is either the abstract
* type name or the protocol name, without naming authority.
*
* @return Principle type name.
*/
return type1;
}
/**
* Return the fully formatted abstract type name, if it is an abstract
* type, otherwise the empty string.
*/
if (isAbstractType()) {
}
return "";
}
/**
* Return the naming authority name.
*
* @return Naming authority name.
*/
return na;
}
/**
*Validate a naming authority name.
*/
throws ServiceLocationException {
validateTypeComponentInternal(name, false);
}
// Validate, allowing '.' if allowDot is true.
static private void
throws ServiceLocationException {
for (i = 0; i < n; i++) {
if ((Character.isLetterOrDigit(c) == false) &&
(c != '+') && (c != '-')) {
boolean throwIt = true;
// If dot is allowed, don't throw it.
if (allowDot && (c == '.')) {
throwIt = false;
}
if (throwIt) {
throw
}
}
}
}
// Two service type names are equal if they have the same
// types, naming authority, and same service: flag.
if (o == this) {
return true;
}
if (!(o instanceof ServiceType)) {
return false;
}
return
}
// Format the service type name for output.
return
type1 +
}
// Return a hash code for the type.
public int hashCode() {
}
// Parse a service type name with optional naming authority.
try {
// This loop is a kludgy way to break out of the parse so
// we only throw at one location in the code.
do {
break; // error!
}
// Look for a nonservice: URL.
isServiceURL = false;
// Need to eat through all dots.
do {
// Break when we run out of tokens.
if (!st.hasMoreTokens()) {
break;
}
} while (true);
// Check for disallowed characters. Allow '.'.
validateTypeComponentInternal(type1, true);
// There should be no more tokens.
if (st.hasMoreTokens()) {
break; // error!
}
return; // done!
}
break; // error!
}
// Get the protocol or abstract type name.
// From here on in, everything is optional, so be sure
// to check for no remaining tokens.
if (!st.hasMoreTokens()) {
return;
// done! It's a simple protocol type w.o. naming authority.
}
// It's either got a naming authority or is an abstract
// type (or both).
// Check for naming authorithy.
} else {
// Error to have IANA.
break;
}
if (!st.hasMoreTokens()) {
return;
// done! It's a simple protocol type w. naming authority.
}
}
// Should be at the separator to concrete type.
break; // error!
}
// This is the concrete type name.
// Should be no more tokens.
if (st.hasMoreTokens()) {
break; // error!
}
return; // done!
} while (false);
} catch (NoSuchElementException ex) {
throw
new Object[] {t}));
} catch (ServiceLocationException ex) {
throw
}
throw
new Object[] {t}));
}
}