Source code: org/alicebot/server/core/processor/GenderProcessor.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.HashMap;
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.Substituter;
12
13 // Referenced classes of package org.alicebot.server.core.processor:
14 // AIMLProcessor, ProcessorException, AIMLProcessorException
15
16 public class GenderProcessor extends AIMLProcessor
17 {
18
19 public GenderProcessor()
20 {
21 }
22
23 public String process(int i, XMLNode xmlnode, TemplateParser templateparser)
24 throws AIMLProcessorException
25 {
26 if(xmlnode.XMLType == 0)
27 try
28 {
29 return templateparser.processResponse(applySubstitutions(templateparser.evaluate(i++, xmlnode.XMLChild), templateparser.getBotID()));
30 }
31 catch(ProcessorException processorexception)
32 {
33 throw (AIMLProcessorException)processorexception;
34 }
35 if(xmlnode.XMLType == 1)
36 {
37 if(!Globals.supportDeprecatedTags())
38 return templateparser.shortcutTag(i, "gender", 0, "", "star", 1);
39 else
40 return templateparser.shortcutTag(i, "bot", 1, "name=\"gender\"", "", 1);
41 } else
42 {
43 throw new AIMLProcessorException("Invalid gender element!");
44 }
45 }
46
47 public static String applySubstitutions(String s, String s1)
48 {
49 return Substituter.applySubstitutions(Bots.getBot(s1).getGenderSubstitutionsMap(), s);
50 }
51
52 public static void addSubstitution(String s, String s1)
53 {
54 if(s != null && s1 != null)
55 substitutionMap.put(s.toUpperCase(), s1);
56 }
57
58 public static final String label = "gender";
59 private static HashMap substitutionMap = new HashMap();
60
61 }