• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Searching a full name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Searching a full name


  • Subject: RE: Searching a full name
  • From: <email@hidden>
  • Date: Tue, 28 Sep 2004 10:04:54 +0200
  • Thread-topic: Searching a full name

Hi Jonathan!

Here's he bug fix release:

		int commaIndex = allFields.indexOf(',');
		NSMutableArray couples = new NSMutableArray();

		if (commaIndex > 0)
		{
			couples.addObject(
				new String[] {
					allFields.substring(0, commaIndex).trim(),
					allFields.substring(commaIndex + 1, allFields.length()).trim()});
		}
		else
		{
			StringTokenizer st = new StringTokenizer(allFields, " ");
			int count = st.countTokens();
			NSMutableArray words = new NSMutableArray(count);

			while (st.hasMoreTokens())
			{
				words.addObject(st.nextElement());
			}

			for (int i = 0; i < count; i++)
			{
				StringBuffer one = new StringBuffer();
				StringBuffer two = new StringBuffer();

				for (int j = 0; j < i; j++)
				{
					if (j > 0)
					{
						one.append(" ");
					}

					one.append(words.objectAtIndex(j));
				}

				for (int j = i; j < count; j++)
				{
					if (j > i)
					{
						two.append(" ");
					}

					two.append(words.objectAtIndex(j));
				}

				couples.addObject(new String[] { one.toString(), two.toString()});
			}
		}

		int cCount = couples.count();
		NSMutableArray qualifiers = new NSMutableArray(cCount * 2);

		for (int c = 0; c < cCount; c++)
		{
			String[] couple = (String[]) couples.objectAtIndex(c);
			String wordOne = couple[0];
			String wordTwo = couple[1];

			if ((wordOne.length() > 0) && (wordTwo.length() > 0))
			{
				EOQualifier variantOne =
					new EOAndQualifier(
						new NSArray(
							new EOQualifier[] {
								new EOKeyValueQualifier(
									"firstName",
									EOQualifier.QualifierOperatorCaseInsensitiveLike,
									wordOne),
								new EOKeyValueQualifier(
									"lastName",
									EOQualifier.QualifierOperatorCaseInsensitiveLike,
									wordTwo)}));
				EOQualifier variantTwo =
					new EOAndQualifier(
						new NSArray(
							new EOQualifier[] {
								new EOKeyValueQualifier(
									"firstName",
									EOQualifier.QualifierOperatorCaseInsensitiveLike,
									wordTwo),
								new EOKeyValueQualifier(
									"lastName",
									EOQualifier.QualifierOperatorCaseInsensitiveLike,
									wordOne)}));

				qualifiers.addObject(variantOne);
				qualifiers.addObject(variantTwo);
			}
			else
			{
				String word = (wordOne.length() > 0) ? wordOne : wordTwo;
				EOQualifier qualifierOne =
					new EOKeyValueQualifier(
						"firstName",
						EOQualifier.QualifierOperatorCaseInsensitiveLike,
						word);
				EOQualifier qualifierTwo =
					new EOKeyValueQualifier(
						"lastName",
						EOQualifier.QualifierOperatorCaseInsensitiveLike,
						word);

				qualifiers.addObject(qualifierOne);
				qualifiers.addObject(qualifierTwo);
			}
		}

		NSLog.out.appendln("   new EOOrQualifier(qualifiers)  = " + new EOOrQualifier(qualifiers));

		return new EOOrQualifier(qualifiers);

All remaining bugs are left as an exercise to the reader ;-)

Pierre.


**********************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
**********************************************************************

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: OpenBasePlugIn
  • Next by Date: Re: OpenBasePlugIn
  • Previous by thread: RE: Searching a full name
  • Next by thread: First Wonder Project Instructions
  • Index(es):
    • Date
    • Thread