Mercurial > hg > mpdl-group
comparison software/eXist/mpdl-modules/src/de/mpg/mpiwg/berlin/mpdl/lt/doc/regularization/Regularization.java @ 0:408254cf2f1d
Erstellung
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Wed, 24 Nov 2010 17:24:23 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:408254cf2f1d |
---|---|
1 package de.mpg.mpiwg.berlin.mpdl.lt.doc.regularization; | |
2 | |
3 import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException; | |
4 import de.mpg.mpiwg.berlin.mpdl.util.StringUtilEscapeChars; | |
5 import de.mpg.mpiwg.berlin.mpdl.util.XmlUtil; | |
6 | |
7 public class Regularization { | |
8 private String language; | |
9 private String orig; | |
10 private String norm; | |
11 private String source; | |
12 private int sourcePosition; | |
13 | |
14 public Regularization(String language, String orig, String norm, String source) { | |
15 this.language = language; | |
16 this.orig = orig; | |
17 this.norm = norm; | |
18 this.source = source; | |
19 } | |
20 | |
21 public static Regularization getInstance(String xmlStr) throws ApplicationException { | |
22 XmlUtil xmlUtil = XmlUtil.getInstance(); | |
23 String language = xmlUtil.evaluateToString(xmlStr, "//language", null); | |
24 String orig = xmlUtil.evaluateToString(xmlStr, "//orig", null); | |
25 String norm = xmlUtil.evaluateToString(xmlStr, "//norm", null); | |
26 String source = xmlUtil.evaluateToString(xmlStr, "//source", null); | |
27 String sourcePosStr = xmlUtil.evaluateToString(xmlStr, "//source/@position", null); | |
28 int sourcePos = new Integer(sourcePosStr); | |
29 Regularization reg = new Regularization(language, orig, norm, source); | |
30 reg.setSourcePosition(sourcePos); | |
31 return reg; | |
32 } | |
33 | |
34 public String getLanguage() { | |
35 return language; | |
36 } | |
37 | |
38 public void setLanguage(String language) { | |
39 this.language = language; | |
40 } | |
41 | |
42 public String getOrig() { | |
43 return orig; | |
44 } | |
45 | |
46 public void setOrig(String orig) { | |
47 this.orig = orig; | |
48 } | |
49 | |
50 public String getNorm() { | |
51 return norm; | |
52 } | |
53 | |
54 public void setNorm(String norm) { | |
55 this.norm = norm; | |
56 } | |
57 | |
58 public String getSource() { | |
59 return source; | |
60 } | |
61 | |
62 public void setSource(String source) { | |
63 this.source = source; | |
64 } | |
65 | |
66 public int getSourcePosition() { | |
67 return sourcePosition; | |
68 } | |
69 | |
70 public void setSourcePosition(int sourcePosition) { | |
71 this.sourcePosition = sourcePosition; | |
72 } | |
73 | |
74 public String getXmlString() { | |
75 String xmlString = "<reg>\n"; | |
76 if (language != null) | |
77 xmlString += " <language>" + language + "</language>\n"; | |
78 if (orig != null) | |
79 xmlString += " <orig>" + StringUtilEscapeChars.deresolveXmlEntities(orig) + "</orig>\n"; | |
80 if (norm != null) | |
81 xmlString += " <norm>" + StringUtilEscapeChars.deresolveXmlEntities(norm) + "</norm>\n"; | |
82 if (source != null) | |
83 xmlString += " <source position=\"" + sourcePosition + "\">" + StringUtilEscapeChars.deresolveXmlEntities(source) + "</source>\n"; | |
84 xmlString += "</reg>\n"; | |
85 return xmlString; | |
86 } | |
87 | |
88 | |
89 } |