Source code: org/alicebot/server/core/processor/IndexedPredicateProcessor.java
1 // Decompiled by Jad v1.5.8c. Copyright 2001 Pavel Kouznetsov.
2 // Jad home page: http://www.geocities.com/kpdus/jad.html
3 // Decompiler options: packimports(3)
4
5 package org.alicebot.server.core.processor;
6
7 import java.util.ArrayList;
8 import org.alicebot.server.core.*;
9 import org.alicebot.server.core.parser.TemplateParser;
10 import org.alicebot.server.core.parser.XMLNode;
11 import org.alicebot.server.core.util.DeveloperError;
12 import org.alicebot.server.core.util.Toolkit;
13
14 // Referenced classes of package org.alicebot.server.core.processor:
15 // AIMLProcessor
16
17 public abstract class IndexedPredicateProcessor extends AIMLProcessor
18 {
19
20 public IndexedPredicateProcessor()
21 {
22 }
23
24 public String process(int i, XMLNode xmlnode, TemplateParser templateparser, String s, int j)
25 {
26 if(j != 1 && j != 2)
27 return "";
28 int ai[] = TemplateParser.getValid2dIndex(xmlnode);
29 if(ai[0] <= 0)
30 return "";
31 String s1 = PredicateMaster.get(s, ai[0], templateparser.getUserID(), templateparser.getBotID());
32 Bot bot = Bots.getBot(templateparser.getBotID());
33 ArrayList arraylist = bot.sentenceSplit(s1);
34 int k = arraylist.size();
35 if(k == 0)
36 return s1;
37 if(ai[1] > k)
38 return "";
39 else
40 return Toolkit.removeMarkup((String)arraylist.get(k - ai[1])).trim();
41 }
42
43 public String process(int i, XMLNode xmlnode, TemplateParser templateparser, ArrayList arraylist, int j)
44 {
45 if(j != 1)
46 throw new DeveloperError("Wrong number of dimensions: " + j + " != 1");
47 if(arraylist.isEmpty())
48 return "";
49 int k = TemplateParser.getValid1dIndex(xmlnode);
50 if(--k >= arraylist.size())
51 return "";
52 else
53 return Toolkit.removeMarkup((String)arraylist.get(k)).trim();
54 }
55 }