Source code: org/alicebot/server/core/targeting/TargetWriter.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.targeting;
6
7 import java.io.File;
8 import java.util.*;
9 import org.alicebot.server.core.Globals;
10 import org.alicebot.server.core.util.*;
11
12 // Referenced classes of package org.alicebot.server.core.targeting:
13 // Targeting, Target
14
15 public class TargetWriter extends Targeting
16 {
17
18 public TargetWriter()
19 {
20 }
21
22 public static void rewriteTargets(HashMap hashmap, File file)
23 {
24 if(!file.canWrite())
25 {
26 Trace.userinfo("Cannot write targets.");
27 return;
28 }
29 file.delete();
30 XMLResourceSpec xmlresourcespec = new XMLResourceSpec();
31 xmlresourcespec.description = "Targeting Data";
32 xmlresourcespec.path = file.getAbsolutePath();
33 xmlresourcespec.root = "targets";
34 xmlresourcespec.dtd = XMLResourceSpec.HTML_ENTITIES_DTD;
35 xmlresourcespec.encoding = Globals.getProperty("programd.targeting.data.encoding", "UTF-8");
36 Iterator iterator = hashmap.values().iterator();
37 if(iterator.hasNext())
38 for(; iterator.hasNext(); write((Target)iterator.next(), xmlresourcespec));
39 else
40 write(null, xmlresourcespec);
41 }
42
43 public static void write(Target target, XMLResourceSpec xmlresourcespec)
44 {
45 if(target != null)
46 XMLWriter.write(" <target>" + Targeting.LINE_SEPARATOR + " " + " " + "<input>" + Targeting.LINE_SEPARATOR + " " + " " + " " + "<text>" + target.getLastInputText() + "</text>" + Targeting.LINE_SEPARATOR + " " + " " + " " + "<that>" + target.getLastInputThat() + "</that>" + Targeting.LINE_SEPARATOR + " " + " " + " " + "<topic>" + target.getLastInputTopic() + "</topic>" + Targeting.LINE_SEPARATOR + " " + " " + "</input>" + Targeting.LINE_SEPARATOR + " " + " " + "<match>" + Targeting.LINE_SEPARATOR + " " + " " + " " + "<pattern>" + target.getMatchPattern() + "</pattern>" + Targeting.LINE_SEPARATOR + " " + " " + " " + "<that>" + target.getMatchThat() + "</that>" + Targeting.LINE_SEPARATOR + " " + " " + " " + "<topic>" + target.getMatchTopic() + "</topic>" + Targeting.LINE_SEPARATOR + " " + " " + " " + "<template>" + target.getMatchTemplate() + "</template>" + Targeting.LINE_SEPARATOR + " " + " " + "</match>" + Targeting.LINE_SEPARATOR + " " + " " + "<reply>" + target.getLastReply() + "</reply>" + Targeting.LINE_SEPARATOR + " " + "</target>" + Targeting.LINE_SEPARATOR, xmlresourcespec);
47 else
48 XMLWriter.write("", xmlresourcespec);
49 }
50 }