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, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A// Author: James Kempf 2N/A// Created On: Thu Jun 19 10:51:32 1997 2N/A// Last Modified By: James Kempf 2N/A// Last Modified On: Mon Nov 9 10:21:02 1998 2N/A * The AttributeVerifier class implements the ServiceLocationAttributeVerifier 2N/A * interface, but without committment to a particular mechanism for 2N/A * obtaining the template defintion. Subclasses provide the mechanism, 2N/A * and pass in the template to the parent as a Reader during object 2N/A * creation. The AttributeVerifier class parses tokens from the Reader and 2N/A * constructs the attribute descriptor objects describing the attribute. These 2N/A * are used during verification of the attribute. The AttributeVerifier 2N/A * and implementations of the attribute descriptors are free to optimize 2N/A * space utilization by lazily evaluating portions of the attribute 2N/A * @author James Kempf 2N/A // Template specific escape. 2N/A // Number of template attributes. 2N/A // Bitfields for found template attributes. 2N/A // When all template attribute assignments are found. 2N/A // These are the valid SLP types. 2N/A // These are the corresponding Java types. Package public so 2N/A // others (SLPConfig for example) can get at them. 2N/A "java.lang.Integer";
2N/A "java.lang.Boolean";
2N/A // Tokens for boolean values. 2N/A // This is the number of flags. 2N/A // These are the flags. 2N/A // These masks help determine whether the flags have been duplicated. 2N/A // These are tokens for separator characters. 2N/A // This token is for checking version number 2N/A // attribute assignment. 2N/A // Radix64 code characters. 2N/A // The SLP service type of this template. 2N/A // The template's language locale. 2N/A // The template's version. 2N/A // The template's URL syntax. 2N/A // The template's description. 2N/A // The attribute descriptors. 2N/A // Initialize the attribute verifier with a reader. Subclasses or clients 2N/A // pass in a Reader on the template that is used for parsing. This 2N/A // method is used when the template includes the template attributes 2N/A // Use a StreamTokenizer to parse. 2N/A // Initialize tokenizer for parsing main. 2N/A // Now parse the attribute template, including template attributes. 2N/A // Initialize with this method when no template attributes are involved. 2N/A // Use a StreamTokenizer to parse. 2N/A // Initialize tokenizer for parsing main. 2N/A // Now parse the attribute templates, but no template attributes. 2N/A // ServiceLocationAttributeVerifier interface implementation. 2N/A * Returns the SLP service type for which this is the verifier. 2N/A * @return The SLP service type name. 2N/A * Returns the SLP language locale of this is the verifier. 2N/A * @return The SLP language locale. 2N/A * Returns the SLP version of this is the verifier. 2N/A * @return The SLP version. 2N/A * Returns the SLP URL syntax of this is the verifier. 2N/A * @return The SLP URL syntax. 2N/A * Returns the SLP description of this is the verifier. 2N/A * @return The SLP description. 2N/A * Returns the ServiceLocationAttributeDescriptor object for the 2N/A * attribute having the named id. IF no such attribute exists in the 2N/A * template, returns null. This method is primarily for GUI tools to 2N/A * display attribute information. Programmatic verification of attributes 2N/A * should use the verifyAttribute() method. 2N/A * @param attrId Id of attribute to return. 2N/A * @return The ServiceLocationAttributeDescriptor object corresponding 2N/A * to the parameter, or null if none. 2N/A * Returns an Enumeration of 2N/A * ServiceLocationAttributeDescriptors for the template. This method 2N/A * is primarily for GUI tools to display attribute information. 2N/A * Programmatic verification of attributes should use the 2N/A * verifyAttribute() method. Note that small memory implementations 2N/A * may want to implement the Enumeration so that attributes are 2N/A * parsed on demand rather than at creation time. 2N/A * @return A Dictionary with attribute id's as the keys and 2N/A * ServiceLocationAttributeDescriptor objects for the 2N/A * attributes as the values. 2N/A * Verify that the attribute parameter is a valid SLP attribute. 2N/A * @param attribute The ServiceLocationAttribute to be verified. 2N/A "template_no_attribute",
2N/A // If keyword, check that no values were specified. 2N/A "template_not_null",
2N/A // Check that a values vector exists, and, if the attribute is 2N/A // not multivalued, only one element is in it. 2N/A "template_not_multi",
2N/A // Get allowed values. 2N/A // Lower case if string, convert to Opaque if byte array. 2N/A // Check that the types of the values vector match the attribute 2N/A // type. Also, if any allowed values, that attribute values 2N/A for (i =
0; i < n; i++) {
2N/A "template_type_mismatch",
2N/A // Convert value for comparison, if necessary. 2N/A "template_not_allowed_value",
2N/A // No way to verify `X' because that's a search property. We 2N/A // must verify `O' in the context of an attribute set. 2N/A * Verify that the set of registration attributes matches the 2N/A * required attributes for the service. 2N/A * @param attributeVector A Vector of ServiceLocationAttribute objects 2N/A * for the registration. 2N/A * @exception ServiceLocationException Thrown if the 2N/A * attribute set is not valid. The message contains information 2N/A * on the attribute name and problem. 2N/A // Check whether any attributes are required. If so, then 2N/A // there's an error. 2N/A "template_missing_required",
2N/A // Construct a hashtable of incoming objects, verifying them 2N/A for (i =
0; i < n; i++) {
2N/A // If we already have it, signal a duplicate. 2N/A // Now check that all required attributes are present. 2N/A "template_missing_required",
2N/A // Private implementation. This is the template attribute parser. 2N/A // Tokenizer initializers. 2N/A // Base initialization. Resets syntax tables, sets up EOL parsing, 2N/A // and makes word case significant. 2N/A // Each part of an attribute production must specify which 2N/A // characters belong to words. 2N/A // Note that we have to make EOL be whitespace even if significant 2N/A // because otherwise the line number won't be correctly incremented. 2N/A // Don't lower case tokens. 2N/A // Initialize those token characters that appear in all 2N/A // These characters are recognized as parts of tokens. 2N/A // Initialize tokenizer for parsing attribute name, 2N/A // attribute type and flags, 2N/A // and for boolean initializer lists. 2N/A // Need backslash for escaping. 2N/A // Attribute id, Type, flags, and boolean initialzers 2N/A // all ignore white space. 2N/A // Attribute part won't view newline as being significant. 2N/A // Case is not folded. 2N/A // Initialize tokenizer for parsing service type name. 2N/A // need to restrict characters. 2N/A // Scheme name, type, flags, and boolean initialzers 2N/A // all ignore white space. 2N/A // Scheme part won't view newline as being significant. 2N/A // Case is not folded. 2N/A // Initialize tokenizer for string list parsing. 2N/A // Everything except '#' and ',' is recognized. 2N/A // Note that whitespace is significant, but 2N/A // '%' is also reserved, but it is postprocessed 2N/A // after the string is collected. 2N/A // Parse by lines to check when we've reached the end of the list. 2N/A // Initialize tokenizer for integer list parsing. 2N/A // Integer value list parsing ignores white space. 2N/A // Parse by lines so we can find the end. 2N/A // Boolean lists have same item syntax as scheme char. 2N/A // Initialize main production parsing. The only 2N/A // significant token character is <NL> because 2N/A // parsing is done on a line-oriented basis. 2N/A // Parse a template from the tokenizer. 2N/A // First parse past the template attributes. 2N/A // Finally, parse the attributes. 2N/A // Parse the template attributes from the tokenizer. 2N/A // Parse each of the template attributes. Note that we are parsing 2N/A // the attribute value assignments, not definitions. 2N/A "template_io_error",
2N/A // Parse a template attribute. 2N/A // Get line including id and equals. 2N/A "template_assign_error",
2N/A // Get tokenizer for id and potential value line. 2N/A // Make sure newline is there. 2N/A "template_end_error",
2N/A "template_unk_token",
2N/A "template_missing_id",
2N/A // Check for the equals. 2N/A "template_missing_eq ",
2N/A // Depending on the id, parse the rest. 2N/A // Just need to parse off the service type. 2N/A "template_srv_type_err",
2N/A // Check for characters which are not alphanumerics, + and -. 2N/A // Service type names are more heavily restricted. 2N/A "template_srv_type_err",
2N/A // Need to prefix with "serivce:". 2N/A // Set service type instance variable. 2N/A // Check for extra stuff. 2N/A "template_srv_type_err",
2N/A // Just need to parse off the version number. 2N/A "template_vers_err",
2N/A // Make sure it's a valid version number. 2N/A "template_vers_mssing",
2N/A "template_vers_err",
2N/A // Check for extra stuff. 2N/A "template_vers_err",
2N/A // Make sure there is nothing else on that line. 2N/A "template_attr_syntax",
2N/A // Need to continue parsing help text until we reach a blank 2N/A // If previous token was end of line, quit. 2N/A // Store any text first. 2N/A "template_end_error",
2N/A "template_unk_token",
2N/A // Pull everything out of the rdr StringReader until empty. 2N/A // Need to continue parsing service URL syntax until we 2N/A // reach a blank line. 2N/A // If previous token was end of line, quit. 2N/A // Store any text first. 2N/A "template_end_error",
2N/A "template_unk_token",
2N/A "template_nontattribute_err",
2N/A // Throw exception if a duplicate definition was detected. 2N/A // Make sure the assignment ends with a blank line. 2N/A "template_attr_syntax",
2N/A // Parse the attributes from the tokenizer. 2N/A // Check if at end of file yet. 2N/A // If not, push token back so we can get it next time. 2N/A // Parse off the attribute descriptor. 2N/A // Check whether default values, if any, are correct. 2N/A // If the attribute already exists, then throw exception. 2N/A // We could arguably replace existing, but it might 2N/A // suprise the user. 2N/A // Add the attribute to the descriptor table. 2N/A "template_io_error",
2N/A // Parse a single attribute description from the tokenizer. 2N/A // Parse the string for attribute id, type, and flags. 2N/A "template_attr_syntax",
2N/A // Parse the attribute id. 2N/A // Parse the type and flags. 2N/A "template_end_error",
2N/A "template_unk_token",
2N/A // Parse initial values. 2N/A // Read in entire list. 2N/A // Trim line, check for '#', indicating end of list. 2N/A // it's help text already. 2N/A // Otherwise concatenate onto growing list. 2N/A // end of attribute definition. 2N/A // Process any accumulated list. 2N/A "template_end_error",
2N/A "template_unk_token",
2N/A // Check for end of definition. 2N/A // Check for start of help text. 2N/A "template_attr_syntax",
2N/A "template_end_error",
2N/A "template_unk_token",
2N/A // Check for end of help text. 2N/A // Help text is collected verbatim after '#'. 2N/A // We've reached the end of the help text. Store it 2N/A // and break out of the loop. 2N/A // If previous token was end of line, quit. 2N/A // Store any text first. 2N/A // If this is a keyword attribute, set the allowed 2N/A // values list to null. 2N/A // Error if previous token wasn't EOL. 2N/A "template_end_error",
2N/A "template_unk_token",
2N/A // Parse allowed values. 2N/A // Read in entire list. 2N/A // Concatenate onto growing list. 2N/A // end of attribute definition. 2N/A // Process any accumulated list. 2N/A "template_end_error",
2N/A "template_unk_token",
2N/A // Error. Keyword attribute should have ended during help text 2N/A // parsing or before. 2N/A "template_attr_syntax",
2N/A "template_io_error",
2N/A // Check whether the default values, if any, are correct. 2N/A // Don't bother if it's a keyword attribute, parsing has checked. 2N/A // First, collect the allowed values. 2N/A // Lower case strings and create opaques for comparison 2N/A // if type is opaque. 2N/A // Now compare the allowed with the initial. 2N/A // Error if allowed is restricted but no initializers. 2N/A // Compare init values with allowed. 2N/A return;
// found it! 2N/A // Initializer wasn't found. 2N/A "template_wrong_init",
2N/A // Parse the attribute's id string. 2N/A // Parse the attribute's identifier tag. 2N/A // Parse the separator. 2N/A "template_attr_syntax",
2N/A // Expand out any escaped ``#''. It won't be handled by 2N/A // Expand out character escapes. 2N/A // Parse the attribute's type and flags. 2N/A // Parse the attribute's type. 2N/A // Check if any flags are left. 2N/A // Error if flags with keyword. 2N/A "template_attr_syntax",
2N/A // Check and assign it to the attribute. 2N/A // Parse the attribute's initial value(s). 2N/A // First get the vector of initial values. 2N/A // Check whether it works for this attribute. Type 2N/A // checking will be done by value list parsing. 2N/A "template_attr_syntax",
2N/A // Parse the attribute's allowed values. 2N/A // First get the vector of all allowed values. 2N/A // Now set the allowed value vector. 2N/A // Parse a value list. 2N/A // Set up the tokenizer according to the type of the 2N/A // Parse through a potentially multivalued value list. 2N/A // false when a comma required. 2N/A // If a word isn't required, then the case is 2N/A // "token token" and is an error. 2N/A // Convert the value to the proper object. 2N/A // If a word is required, then list ends with 2N/A // a comma, so error. 2N/A // If a word is required, then error. The case is ",,". 2N/A // Otherwise, the next token must be a word. 2N/A // No other tokens are allowed. 2N/A "template_attr_syntax",
2N/A // Check the type and add it to the attribute descriptor. 2N/A // Check token against recognized types. 2N/A "template_not_slp_type",
2N/A // Check the flag and add it to the attribute descriptor. 2N/A // We depend on the attribute descriptor being initialized to 2N/A // nothing, i.e. false for all flags and for keyword. 2N/A // Check for boolean. Booleans may not have 2N/A "template_boolean_multi",
2N/A "template_invalid_attr_flag",
2N/A "template_dup_attr_flag",
2N/A return 0;
// never happens. 2N/A // Parse a word out of the tokenizer. The exact characters 2N/A // will depend on what the syntax tables have been set to. 2N/A // Report the erroneous characters. 2N/A "template_invalid_tok",
2N/A // Convert a value list token to the value. 2N/A // Expand out any escaped ``#''. It won't be handled by 2N/A // Expand out character escapes. 2N/A "template_expect_int",
2N/A // Boolean.valueOf() doesn't handle this properly. 2N/A "template_expect_bool",
2N/A "template_attr_desc",
2N/A // Expand out any escaped hashes. Not handled by SLA.