nextToken() public method

public nextToken ( ) : int
return int
Exemplo n.º 1
0
        private AttributeQualifier parseQualifier(SchemaTokenCreator st, string name)
        {
            ArrayList values = new ArrayList(5);

            try
            {
                if (st.nextToken() == '\'')
                {
                    values.Add(st.StringValue);
                }
                else
                {
                    if (st.lastttype == '(')
                    {
                        while (st.nextToken() == '\'')
                        {
                            values.Add(st.StringValue);
                        }
                    }
                }
            }
            catch (IOException e)
            {
                throw e;
            }
            string[] valArray = new string[values.Count];
            valArray = (string[])SupportClass.ArrayListSupport.ToArray(values, valArray);
            return(new AttributeQualifier(name, valArray));
        }
Exemplo n.º 2
0
		private AttributeQualifier parseQualifier(SchemaTokenCreator st, System.String name)
		{
			System.Collections.ArrayList values = new System.Collections.ArrayList(5);
			try
			{
				if (st.nextToken() == '\'')
				{
					values.Add(st.StringValue);
				}
				else
				{
					if (st.lastttype == '(')
					{
						while (st.nextToken() == '\'')
						{
							values.Add(st.StringValue);
						}
					}
				}
			}
			catch (System.IO.IOException e)
			{
				throw e;
			}
			System.String[] valArray = new System.String[values.Count];
			valArray = (System.String[]) SupportClass.ArrayListSupport.ToArray(values, valArray);
			return new AttributeQualifier(name, valArray);
		}
Exemplo n.º 3
0
        public SchemaParser(string aString)
        {
            InitBlock();

            int index;

            if ((index = aString.IndexOf('\\')) != -1)
            {
                /*
                 * Unless we escape the slash, StreamTokenizer will interpret the
                 * single slash and convert it assuming octal values.
                 * Two successive back slashes are intrepreted as one backslash.
                 */
                StringBuilder newString = new StringBuilder(aString.Substring(0, (index) - (0)));
                for (int i = index; i < aString.Length; i++)
                {
                    newString.Append(aString[i]);
                    if (aString[i] == '\\')
                    {
                        newString.Append('\\');
                    }
                }
                rawString = newString.ToString();
            }
            else
            {
                rawString = aString;
            }

            SchemaTokenCreator st2 = new SchemaTokenCreator(new StringReader(rawString));

            st2.OrdinaryCharacter('.');
            st2.OrdinaryCharacters('0', '9');
            st2.OrdinaryCharacter('{');
            st2.OrdinaryCharacter('}');
            st2.OrdinaryCharacter('_');
            st2.OrdinaryCharacter(';');
            st2.WordCharacters('.', '9');
            st2.WordCharacters('{', '}');
            st2.WordCharacters('_', '_');
            st2.WordCharacters(';', ';');
            //First parse out the OID
            try
            {
                string currName;
                if ((int)TokenTypes.EOF != st2.nextToken())
                {
                    if (st2.lastttype == '(')
                    {
                        if ((int)TokenTypes.WORD == st2.nextToken())
                        {
                            id = st2.StringValue;
                        }
                        while ((int)TokenTypes.EOF != st2.nextToken())
                        {
                            if (st2.lastttype == (int)TokenTypes.WORD)
                            {
                                if (st2.StringValue.ToUpper().Equals("NAME".ToUpper()))
                                {
                                    if (st2.nextToken() == '\'')
                                    {
                                        names    = new string[1];
                                        names[0] = st2.StringValue;
                                    }
                                    else
                                    {
                                        if (st2.lastttype == '(')
                                        {
                                            ArrayList nameList = new ArrayList();
                                            while (st2.nextToken() == '\'')
                                            {
                                                if (st2.StringValue != null)
                                                {
                                                    nameList.Add(st2.StringValue);
                                                }
                                            }
                                            if (nameList.Count > 0)
                                            {
                                                names = new string[nameList.Count];
                                                SupportClass.ArrayListSupport.ToArray(nameList, names);
                                            }
                                        }
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("DESC".ToUpper()))
                                {
                                    if (st2.nextToken() == '\'')
                                    {
                                        description = st2.StringValue;
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("SYNTAX".ToUpper()))
                                {
                                    result = st2.nextToken();
                                    if ((result == (int)TokenTypes.WORD) || (result == '\''))
                                    //Test for non-standard schema
                                    {
                                        syntax = st2.StringValue;
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("EQUALITY".ToUpper()))
                                {
                                    if (st2.nextToken() == (int)TokenTypes.WORD)
                                    {
                                        equality = st2.StringValue;
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("ORDERING".ToUpper()))
                                {
                                    if (st2.nextToken() == (int)TokenTypes.WORD)
                                    {
                                        ordering = st2.StringValue;
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("SUBSTR".ToUpper()))
                                {
                                    if (st2.nextToken() == (int)TokenTypes.WORD)
                                    {
                                        substring = st2.StringValue;
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("FORM".ToUpper()))
                                {
                                    if (st2.nextToken() == (int)TokenTypes.WORD)
                                    {
                                        nameForm = st2.StringValue;
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("OC".ToUpper()))
                                {
                                    if (st2.nextToken() == (int)TokenTypes.WORD)
                                    {
                                        objectClass = st2.StringValue;
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("SUP".ToUpper()))
                                {
                                    ArrayList values = new ArrayList();
                                    st2.nextToken();
                                    if (st2.lastttype == '(')
                                    {
                                        st2.nextToken();
                                        while (st2.lastttype != ')')
                                        {
                                            if (st2.lastttype != '$')
                                            {
                                                values.Add(st2.StringValue);
                                            }
                                            st2.nextToken();
                                        }
                                    }
                                    else
                                    {
                                        values.Add(st2.StringValue);
                                        superior = st2.StringValue;
                                    }
                                    if (values.Count > 0)
                                    {
                                        superiors = new string[values.Count];
                                        SupportClass.ArrayListSupport.ToArray(values, superiors);
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("SINGLE-VALUE".ToUpper()))
                                {
                                    single = true;
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("OBSOLETE".ToUpper()))
                                {
                                    obsolete = true;
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("COLLECTIVE".ToUpper()))
                                {
                                    collective = true;
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("NO-USER-MODIFICATION".ToUpper()))
                                {
                                    userMod = false;
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("MUST".ToUpper()))
                                {
                                    ArrayList values = new ArrayList();
                                    st2.nextToken();
                                    if (st2.lastttype == '(')
                                    {
                                        st2.nextToken();
                                        while (st2.lastttype != ')')
                                        {
                                            if (st2.lastttype != '$')
                                            {
                                                values.Add(st2.StringValue);
                                            }
                                            st2.nextToken();
                                        }
                                    }
                                    else
                                    {
                                        values.Add(st2.StringValue);
                                    }
                                    if (values.Count > 0)
                                    {
                                        required = new string[values.Count];
                                        SupportClass.ArrayListSupport.ToArray(values, required);
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("MAY".ToUpper()))
                                {
                                    ArrayList values = new ArrayList();
                                    st2.nextToken();
                                    if (st2.lastttype == '(')
                                    {
                                        st2.nextToken();
                                        while (st2.lastttype != ')')
                                        {
                                            if (st2.lastttype != '$')
                                            {
                                                values.Add(st2.StringValue);
                                            }
                                            st2.nextToken();
                                        }
                                    }
                                    else
                                    {
                                        values.Add(st2.StringValue);
                                    }
                                    if (values.Count > 0)
                                    {
                                        optional = new string[values.Count];
                                        SupportClass.ArrayListSupport.ToArray(values, optional);
                                    }
                                    continue;
                                }

                                if (st2.StringValue.ToUpper().Equals("NOT".ToUpper()))
                                {
                                    ArrayList values = new ArrayList();
                                    st2.nextToken();
                                    if (st2.lastttype == '(')
                                    {
                                        st2.nextToken();
                                        while (st2.lastttype != ')')
                                        {
                                            if (st2.lastttype != '$')
                                            {
                                                values.Add(st2.StringValue);
                                            }
                                            st2.nextToken();
                                        }
                                    }
                                    else
                                    {
                                        values.Add(st2.StringValue);
                                    }
                                    if (values.Count > 0)
                                    {
                                        precluded = new string[values.Count];
                                        SupportClass.ArrayListSupport.ToArray(values, precluded);
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("AUX".ToUpper()))
                                {
                                    ArrayList values = new ArrayList();
                                    st2.nextToken();
                                    if (st2.lastttype == '(')
                                    {
                                        st2.nextToken();
                                        while (st2.lastttype != ')')
                                        {
                                            if (st2.lastttype != '$')
                                            {
                                                values.Add(st2.StringValue);
                                            }
                                            st2.nextToken();
                                        }
                                    }
                                    else
                                    {
                                        values.Add(st2.StringValue);
                                    }
                                    if (values.Count > 0)
                                    {
                                        auxiliary = new string[values.Count];
                                        SupportClass.ArrayListSupport.ToArray(values, auxiliary);
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("ABSTRACT".ToUpper()))
                                {
                                    type = LdapObjectClassSchema.ABSTRACT;
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("STRUCTURAL".ToUpper()))
                                {
                                    type = LdapObjectClassSchema.STRUCTURAL;
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("AUXILIARY".ToUpper()))
                                {
                                    type = LdapObjectClassSchema.AUXILIARY;
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("USAGE".ToUpper()))
                                {
                                    if (st2.nextToken() == (int)TokenTypes.WORD)
                                    {
                                        currName = st2.StringValue;
                                        if (currName.ToUpper().Equals("directoryOperation".ToUpper()))
                                        {
                                            usage = LdapAttributeSchema.DIRECTORY_OPERATION;
                                        }
                                        else if (currName.ToUpper().Equals("distributedOperation".ToUpper()))
                                        {
                                            usage = LdapAttributeSchema.DISTRIBUTED_OPERATION;
                                        }
                                        else if (currName.ToUpper().Equals("dSAOperation".ToUpper()))
                                        {
                                            usage = LdapAttributeSchema.DSA_OPERATION;
                                        }
                                        else if (currName.ToUpper().Equals("userApplications".ToUpper()))
                                        {
                                            usage = LdapAttributeSchema.USER_APPLICATIONS;
                                        }
                                    }
                                    continue;
                                }
                                if (st2.StringValue.ToUpper().Equals("APPLIES".ToUpper()))
                                {
                                    ArrayList values = new ArrayList();
                                    st2.nextToken();
                                    if (st2.lastttype == '(')
                                    {
                                        st2.nextToken();
                                        while (st2.lastttype != ')')
                                        {
                                            if (st2.lastttype != '$')
                                            {
                                                values.Add(st2.StringValue);
                                            }
                                            st2.nextToken();
                                        }
                                    }
                                    else
                                    {
                                        values.Add(st2.StringValue);
                                    }
                                    if (values.Count > 0)
                                    {
                                        applies = new string[values.Count];
                                        SupportClass.ArrayListSupport.ToArray(values, applies);
                                    }
                                    continue;
                                }
                                currName = st2.StringValue;
                                AttributeQualifier q = parseQualifier(st2, currName);
                                if (q != null)
                                {
                                    qualifiers.Add(q);
                                }
                                continue;
                            }
                        }
                    }
                }
            }
            catch (IOException e)
            {
                throw e;
            }
        }
Exemplo n.º 4
0
		public SchemaParser(System.String aString)
		{
			InitBlock();
			
			int index;
			
			if ((index = aString.IndexOf((System.Char) '\\')) != - 1)
			{
				/*
				* Unless we escape the slash, StreamTokenizer will interpret the
				* single slash and convert it assuming octal values.
				* Two successive back slashes are intrepreted as one backslash.
				*/
				System.Text.StringBuilder newString = new System.Text.StringBuilder(aString.Substring(0, (index) - (0)));
				for (int i = index; i < aString.Length; i++)
				{
					newString.Append(aString[i]);
					if (aString[i] == '\\')
					{
						newString.Append('\\');
					}
				}
				rawString = newString.ToString();
			}
			else
			{
				rawString = aString;
			}
			
			SchemaTokenCreator st2 = new SchemaTokenCreator(new System.IO.StringReader(rawString));
			st2.OrdinaryCharacter('.');
			st2.OrdinaryCharacters('0', '9');
			st2.OrdinaryCharacter('{');
			st2.OrdinaryCharacter('}');
			st2.OrdinaryCharacter('_');
			st2.OrdinaryCharacter(';');
			st2.WordCharacters('.', '9');
			st2.WordCharacters('{', '}');
			st2.WordCharacters('_', '_');
			st2.WordCharacters(';', ';');
			//First parse out the OID
			try
			{
				System.String currName;
				if ((int)TokenTypes.EOF != st2.nextToken())
				{
					if (st2.lastttype == '(')
					{
						if ((int)TokenTypes.WORD == st2.nextToken())
						{
							id = st2.StringValue;
						}
						while ((int)TokenTypes.EOF != st2.nextToken())
						{
							if (st2.lastttype == (int)TokenTypes.WORD)
							{
								if (st2.StringValue.ToUpper().Equals("NAME".ToUpper()))
								{
									if (st2.nextToken() == '\'')
									{
										names = new System.String[1];
										names[0] = st2.StringValue;
									}
									else
									{
										if (st2.lastttype == '(')
										{
											System.Collections.ArrayList nameList = new System.Collections.ArrayList();
											while (st2.nextToken() == '\'')
											{
												if ((System.Object) st2.StringValue != null)
												{
													nameList.Add(st2.StringValue);
												}
											}
											if (nameList.Count > 0)
											{
												names = new System.String[nameList.Count];
												SupportClass.ArrayListSupport.ToArray(nameList, names);
											}
										}
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("DESC".ToUpper()))
								{
									if (st2.nextToken() == '\'')
									{
										description = st2.StringValue;
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("SYNTAX".ToUpper()))
								{
									result = st2.nextToken();
									if ((result == (int)TokenTypes.WORD) || (result == '\''))
									//Test for non-standard schema
									{
										syntax = st2.StringValue;
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("EQUALITY".ToUpper()))
								{
									if (st2.nextToken() == (int)TokenTypes.WORD)
									{
										equality = st2.StringValue;
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("ORDERING".ToUpper()))
								{
									if (st2.nextToken() == (int)TokenTypes.WORD)
									{
										ordering = st2.StringValue;
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("SUBSTR".ToUpper()))
								{
									if (st2.nextToken() == (int)TokenTypes.WORD)
									{
										substring = st2.StringValue;
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("FORM".ToUpper()))
								{
									if (st2.nextToken() == (int)TokenTypes.WORD)
									{
										nameForm = st2.StringValue;
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("OC".ToUpper()))
								{
									if (st2.nextToken() == (int)TokenTypes.WORD)
									{
										objectClass = st2.StringValue;
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("SUP".ToUpper()))
								{
									System.Collections.ArrayList values = new System.Collections.ArrayList();
									st2.nextToken();
									if (st2.lastttype == '(')
									{
										st2.nextToken();
										while (st2.lastttype != ')')
										{
											if (st2.lastttype != '$')
											{
												values.Add(st2.StringValue);
											}
											st2.nextToken();
										}
									}
									else
									{
										values.Add(st2.StringValue);
										superior = st2.StringValue;
									}
									if (values.Count > 0)
									{
										superiors = new System.String[values.Count];
										SupportClass.ArrayListSupport.ToArray(values, superiors);
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("SINGLE-VALUE".ToUpper()))
								{
									single = true;
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("OBSOLETE".ToUpper()))
								{
									obsolete = true;
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("COLLECTIVE".ToUpper()))
								{
									collective = true;
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("NO-USER-MODIFICATION".ToUpper()))
								{
									userMod = false;
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("MUST".ToUpper()))
								{
									System.Collections.ArrayList values = new System.Collections.ArrayList();
									st2.nextToken();
									if (st2.lastttype == '(')
									{
										st2.nextToken();
										while (st2.lastttype != ')')
										{
											if (st2.lastttype != '$')
											{
												values.Add(st2.StringValue);
											}
											st2.nextToken();
										}
									}
									else
									{
										values.Add(st2.StringValue);
									}
									if (values.Count > 0)
									{
										required = new System.String[values.Count];
										SupportClass.ArrayListSupport.ToArray(values, required);
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("MAY".ToUpper()))
								{
									System.Collections.ArrayList values = new System.Collections.ArrayList();
									st2.nextToken();
									if (st2.lastttype == '(')
									{
										st2.nextToken();
										while (st2.lastttype != ')')
										{
											if (st2.lastttype != '$')
											{
												values.Add(st2.StringValue);
											}
											st2.nextToken();
										}
									}
									else
									{
										values.Add(st2.StringValue);
									}
									if (values.Count > 0)
									{
										optional = new System.String[values.Count];
										SupportClass.ArrayListSupport.ToArray(values, optional);
									}
									continue;
								}

								if (st2.StringValue.ToUpper().Equals("NOT".ToUpper()))
								{
									System.Collections.ArrayList values = new System.Collections.ArrayList();
									st2.nextToken();
									if (st2.lastttype == '(')
									{
										st2.nextToken();
										while (st2.lastttype != ')')
										{
											if (st2.lastttype != '$')
											{
												values.Add(st2.StringValue);
											}
											st2.nextToken();
										}
									}
									else
									{
										values.Add(st2.StringValue);
									}
									if (values.Count > 0)
									{
										precluded = new System.String[values.Count];
										SupportClass.ArrayListSupport.ToArray(values, precluded);
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("AUX".ToUpper()))
								{
									System.Collections.ArrayList values = new System.Collections.ArrayList();
									st2.nextToken();
									if (st2.lastttype == '(')
									{
										st2.nextToken();
										while (st2.lastttype != ')')
										{
											if (st2.lastttype != '$')
											{
												values.Add(st2.StringValue);
											}
											st2.nextToken();
										}
									}
									else
									{
										values.Add(st2.StringValue);
									}
									if (values.Count > 0)
									{
										auxiliary = new System.String[values.Count];
										SupportClass.ArrayListSupport.ToArray(values, auxiliary);
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("ABSTRACT".ToUpper()))
								{
									type = LdapObjectClassSchema.ABSTRACT;
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("STRUCTURAL".ToUpper()))
								{
									type = LdapObjectClassSchema.STRUCTURAL;
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("AUXILIARY".ToUpper()))
								{
									type = LdapObjectClassSchema.AUXILIARY;
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("USAGE".ToUpper()))
								{
									if (st2.nextToken() == (int)TokenTypes.WORD)
									{
										currName = st2.StringValue;
										if (currName.ToUpper().Equals("directoryOperation".ToUpper()))
										{
											usage = LdapAttributeSchema.DIRECTORY_OPERATION;
										}
										else if (currName.ToUpper().Equals("distributedOperation".ToUpper()))
										{
											usage = LdapAttributeSchema.DISTRIBUTED_OPERATION;
										}
										else if (currName.ToUpper().Equals("dSAOperation".ToUpper()))
										{
											usage = LdapAttributeSchema.DSA_OPERATION;
										}
										else if (currName.ToUpper().Equals("userApplications".ToUpper()))
										{
											usage = LdapAttributeSchema.USER_APPLICATIONS;
										}
									}
									continue;
								}
								if (st2.StringValue.ToUpper().Equals("APPLIES".ToUpper()))
								{
									System.Collections.ArrayList values = new System.Collections.ArrayList();
									st2.nextToken();
									if (st2.lastttype == '(')
									{
										st2.nextToken();
										while (st2.lastttype != ')')
										{
											if (st2.lastttype != '$')
											{
												values.Add(st2.StringValue);
											}
											st2.nextToken();
										}
									}
									else
									{
										values.Add(st2.StringValue);
									}
									if (values.Count > 0)
									{
										applies = new System.String[values.Count];
										SupportClass.ArrayListSupport.ToArray(values, applies);
									}
									continue;
								}
								currName = st2.StringValue;
								AttributeQualifier q = parseQualifier(st2, currName);
								if (q != null)
								{
									qualifiers.Add(q);
								}
								continue;
							}
						}
					}
				}
			}
			catch (System.IO.IOException e)
			{
				throw e;
			}
		}